Discuss Web Components integration
See original GitHub issueI understand that as an early adopter using technology like Web Components, I cannot expect the existing tooling I’m accustomed to, to “just work”. Although in the case of Semantic UI, I’m worried that its current design decisions do not align with the future of isolation and custom elements in the web via Web Components.
Example: You are building a data grid and want to separate the table from the row via components. So you have the following two components:
- TableComponent
- TableRowComponent
Once rendered the DOM Tree looks something like:
~ TableComponent ~
-> Shadow Root
-> slot (table)
-> table
-> thead
-> tbody
-> ~ TableRowComponent (Subclasses TR) ~
-> Shadow Root
-> td
-> td
The problem may not be immediately obvious, but as styles do not cross the shadow boundary and the way that Semantic UI forfeits explicit class names for element names, means that it’s pretty much impossible to get this to work:
/* .ui.celled.table is styled perfectly, but there's no way to cascade into the td */
.ui.celled.table tr td, .ui.celled.table tr th {
border-left: 1px solid rgba(34,36,38,.1);
}
How can we get these styles into the Shadow Root?
- CSS Variables? (Not really, they won’t substitute full blocks, could help with theming)
- Flat class names? (Good solution, but 3671 didn’t fair well…)
- JavaScript? (Really hope not)
Does the project/community have thoughts on this fundamental design problem?
Issue Analytics
- State:
- Created 7 years ago
- Reactions:3
- Comments:13
Top GitHub Comments
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.
Looks like
is
didn’t make it to the v1 specification which is very frustrating to learn. So the above code doesn’t work. The best you can do right now is:This displays correctly and will be styled nicely by Semantic UI. Issues will occur once you decide to make
<some-custom-row>
re-usable and stateful using Web Components.I’m going to investigate generating Web Components for Semantic UI. Would be nice to have a UI Toolkit for diffHTML (the tool I’m working on) and this way I could simply extend from
SemanticUITableRow
like this:This would be automatically styled, next pass could be maybe making them stateful w/ the JS.