-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Besides having both stateless and stateful components as pure functions of data, it would be good to also add support for the new Custom Elements style classes and the more traditional D3 components. D3 components should be straightforward given it was the source of the inspiration for the current components. Classes would be expected to have a similar declarative render function (draw) but also allows developers to more neatly setup other methods/accessors/lifecycle hooks/etc. This should also improve interop.
Classical D3 Component
function chart() {
var width = 720, // default width
height = 80; // default height
function my() {
// generate chart here, using `width` and `height`
}
my.width = function(value) {
if (!arguments.length) return width;
width = value;
return my;
};
my.height = function(value) {
if (!arguments.length) return height;
height = value;
return my;
};
return my;
}Custom Element Class
class MyComponent extends HTMLElement {
// can move name and other meta data here..
name: 'my-component'
get width(){
return this._width
}
set width(value){
this._width = value
}
draw(node, data) {
// update node
jsx(node)`
...
`
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels