-
Notifications
You must be signed in to change notification settings - Fork 66
Description
this was discussed on Discord and @Pauan suggested something like the following syntax:
static STYLE1: Lazy<Stylesheet> = Lazy::new(|| stylesheet!("div.bar", {
.style(...)
}));
html!("div", {
.shadow_root!(ShadowRootMode::Open, {
.stylesheet(&*STYLE1)
.children(&mut [ ... ])
})
})
The Stylesheet here should somehow use Constructable Stylesheet Objects - such that if the above html! were called 100 times to add instances of this component to a page, they should all share the same static stylesheet.
Even though the stylesheet is static, its inner contents can be changed and so the above will support .style_signal()
It's likely that these stylesheets, scoped to a shadow root, will often define many rules at once - so it would be more efficient and convenient to have a wrapper that collects them all.
This wrapper could be called stylesheets!, or perhaps, stylesheet! becomes the wrapper and each rule uses a rule! macro. If going with the latter, the above could look like:
static STYLE1: Lazy<Stylesheet> = Lazy::new(|| stylesheet!(&[
rule!("div.bar", {
.style(...)
}),
rule!("ul > li + li", {
.style_signal(...)
})
]));
html!("div", {
.shadow_root!(ShadowRootMode::Open, {
.stylesheet(&*STYLE1)
.children(&mut [ ... ])
})
})