File tree Expand file tree Collapse file tree
packages/design-system/.ladle Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -27,11 +27,18 @@ export const Provider: GlobalProvider = ({ children }) => {
2727 read < boolean > ( 'ladle-dark' , false )
2828 )
2929
30+ // Mirror the selection onto <body> as well. Ladle injects this Provider inside
31+ // <main>, so the wrapping ThemeProvider below themes only the story; setting
32+ // `data-theme` / `.dark` on <body> extends the DS theme context to the whole
33+ // Ladle app (the component menu + toolbar chrome), so `var(--primary)` resolves
34+ // per-theme globally and head.html can drive Ladle's own accent from it.
3035 React . useEffect ( ( ) => {
3136 window . localStorage . setItem ( 'ladle-theme' , JSON . stringify ( theme ) )
37+ document . body . setAttribute ( 'data-theme' , theme )
3238 } , [ theme ] )
3339 React . useEffect ( ( ) => {
3440 window . localStorage . setItem ( 'ladle-dark' , JSON . stringify ( dark ) )
41+ document . body . classList . toggle ( 'dark' , dark )
3542 } , [ dark ] )
3643
3744 return (
Original file line number Diff line number Diff line change 2323 * {
2424 font-family : var (--theme-font-primary );
2525 }
26+
27+ /* Drive Ladle's own chrome accent (active menu item, focus, links) from the
28+ selected DS theme, so the theme switch is visible on the global view (the
29+ component menu), not just inside a story. `data-theme` is mirrored onto
30+ <body> by the Ladle Provider; `--primary` resolves per-theme there
31+ (UZH blue under uzh, near-black under neutral). */
32+ body [data-theme ] {
33+ --ladle-color-accent : var (--primary );
34+ }
35+ /* Also tint the active component in the menu (Ladle bolds it via
36+ `.ladle-active a`) so the selected theme is obvious right in the list. */
37+ .ladle-aside .ladle-active a {
38+ color : var (--primary );
39+ }
2640</ style >
You can’t perform that action at this time.
0 commit comments