adobe / react-webcomponent

This projects automates the wrapping of a React component in a CustomElement.
Apache License 2.0
105 stars 19 forks source link

Allow capturing of child content into the web component #4

Closed cuberoot closed 5 years ago

cuberoot commented 5 years ago

Expected Behaviour

This is a feature request.

There should be a @byContent decorator that would allow capturing of arbitrary DOM content that the web component user has placed into a wrapped web component.

                <popover open={ true } title="Title">
                    <section>
                        <button on-click={ (event) => this.handleClick(event) }>Push Me</button>
                    </section>
                </popover>

So, if popover is a wrapped web component, we want the user to be able to pass our component content to put inside our component.

class PopoverModel extends DOMModel {
    @byAttrVal() title;
    @byBooleanAttrVal() open = true;
    @byContent('section') content;
}

So, once the above model was parsed, there would be a content field that would contain a React component that you could render into the React component that you are wrapping.