Skip to content

feat: add support for more component types (Custom Element classes and D3 functions) #29

Description

@pemrouz

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

functionchart(){varwidth=720,// default widthheight=80;// default heightfunctionmy(){// generate chart here, using `width` and `height`}my.width=function(value){if(!arguments.length)returnwidth;width=value;returnmy;};my.height=function(value){if(!arguments.length)returnheight;height=value;returnmy;};returnmy;}

Custom Element Class

classMyComponentextendsHTMLElement{// can move name and other meta data here..name: 'my-component'getwidth(){returnthis._width}setwidth(value){this._width=value}draw(node,data){// update nodejsx(node)` ... `}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions