@converse/skeletor 0.0.3 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -7
- package/dist/skeletor.js +508 -1048
- package/dist/skeletor.js.map +1 -1
- package/dist/skeletor.min.js +4 -93
- package/dist/skeletor.min.js.map +1 -1
- package/package.json +6 -7
- package/src/collection.js +1 -1
- package/src/drivers/indexeddb-getitems.js~ +1116 -0
- package/src/drivers/indexeddb.js~ +1115 -0
- package/src/storage.js +11 -8
- package/src/storage.js~ +13 -9
- package/CHANGES.md +0 -26
- package/dist/skeletor.js~ +0 -2291
- package/src/.events.js.swp +0 -0
- package/src/.helpers.js.swp +0 -0
- package/src/.history.js.swp +0 -0
- package/src/.model.js.swp +0 -0
- package/src/.overview.js.swp +0 -0
- package/src/.router.js.swp +0 -0
- package/src/.view.js.swp +0 -0
- package/src/collection.js~ +0 -737
- package/src/drivers/.sessionStorage.js.swp +0 -0
- package/src/drivers/sessionStorage.js~ +0 -316
- package/src/element-overview.js~ +0 -4
- package/src/element.js~ +0 -190
- package/src/events.js~ +0 -334
- package/src/helpers.js~ +0 -151
- package/src/history.js~ +0 -301
- package/src/htmlview.js~ +0 -14
- package/src/model.js~ +0 -439
- package/src/orderedlist.js~ +0 -88
- package/src/overview.js~ +0 -111
- package/src/router.js~ +0 -119
- package/src/vdomview.js~ +0 -15
- package/src/view.js~ +0 -283
package/README.md
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
1
|
# Skeletor
|
|
2
2
|
|
|
3
|
-
[](https://inverse.chat/#converse/room?jid=discuss@conference.conversejs.org)
|
|
4
4
|
[](https://travis-ci.org/conversejs/skeletor)
|
|
5
5
|
|
|
6
|
-
Skeletor is a [Backbone](http://backbonejs.org) fork.
|
|
6
|
+
Skeletor is a [Backbone](http://backbonejs.org) fork that adds various improvements and features.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
## Introduction
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
The goal of Skeletor is to modernize Backbone and to allow you to stop
|
|
11
|
+
writing imperative view code (e.g. manually adding and removing DOM nodes)
|
|
12
|
+
and instead start writing declarative, component-based code that automatically
|
|
13
|
+
updates only the changed parts of the DOM, similarly to basically all modern
|
|
14
|
+
JavaScript frameworks.
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
The original Backbone Views aren't components can't be rendered in a nested and
|
|
17
|
+
declarative way. Instead, it's up to you to manually make sure that these views
|
|
18
|
+
are rendered in the correct place in the DOM. This approach becomes unwieldy,
|
|
19
|
+
difficult and fragile as your site becomes larger and more complex.
|
|
20
|
+
|
|
21
|
+
Skeletor solves this by creating a new type of View, called `ElementView`,
|
|
22
|
+
which is very similar to the original Backbone `View` but which is also a web
|
|
23
|
+
component that gets instantiated automatically as soon as its rendered in the
|
|
24
|
+
DOM.
|
|
14
25
|
|
|
15
26
|
## Why bother?
|
|
16
27
|
|
|
@@ -18,7 +29,7 @@ The goal of this fork is to allow the Converse team to gradually update the [Con
|
|
|
18
29
|
XMPP webchat client to use web components (using [LitElement](https://lit-element.polymer-project.org/))
|
|
19
30
|
without requiring us to put everything on hold in order to do a massive rewrite.
|
|
20
31
|
|
|
21
|
-
The end-goal is to not have any
|
|
32
|
+
The end-goal is to not have any Skeletor Views at all, only LitElement components.
|
|
22
33
|
|
|
23
34
|
We can cheat a little by letting the existing Views also be web components
|
|
24
35
|
(more accurately, "custom elements"), this allows us to declaratively render the
|
|
@@ -60,3 +71,55 @@ UI, while we're progressively getting rid of the views.
|
|
|
60
71
|
5. The `partition` and `invokeMap` methods have been removed.
|
|
61
72
|
|
|
62
73
|

|
|
74
|
+
### ElementView example
|
|
75
|
+
|
|
76
|
+
The ElementView looks very similar to a normal Backbone View.
|
|
77
|
+
|
|
78
|
+
Since it's a web component, you need to call `CustomElementRegistry.define` to
|
|
79
|
+
register it.
|
|
80
|
+
|
|
81
|
+
The `this` variable for the ElementView is the custom DOM element itself,
|
|
82
|
+
in this case, `<my-custom-button>`.
|
|
83
|
+
|
|
84
|
+
So there is no `el` attribute and `this.el` will be undefined. Whereever in a
|
|
85
|
+
Backbone View you'd use `this.el`, with an ElementView you'd just use `this`.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
```javascript
|
|
89
|
+
|
|
90
|
+
import { ElementView } from '@converse/skeletor/src/element.js';
|
|
91
|
+
import { render } from 'lit';
|
|
92
|
+
import { html } from 'lit';
|
|
93
|
+
|
|
94
|
+
export default class MyCustomButton extends ElementView {
|
|
95
|
+
events = {
|
|
96
|
+
'click .button': 'onButtonClicked'
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async initialize () {
|
|
100
|
+
this.model = new Model({ count: 0 });
|
|
101
|
+
this.listenTo(this.model, 'change', this.render)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
render () {
|
|
105
|
+
return render(html`<button class="button">I've been clicked ${model.get('count')} times!</button>`, this);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
onButtonClicked () {
|
|
109
|
+
this.model.save('count', this.model.get('count')+1);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
CustomElementRegistry.define('my-custom-button', MyCustomButton);
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
You can now put your custom element in the DOM, and once the DOM is loaded by
|
|
117
|
+
the browser, your ElementView will automatically be instantiated and
|
|
118
|
+
`initialize` will be called.
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<div>
|
|
123
|
+
<my-custom-button></my-custom-button>
|
|
124
|
+
</div>
|
|
125
|
+
```
|