sashafirsov / shadow-dom-element

shadow-dom-element web component to render local and remote template
Apache License 2.0
0 stars 0 forks source link

Diary - design & implementation thoughts #1

Open sashafirsov opened 2 years ago

sashafirsov commented 2 years ago

shadow-dom-element is a first implementation capable of external templates with native TEMPLATE and SLOT use by web page. As such, it could serve as façade to whole concept of native templates use for developers community. Making it simple, efficient, and sexy would serve the evangelizing purpose.

The Ananke site template demo for shadow and light DOM included into sources, is just a brief reference implementation which is not sufficient as bootstrap for the site and does not have a guideline.

The idea of JsonResume.org theme could be a good starting point.

Registering of such resume templates could be automated by visiting forked repos with embedded signed disclaimer. GitHub Stars or NPM stats could serve the listing priority.

sashafirsov commented 2 years ago

Rendering JSON 🤔 most of data are passed as non-UI friendly format, novadays mostly as JSON. Native HTML template does not work with such. It injects HTML via slot. How to pass the JSON data into slot?

As slotted-element is planned to be inherited form light-dom-element, its behavior could change.

Would conversion of JSON to template-able HTML be a better approach?

For simple JSON with key:value pairs there is straight answer.

`<span slot="${key}">${value}</span>`

The row of SPANs would reflect the JSON pairs and template would serve slots of interest.

slot concept does not reflect the hierarchical and recurrent data structure. Can it be worked around by template+slot concept? Can the template inclusion or recursion be used for structure and repeated slots for array relation?