Run the following commands:
cd componentsnpm installoryarn installyarn start
Directories
components/src/components- contains a stenciljs-bootstraped projectcomponents/src/components/components- contains a set of web components used when renderingcomponents/src/components/utils- utility functions
<jsc-app></jsc-app> is the main entry point for rendering a component. A component is rendered by providing a list of objects conforming to a speficic standard.
Here's an example of how we can render a Navbar component:
[
{
"component":"Navbar",
"sections":{
"links":[
{
"component":"NavLink",
"props":{
"label":"Home"
}
},
{
"component":"NavLink",
"props":{
"label":"About"
}
}
]
},
"props":{
"title": "Jaseci App"
}
}
]The above code will generate the following markup.
<jsc-nav-bar label="Jaseci App">
<div slot="links">
<jsc-nav-link label="Home"></jsc-nav-link>
<jsc-nav-link label="About"></jsc-nav-link>
</div>
</jsc-nav-bar>componentis used to determine which html element to generate.sectionsare array of components to be rendered as a child ofcomponent, each slot has a name to determine where it will be renderedpropsare attributes that will be attached to the generated element
The generated navbar might look like this:
- renderComponentTree
- The
renderComponentTreefunctions accepts an array ofJaseciComponentand converts it to a string of custom html elements.
- The
- renderComponent
renderComponentaccepts a singleJaseci Componentcomponent and generates and converts it to a custom html element
