The site initializes the runtime once, in ThemeContext, with applyTheme(themes.default, { replace: true, styleId: 'uxdsl-ssr-theme' }) — the override it was built with — and applies the other named themes the same way when you pick one in the header. The calls here only read that state: getAppliedTheme() returns the applied override, subscribeTheme(listener) is notified after each successful application, and getPalette('primary-main') reads the computed custom property.
defaultgetAppliedTheme() — families in the applied overridegetAppliedTheme().palette.primary.maingetPalette('primary-main') — the computed custom propertyThe two can differ: the override holds the light value, and in dark mode the stylesheet applyTheme generated switches primary-main to modes.dark's — which is what getPalette reads.
subscribeTheme(listener)No application yet since this page loaded. Switch the theme in the header: each successful applyTheme notifies this listener.
applyTheme, resetTheme and loadPersistedTheme manage one stylesheet per document; the per-token setters (updatePalette, updateColor, updateSpacing, updateBreakpoint) write inline custom properties and rewrite compiled media queries. On this page they would compete with ThemeContext, so they run in the frame below: a page compiled with this site's default theme (by the real compiler, at build time), with its own document and its own copy of the runtime. Run the steps in order, watch the frame and the report, and reload the sandbox to undo everything.
Two results are worth reading closely, because they are the honest edges of the old API rather than bugs in this page. After updatePalette, a later applyTheme returns ok: true and the color does not change: the inline value beats any stylesheet (this site's ThemeContext clears those inline values after each application for exactly that reason). And after updateBreakpoint('md', 900), getBreakpoints() says 900 while getAppliedTheme() still says 768: the legacy API rewrote the compiled rules, not the theme, and applyTheme itself refuses to move a threshold (UXD_THEME_STRUCTURE) — moving one is a rebuild.
loadPersistedTheme is always called here with the lab's own key and migrateLegacy: false. A default call migrates, and then deletes, the four pre-beta.6 storage keys — which this site's older demos still write.
subscribeTheme / subscribe heardRun a step. Each call's return value is shown as it came back.
These functions are pure: they take a theme and return a value, so they run on this page against the active theme. resolveTheme is the one place an effective theme is built (the base with an override merged over it); buttonDeclarations, inputDeclarations and resolveTypographyRole are what @ds-button, @ds-input and @ds-typo expand to — the compiler calls the same functions; googleFontsImportUrls and encodeGoogleFontFamily build the Google Fonts @import both the compiler and generateThemeCss emit.
resolveTheme(override) and getDefaultTheme()| Variant | resolveTheme | From | getDefaultTheme |
|---|---|---|---|
main | #0f766e | your override | #7e22ce |
light | #a855f7 | base | #a855f7 |
dark | #581c87 | base | #581c87 |
contrast | #ffffff | base | #ffffff |
Override only main and dark/contrast come from the base: the same merge uxdsl theme --diff labels leaf by leaf (see the CLI page).
buttonDeclarations · inputDeclarations · resolveTypographyRoleWhat @ds-button(contained) emits for the active theme:
padding | var(--uxdsl__surface__contained-padding) |
border-radius | var(--uxdsl__surface__contained-radius) |
background | var(--uxdsl__surface__contained-bg) |
color | var(--uxdsl__surface__contained-color) |
border | var(--uxdsl__surface__contained-border) |
box-shadow | var(--uxdsl__surface__contained-shadow) |
background | var(--uxdsl__button__contained-hover-bg) |
color | var(--uxdsl__button__contained-hover-color) |
background | var(--uxdsl__button__contained-selected-bg) |
color | var(--uxdsl__button__contained-selected-color) |
googleFontsImportUrls · encodeGoogleFontFamilyThe active theme's fonts.google, as the @import URLs the compiler and generateThemeCss both emit:
https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap encodeGoogleFontFamily → Noto+Sans+JP:wght@400;700