@cscfi/csc-ui 4.0.0-alpha.18 → 4.0.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/csc-ui.js +1396 -1376
- package/dist/styles/css/tokens.css +15 -5
- package/dist/web-types.json +1 -1
- package/dist-types/index.d.ts +1 -1
- package/dist-types/theme/chart-data.d.ts +2 -1
- package/dist-types/theme/themeMode.d.ts +31 -8
- package/package.json +1 -1
|
@@ -134,6 +134,12 @@
|
|
|
134
134
|
* Semantic tokens. Role-named properties that resolve to a
|
|
135
135
|
* different palette step per theme mode; components author against the
|
|
136
136
|
* per-role color utilities the @theme inline map in tailwind.css exposes.
|
|
137
|
+
*
|
|
138
|
+
* The mode selectors are not anchored to :root — any element carrying
|
|
139
|
+
* data-theme="light" or "dark" opens a mode scope for its subtree, and the
|
|
140
|
+
* nearest enclosing scope wins (ADR-0053). Block order is load-bearing:
|
|
141
|
+
* :root and [data-theme='dark'] have equal specificity, so dark must stay
|
|
142
|
+
* last. See utils/createSemanticTheme.cjs for the full cascade rationale.
|
|
137
143
|
*/
|
|
138
144
|
|
|
139
145
|
/* Mode-invariant roles (identical in light and dark). */
|
|
@@ -145,8 +151,10 @@
|
|
|
145
151
|
--c-scrim: var(--c-black);
|
|
146
152
|
}
|
|
147
153
|
|
|
154
|
+
/* Light is the default; any element may open a light mode scope. */
|
|
148
155
|
:root,
|
|
149
|
-
|
|
156
|
+
[data-theme='light'] {
|
|
157
|
+
color-scheme: light;
|
|
150
158
|
--c-surface: var(--c-white);
|
|
151
159
|
--c-surface-raised: var(--c-white);
|
|
152
160
|
--c-surface-overlay: var(--c-white);
|
|
@@ -241,8 +249,9 @@
|
|
|
241
249
|
--c-logo-magenta: oklch(0.4006 0.1660 351.9773);
|
|
242
250
|
}
|
|
243
251
|
|
|
244
|
-
/* Explicit dark mode (wins over the OS preference). */
|
|
245
|
-
|
|
252
|
+
/* Explicit dark, at the root or in any mode scope (wins over the OS preference). */
|
|
253
|
+
[data-theme='dark'] {
|
|
254
|
+
color-scheme: dark;
|
|
246
255
|
--c-surface: var(--c-slate-800);
|
|
247
256
|
--c-surface-raised: var(--c-slate-800);
|
|
248
257
|
--c-surface-overlay: var(--c-slate-700);
|
|
@@ -337,9 +346,10 @@
|
|
|
337
346
|
--c-logo-magenta: var(--c-white);
|
|
338
347
|
}
|
|
339
348
|
|
|
340
|
-
/* OS dark preference, only when
|
|
349
|
+
/* OS dark preference, only when the root pins no mode. */
|
|
341
350
|
@media (prefers-color-scheme: dark) {
|
|
342
|
-
:root:not([data-theme]) {
|
|
351
|
+
:root:not([data-theme='light']):not([data-theme='dark']) {
|
|
352
|
+
color-scheme: dark;
|
|
343
353
|
--c-surface: var(--c-slate-800);
|
|
344
354
|
--c-surface-raised: var(--c-slate-800);
|
|
345
355
|
--c-surface-overlay: var(--c-slate-700);
|
package/dist/web-types.json
CHANGED
package/dist-types/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export type { AppDefaults, DefaultableTag } from './shared/appDefaults';
|
|
|
29
29
|
export { chartAnatomy, chartAnatomyHex, chartSlots, chartSlotsHex, } from './theme/chart-data';
|
|
30
30
|
export type { ChartAnatomy, ChartSlots } from './theme/chart-data';
|
|
31
31
|
export { DEFAULT_SEEDS, FAMILIES } from './theme/ramp.js';
|
|
32
|
-
export { themeMode } from './theme/themeMode';
|
|
32
|
+
export { observeThemeMode, themeMode } from './theme/themeMode';
|
|
33
33
|
export type { ThemeMode } from './theme/themeMode';
|
|
34
34
|
export type { CFieldSize, CPlacement, CSelectItem, CToastMessage, CToastType, } from './types';
|
|
35
35
|
export { h } from 'vue';
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
* The chart tokens (ADR-0030) as importable data (ADR-0040): the twelve
|
|
8
8
|
* series slots and the chart anatomy roles per theme mode. Values are the
|
|
9
9
|
* frozen, validated set — they never follow a consumer's `--c-chart-*`
|
|
10
|
-
* overrides. Pair with `themeMode()` to pick the mode
|
|
10
|
+
* overrides. Pair with `themeMode(el)` to pick the mode in effect where the
|
|
11
|
+
* chart sits, or `observeThemeMode()` to follow it.
|
|
11
12
|
*/
|
|
12
13
|
import type { ThemeMode } from './themeMode';
|
|
13
14
|
/** The twelve series slots in slot order (`chart-1` … `chart-12`). */
|
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
/** The light-or-dark state that selects which palette the semantic tokens resolve to. */
|
|
2
2
|
export type ThemeMode = 'dark' | 'light';
|
|
3
3
|
/**
|
|
4
|
-
* Resolve the theme mode
|
|
5
|
-
* `tokens.css`:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
4
|
+
* Resolve the theme mode in effect for an element, mirroring the cascade in
|
|
5
|
+
* `tokens.css`: the nearest enclosing **mode scope** wins (an ancestor-or-self
|
|
6
|
+
* carrying `data-theme="light"` or `"dark"`, ADR-0053); otherwise the OS
|
|
7
|
+
* preference; light where neither is available (server rendering, no
|
|
8
|
+
* `matchMedia`). Any other `data-theme` value is inert, exactly as it is in CSS.
|
|
9
|
+
*
|
|
10
|
+
* Pass the element whose mode you need — a chart inside a dark panel on an
|
|
11
|
+
* otherwise light page resolves `dark` only if you ask about the chart.
|
|
12
|
+
* `observeThemeMode()` keeps that answer current.
|
|
13
|
+
*
|
|
14
|
+
* @param root the element to resolve for — defaults to `<html>`
|
|
12
15
|
*/
|
|
13
16
|
export declare function themeMode(root?: Element | null): ThemeMode;
|
|
17
|
+
/**
|
|
18
|
+
* Watch the theme mode in effect for an element and report every change.
|
|
19
|
+
*
|
|
20
|
+
* Calls `onChange` once synchronously with the current mode, then again
|
|
21
|
+
* whenever it actually changes — so wiring a chart up is the one call, with no
|
|
22
|
+
* separate initial render. Covers both paths that can change the answer: a
|
|
23
|
+
* `data-theme` attribute mutating anywhere in the document (the element's own
|
|
24
|
+
* **mode scope** or any ancestor's, which is why a `documentElement`-only
|
|
25
|
+
* observer is not enough), and the OS preference flipping while no scope pins
|
|
26
|
+
* a mode. Re-parenting `target` is not observed; re-subscribe if you move it.
|
|
27
|
+
*
|
|
28
|
+
* ```ts
|
|
29
|
+
* const stop = observeThemeMode(chartEl, (mode) => {
|
|
30
|
+
* chart.setOption({ color: chartSlotsHex[mode] });
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @returns a disposer that detaches both listeners
|
|
35
|
+
*/
|
|
36
|
+
export declare function observeThemeMode(target: Element, onChange: (mode: ThemeMode) => void): () => void;
|
package/package.json
CHANGED