Runtime application of user themes. Built-in themes ship in the static
styles/foundation/accents.css; user themes aren't in that bundle, so their
[data-accent] rules are generated here and applied at runtime.
Delivery: a constructable CSSStyleSheet added to document.adoptedStyleSheets
(unlayered, so it also wins over the layered built-in accents.css — that's
how a user theme can OVERRIDE a built-in of the same id). Falls back to a
<style> element where constructable stylesheets aren't supported.
The rules mirror the generator (scripts/gen-accents.mjs) exactly, so a user
theme behaves identically to a system one. Values come only from
parseThemeFile (validated hex + id), so the generated CSS is safe.
- Description:
Runtime application of user themes. Built-in themes ship in the static
styles/foundation/accents.css; user themes aren't in that bundle, so their[data-accent]rules are generated here and applied at runtime.Delivery: a constructable
CSSStyleSheetadded todocument.adoptedStyleSheets(unlayered, so it also wins over the layered built-inaccents.css— that's how a user theme can OVERRIDE a built-in of the same id). Falls back to a<style>element where constructable stylesheets aren't supported.The rules mirror the generator (scripts/gen-accents.mjs) exactly, so a user theme behaves identically to a system one. Values come only from
parseThemeFile(validated hex + id), so the generated CSS is safe.
- Source:
Methods
(static) applyUserThemes(themes)
- Description:
Apply (or refresh) the runtime stylesheet for the given user themes. Idempotent — call whenever the user-theme list changes.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
themes |
Array.<object> |
(inner) cssFor()
- Description:
The two rules (dark + light) for one theme, matching the built-in format.
- Source: