-
Notifications
You must be signed in to change notification settings - Fork 0
/
readme.template
133 lines (77 loc) · 3.14 KB
/
readme.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
[![npm (scoped)](https://img.shields.io/npm/v/@basiclines/leo.svg?style=flat-square)](https://www.npmjs.com/package/@basiclines/leo)
# LEO
<img src="https://image.ibb.co/kNvycS/logo.png" width="128px">
> LEO is a lightweight JS library that helps you build modern front-end applications.
LEO Provides 3 simple tools (List, Element, Object) to help you build and grow you JS application without defining any specific architecture for you.
* **List**: A list (Array) of Objects
* **Element**: A web-components based solution with reactive bindings.
* **Object**: A object with key-value bindings and customs events.
## About
As an intent of reunite the best in class JS paradigms that are spread over the different ways of building modern javascript applications, LEO extracts different patterns from different frameworks and puts them together for you:
* **From Backbone**: LEO uses the same idea behind Backbone models (Object) and collections (Lists) with a simpler interface that doesn't need any `.get` or `.set` methods.
* **From React**: LEO Element class provides a `render` method that is called whenever the element `data` or `attrs` properties are changed.
* **From Web-Components**: Style and behaviour encapsulation. Any LEO Element can be registered as a web-component with it's custom tag name.
LEO doesn't provides any architecture or specific design decisions for you and it's built entirely with the new ES6 features
## Install
```bash
npm install --save @basiclines/leo
```
### Webpack and Babel configuration
Use the sample configuration from `/examples`, you will find:
* `package.json`
* `.babelrc`
* `webpack.config.js`
## Object usage
```js
import {LEOObject} from 'leo'
class Star extends LEOObject {}
let bowie = new Star({ name: 'David' })
bowie.on('change:name', (name) => { console.log(name) })
bowie.name = 'Ziggy'
```
## Element usage
```js
import {LEOElement} from 'leo'
class StarElement extends LEOElement {
render() {
this.innerHTML = this.attrs.title
}
}
customElements.define('star-element', StarElement)
```
```html
<star-element title="David Bowie"></star-element>
```
## List usage
```js
import {LEOList} from 'leo'
let Constellation = new LEOList([
{ name: 'Polaris', declination: 'N 89°' },
{ name: 'Kochab', declination: 'N 74°' }
])
Constellation.on('add', (obj) => {
console.log('Added obj', obj)
})
Constellation.on('change', (obj) => {
console.log('changed obj', obj)
})
Constellation.push({ name: 'Schedar', declination: 'N 56°' })
Constellation.push({ name: 'Alkaid', declination: 'N 49°' })
Constellation.map(item => { item.name = `Star ${item.name}` })
```
## Examples
Inside `/examples` you can find common code examples.
## API
### LEOObject
A object with key-value bindings and customs events.
{{ object_table }}
### LEOElement
A web-components based solution with reactive bindings.
{{ element_table }}
### LEOList (extends LEOObject)
A list (Array) of objects that inherits all event based behaviour from LEOObject.
{{ list_table }}
## Disclaimer
LEOJS project is still under development and it's not recommended for production use.
## License
[MIT](http://vjpr.mit-license.org)