flatman-component
v0.18.1
Published
#### π« 18 of 25 tests passed (72%)
Downloads
11
Readme
Flatman Component 0.11.3
License: MIT
π« 18 of 25 tests passed (72%)
Table of Contents
Overview
Description
Example
Installation
Notes
Component.create
Description
Description.md (top)
A Component function to work with flatman-server
and flatman
. Designed to act as a replacement for the node which flatman-server
and flatman
generate.
What it does is act as an interface between the component and the this.node.document
.
Another thing it does is normalize the Component
so that it behaves like a DomNode
from flatman-server
and flatman
. Essentially making sure that if you pass a component
around or a DomNode
the behavior is consistent.
The Component
must be initialized using the facade
method.
Example
Example.md (top)
It must be initialized to add a facade to what ever constructor you are using.
You don't need to include the function because the facade
it creates will execute the methods on this
.
const el = flatman.el;
const proto = el('div').constructor.prototype;
const methods = Object.keys(proto);
Component.facade(methods);
What happens here is let's create a compoment.
Component.create('A', {
render() {
// will be set to the `node` property as 'this.node.document'
return el('div');
}
});
The Component
will expose every method that this.node.document
has. So that, additionally to the render
method, you inherit anything else that this.node.document
prototype exposes.
eg: .remove()
, .append()
, addClass()
etc. Unless these methods are prototypes of the component they will be applied to this.node.document
.
Installation
Installation.md (top)
npm i -S flatman-component
Notes
Notes.md (top)
This is a supporting library and is not intended to be used stand alone.
Component.create
Component.create.md (top)
Component.create('name', {
constructor(props) {
// optional
}
render() {
return el('div');
}
});
Tests
1. Add class.......................................................... β
2. Add class on 'className' array..................................... β
4. .appendTo()........................................................ β
8. Create component................................................... β
9. Create component (check constructor props)......................... β
10. Create component (has return value)................................ β
11. Create component thunk............................................. β
13. Component.find..................................................... β
14. getNode().......................................................... β
15. .is().............................................................. β
16. Component.onCreate................................................. β
17. Parent Component................................................... β
18. Parent Node........................................................ β
20. .removeChild()..................................................... β
21. Remove class....................................................... β
22. trigger().......................................................... β
23. trigger() undefined 'on'........................................... β
24. trigger() object................................................... β
3. .append() ......................................................... π«
5. .before() ......................................................... π«
6. .closest() ........................................................ π«
7. .closest() (string selector) ...................................... π«
12. Disable ........................................................... π«
19. .remove() ......................................................... π«
25. trigger() no node ................................................. π«