-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrating away from AngularJS #16
Changes from 9 commits
274d4b4
591d4b4
127fc85
5885b06
0c1de8f
6825442
e643de7
2984d1f
af85e91
4e84769
b213039
7a18582
17c3a86
01e2231
e8f7e43
29d0211
05bd4e3
60fde33
d26020c
415a043
d10fb47
63fb91c
0f3b239
0aaa086
2f71e07
3381b76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,4 @@ | ||
logs/* | ||
!.gitkeep | ||
.idea/ | ||
dist/ | ||
node_modules/ | ||
bower_components/ | ||
tmp | ||
.DS_Store | ||
.idea | ||
desktop.ini | ||
.travis.yml | ||
npm-debug.log | ||
src/app/TILDOCS-#40699695-v1-ùàâ æëåëàì.docx | ||
*.docx | ||
coverage/ |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Revisiting Force-Horse: Making a Legacy Plugin Agnostic and Usable | ||
For a long while, we at the company used our own AngularJS D3.js library for graphs visualizations of real-life data sets, called "[Force-Horse](https://github.com/Webiks/force-horse)". | ||
|
||
Force-Horse is an open source Javascript component wrapping a Force Layout and adding some functionalities we found very useful, like Adaptive tuning of forces and constraints parameters, Adaptive rendering cycle, Play/Pause the simulation, Multiple edges between two nodes, Weight the nodes and the edges, etc... | ||
|
||
 | ||
|
||
While you can read all of the details on the library in Ram's [blog post](http://webiks.com/force-horse-force-layout-component/), the gist of it is having a library that adapts to many types of data sets, and is easily modifiable for the users, having many modes for nodes, D3.js forces, multiple edges between nodes, supporting any size of data set, and easily allowing customization of the base SVG's design. | ||
|
||
## So... What's New? | ||
Having the library written using AngularJS, forces the user to use a deprecated framework. Either the user thinks they can just include AngularJS in the bundle, increasing the bundle, or trying to implement the component for their used framework. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A small comment: AngularJS is, of course, not the front version of Angular, but it is not deprecated. It will be with us perhaps for a long time still.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AngularJS is not, strictly speaking, deprecated. It is still supported, and widely used. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. Changed from "deprecated" to "legacy". |
||
Therefore, we decided to remove the dependency for AngularJS, making the library framework agnostic. | ||
|
||
##### Agnostification | ||
Therefore, we decided to remove the dependency, migrating AngularJS out of the library, moving to a standard browser feature - [Custom Elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Custom_Elements), supported by most browsers, or being worked on at this time (In case it isn't supported, there is a tiny browser polyfill - [see support](https://caniuse.com/#search=custom%20elements%20v0)) | ||
What’s good about using Custom Elements, is that all of the main frameworks - Angular, React, Vue, Polymer etc.. - support it for bindings of inputs and outputs, but you don't have to use a framework to use it. | ||
|
||
##### Integration | ||
We also made the component much easier to integrate, now creating 2 bundles - one for Javascript and one for CSS - and loading the images as a base64 mask directly inside the CSS, so there is no need when creating a distribution build to copy our assets anymore, just importing our CSS. | ||
|
||
##### Tests | ||
The original AngularJS component did not have many tests, so we could not ensure it was working for every user. Now, we added many unit tests for many use cases, to cover all of the grounds we need to be confidant in the stability of this awesome component. | ||
|
||
##### Standards | ||
It's 2017, so we ditched the old ES5 syntax, migrating the entire Javascript code base to ES6, taking advantage of the great things it offers. | ||
Also, we moved from CSS to SCSS, for better style management and versatility. | ||
|
||
## New Usage | ||
### Loading: | ||
With a modules bundler (recommended): | ||
```js | ||
import 'force-horse'; // Imports the web component, not compiled | ||
``` | ||
```scss | ||
@import 'force-horse'; // Imports the SCSS index file | ||
``` | ||
Directly from HTML: | ||
```html | ||
<link rel="stylesheet" type="text/css" href="node_modules/force-horse/dist/style.bundle.css" /> | ||
<script type="application/javascript" src="node_modules/force-horse/dist/main.bundle.js"></script> | ||
``` | ||
### Using: | ||
```html | ||
<force-horse options='{"json": "options"}'></force-horse> | ||
``` | ||
|
||
### Wanna Help? | ||
Working on something similar? [Contribute to our GitHub project](https://github.com/webiks/force-horse) | ||
Thinking we can improve? [Let us know](https://github.com/webiks/force-horse/issues) |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A very nice blog post and plan. A small point: it seems an exaggeration to call force-horse a "legacy" plugin. It is not that old.. it is just that javascript is developing so fast. I probably wrote it just before ES6 kicked in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
It is legacy, just because AngularJS is legacy, see:
Yeah, you kind of mixed some ES6 in there, just a bit.