@vokril/ui-solid 0.25.0 → 0.27.0
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/CHANGELOG.md +20 -0
- package/README.md +17 -6
- package/dist/_internal/platform/settings/settingsTypes.d.cts +7 -0
- package/dist/_internal/platform/settings/settingsTypes.d.ts +7 -0
- package/dist/appThemeDerivation-Be_oKljl.cjs +1 -0
- package/dist/{appThemeDerivation-B7-DjMIM.js → appThemeDerivation-CKoSe4KP.js} +334 -252
- package/dist/fonts/manrope.css +10 -0
- package/dist/fonts.css +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +476 -472
- package/dist/server/appThemeDerivation-Be_oKljl.cjs +1 -0
- package/dist/server/{appThemeDerivation-B7-DjMIM.js → appThemeDerivation-CKoSe4KP.js} +334 -252
- package/dist/server/index.cjs +1 -1
- package/dist/server/index.js +468 -464
- package/dist/server/tokens/index.cjs +1 -1
- package/dist/server/tokens/index.js +33 -29
- package/dist/solid/tokens/index.js +1 -1
- package/dist/solid/tokens/palette/palettes.js +62 -4
- package/dist/solid/tokens/palette/themeRegistry.js +30 -7
- package/dist/solid/tokens/theme.jsx +12 -5
- package/dist/style.css +583 -11
- package/dist/theme.css +582 -10
- package/dist/tokens/index.cjs +1 -1
- package/dist/tokens/index.d.cts +2 -2
- package/dist/tokens/index.d.ts +2 -2
- package/dist/tokens/index.js +33 -29
- package/dist/tokens/palette/palettes.d.cts +13 -13
- package/dist/tokens/palette/palettes.d.ts +13 -13
- package/dist/tokens/palette/themeRegistry.d.cts +27 -6
- package/dist/tokens/palette/themeRegistry.d.ts +27 -6
- package/dist/tokens/theme.d.cts +11 -8
- package/dist/tokens/theme.d.ts +11 -8
- package/dist/tokens/tokens.css +582 -10
- package/dist/ui.css +1 -1
- package/package.json +3 -2
- package/dist/appThemeDerivation-NS3Vws8q.cjs +0 -1
- package/dist/server/appThemeDerivation-NS3Vws8q.cjs +0 -1
package/dist/tokens/index.js
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import { D as
|
|
1
|
+
import { D as a, a as t, I as T, L as r, M as i, O as o, T as l, b as m, U as E, W as n, c as p, d as h, e as A, f as _, g as c, h as I, i as d, j as g, k as D, l as S, m as F, n as O, o as P, p as v, q as L, r as u, s as C, t as f, u as M, v as b, w as B, x as K, y as N, z as U, A as x, B as y } from "../appThemeDerivation-CKoSe4KP.js";
|
|
2
2
|
export {
|
|
3
|
-
|
|
4
|
-
t as
|
|
3
|
+
a as DEFAULT_THEME_ID,
|
|
4
|
+
t as DESIGN_THEMES,
|
|
5
|
+
T as INK_ROLE_KEYS,
|
|
5
6
|
r as LEGACY_THEME_IDS,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
i as MAX_TEXT_TINT_ALPHA,
|
|
8
|
+
o as OKABE_ITO_DIFF,
|
|
9
|
+
l as TEXT_ROLE_KEYS,
|
|
10
|
+
m as ThemeProvider,
|
|
11
|
+
E as UNIQUE_ACCENT,
|
|
12
|
+
n as WELD_BG,
|
|
13
|
+
p as WELD_SURFACE,
|
|
14
|
+
h as accessibleFillSurface,
|
|
15
|
+
A as accessibleInputBorder,
|
|
16
|
+
_ as accessibleOnFillInk,
|
|
17
|
+
c as accessibleTextColor,
|
|
18
|
+
I as applyAppTheme,
|
|
19
|
+
d as derivePaletteProperties,
|
|
20
|
+
g as generateMonacoThemeFromPalette,
|
|
21
|
+
D as generateTerminalPaletteFromPalette,
|
|
22
|
+
S as getDefaultThemeId,
|
|
23
|
+
F as getThemeById,
|
|
24
|
+
O as getThemeDesign,
|
|
22
25
|
P as getThemeOptions,
|
|
23
26
|
v as getThemes,
|
|
24
27
|
L as isColorVisionSafeActive,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
u as isKnownThemeId,
|
|
29
|
+
C as readActiveAppPalette,
|
|
30
|
+
f as readActiveAppThemeId,
|
|
31
|
+
M as readActiveAppThemeType,
|
|
32
|
+
b as registerThemeSource,
|
|
33
|
+
B as resolveThemeOption,
|
|
34
|
+
K as setThemeDesign,
|
|
35
|
+
N as textGroundsFor,
|
|
36
|
+
U as themeOptions,
|
|
37
|
+
x as toColorVisionSafePalette,
|
|
38
|
+
y as useTheme
|
|
35
39
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { ThemeOption } from '../../_internal/platform/settings/settingsTypes.cjs';
|
|
2
2
|
/**
|
|
3
|
-
* Built-in colour themes:
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* Built-in colour themes: a dark and a light theme for each design (decision 0021) —
|
|
4
|
+
* **Viper Dark** (the default) and **Viper Light**, **Vokril Dark** and **Vokril Light** —
|
|
5
|
+
* plus the two high-contrast themes, which belong to no design. Their values are the Vokril
|
|
6
|
+
* colour system in `scripts/palette/vokril.mjs` — do not hand-edit them, change the
|
|
7
|
+
* parameters and run `node scripts/palette/vokril.mjs --write`. The legacy ids `darcula` and
|
|
8
|
+
* `light` resolve to Viper Dark and Viper Light (`themeRegistry`).
|
|
8
9
|
*
|
|
9
|
-
* ⚠
|
|
10
|
-
* dark-only built-in set the light code path — the `body.light` seam, the OKLCH
|
|
11
|
-
* derivation in `accessiblePalette.ts`, every `-text`/`-surface`/`-on-*` role —
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* as a plugin.
|
|
10
|
+
* ⚠ Each design keeps its light theme as a TEST BASELINE, not to re-grow the catalogue.
|
|
11
|
+
* With a dark-only built-in set the light code path — the `body.light` seam, the OKLCH
|
|
12
|
+
* derivation in `accessiblePalette.ts`, every `-text`/`-surface`/`-on-*` role — shipped but
|
|
13
|
+
* was unreachable without installing a plugin, so light-theme regressions (hardcoded
|
|
14
|
+
* dark-only badge colours, white-on-white headings) went unseen by everyone including CI.
|
|
15
|
+
* Keep one dark and one light theme per design; publish anything else as a plugin.
|
|
16
16
|
*
|
|
17
|
-
* ⚠
|
|
17
|
+
* ⚠ Viper Dark must stay FIRST — `appThemeDerivation.ts` and `themeRegistry.ts` fall
|
|
18
18
|
* back to index 0.
|
|
19
19
|
*
|
|
20
20
|
* ⚠ Three consumers parse this file as TEXT rather than importing it (the
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { ThemeOption } from '../../_internal/platform/settings/settingsTypes.js';
|
|
2
2
|
/**
|
|
3
|
-
* Built-in colour themes:
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* Built-in colour themes: a dark and a light theme for each design (decision 0021) —
|
|
4
|
+
* **Viper Dark** (the default) and **Viper Light**, **Vokril Dark** and **Vokril Light** —
|
|
5
|
+
* plus the two high-contrast themes, which belong to no design. Their values are the Vokril
|
|
6
|
+
* colour system in `scripts/palette/vokril.mjs` — do not hand-edit them, change the
|
|
7
|
+
* parameters and run `node scripts/palette/vokril.mjs --write`. The legacy ids `darcula` and
|
|
8
|
+
* `light` resolve to Viper Dark and Viper Light (`themeRegistry`).
|
|
8
9
|
*
|
|
9
|
-
* ⚠
|
|
10
|
-
* dark-only built-in set the light code path — the `body.light` seam, the OKLCH
|
|
11
|
-
* derivation in `accessiblePalette.ts`, every `-text`/`-surface`/`-on-*` role —
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* as a plugin.
|
|
10
|
+
* ⚠ Each design keeps its light theme as a TEST BASELINE, not to re-grow the catalogue.
|
|
11
|
+
* With a dark-only built-in set the light code path — the `body.light` seam, the OKLCH
|
|
12
|
+
* derivation in `accessiblePalette.ts`, every `-text`/`-surface`/`-on-*` role — shipped but
|
|
13
|
+
* was unreachable without installing a plugin, so light-theme regressions (hardcoded
|
|
14
|
+
* dark-only badge colours, white-on-white headings) went unseen by everyone including CI.
|
|
15
|
+
* Keep one dark and one light theme per design; publish anything else as a plugin.
|
|
16
16
|
*
|
|
17
|
-
* ⚠
|
|
17
|
+
* ⚠ Viper Dark must stay FIRST — `appThemeDerivation.ts` and `themeRegistry.ts` fall
|
|
18
18
|
* back to index 0.
|
|
19
19
|
*
|
|
20
20
|
* ⚠ Three consumers parse this file as TEXT rather than importing it (the
|
|
@@ -7,17 +7,35 @@
|
|
|
7
7
|
* a settings group validates a stored theme id against it, and settings groups are realm-wide
|
|
8
8
|
* declarations. Lookups answer the built-ins first, then each source in registration order.
|
|
9
9
|
*
|
|
10
|
+
* The realm also has one design (decision 0021): `viper` (the default) or `vokril`. A product picks it
|
|
11
|
+
* once at start-up with `setThemeDesign`; the theme lists then offer that design's themes (and the
|
|
12
|
+
* high-contrast ones, which belong to no design), and a built-in theme of the other design resolves to
|
|
13
|
+
* this design's theme of the same type — a stored `vokril-dark` reads as `viper-dark` in a Viper product
|
|
14
|
+
* and the other way round, so no stored setting needs migrating.
|
|
15
|
+
*
|
|
10
16
|
* Logger-free and storage-free on purpose: subsystems that resolve a theme by id (the `auto` editor and
|
|
11
17
|
* terminal themes, the grid pin) import it without the theme runtime.
|
|
12
18
|
*/
|
|
13
|
-
import type { ThemeOption } from '../../_internal/platform/settings/settingsTypes.cjs';
|
|
19
|
+
import type { ThemeDesign, ThemeMode, ThemeOption } from '../../_internal/platform/settings/settingsTypes.cjs';
|
|
14
20
|
import type { IDisposable } from '../../_internal/base/lifecycle.cjs';
|
|
15
|
-
|
|
21
|
+
/** The designs and the ids of each design's dark and light theme. */
|
|
22
|
+
export declare const DESIGN_THEMES: Readonly<Record<ThemeDesign, Readonly<Record<ThemeMode, string>>>>;
|
|
23
|
+
/** The default design's dark theme. The active design's default: `getDefaultThemeId()`. */
|
|
24
|
+
export declare const DEFAULT_THEME_ID = "viper-dark";
|
|
16
25
|
/**
|
|
17
26
|
* Ids that earlier releases (and the host app, whose default is `darcula`) stored or
|
|
18
|
-
* stamped; they resolve to the
|
|
27
|
+
* stamped; they resolve to the palette that replaced them (decisions 0015, 0021).
|
|
19
28
|
*/
|
|
20
29
|
export declare const LEGACY_THEME_IDS: Readonly<Record<string, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the realm's design. Call it once, before the first theme is applied; a product does not mix
|
|
32
|
+
* designs.
|
|
33
|
+
*/
|
|
34
|
+
export declare function setThemeDesign(design: ThemeDesign): void;
|
|
35
|
+
/** The realm's design (`viper` unless `setThemeDesign` chose another). */
|
|
36
|
+
export declare function getThemeDesign(): ThemeDesign;
|
|
37
|
+
/** The id of the active design's dark (or light) theme. */
|
|
38
|
+
export declare function getDefaultThemeId(type?: ThemeMode): string;
|
|
21
39
|
/** A source of themes the host contributes (its user-imported themes, its plugins' themes). */
|
|
22
40
|
export interface ThemeSource {
|
|
23
41
|
byId(id: string): ThemeOption | null;
|
|
@@ -25,9 +43,12 @@ export interface ThemeSource {
|
|
|
25
43
|
}
|
|
26
44
|
/** Contributes a source of themes; its themes are listed and resolved until the registration is disposed. */
|
|
27
45
|
export declare function registerThemeSource(source: ThemeSource): IDisposable;
|
|
28
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Resolve a theme by id (built-in → contributed), else the active design's default. A built-in theme
|
|
48
|
+
* of another design resolves to the active design's theme of the same type.
|
|
49
|
+
*/
|
|
29
50
|
export declare function getThemeById(rawId: string): ThemeOption;
|
|
30
|
-
/** All selectable themes: built-ins, then each source's in registration order. */
|
|
51
|
+
/** All selectable themes: the active design's built-ins, then each source's in registration order. */
|
|
31
52
|
export declare function getThemeOptions(): ThemeOption[];
|
|
32
|
-
/** True if the id names a real built-in or contributed theme (vs an unknown id). */
|
|
53
|
+
/** True if the id names a real built-in (of any design) or contributed theme (vs an unknown id). */
|
|
33
54
|
export declare function isKnownThemeId(rawId: string): boolean;
|
|
@@ -7,17 +7,35 @@
|
|
|
7
7
|
* a settings group validates a stored theme id against it, and settings groups are realm-wide
|
|
8
8
|
* declarations. Lookups answer the built-ins first, then each source in registration order.
|
|
9
9
|
*
|
|
10
|
+
* The realm also has one design (decision 0021): `viper` (the default) or `vokril`. A product picks it
|
|
11
|
+
* once at start-up with `setThemeDesign`; the theme lists then offer that design's themes (and the
|
|
12
|
+
* high-contrast ones, which belong to no design), and a built-in theme of the other design resolves to
|
|
13
|
+
* this design's theme of the same type — a stored `vokril-dark` reads as `viper-dark` in a Viper product
|
|
14
|
+
* and the other way round, so no stored setting needs migrating.
|
|
15
|
+
*
|
|
10
16
|
* Logger-free and storage-free on purpose: subsystems that resolve a theme by id (the `auto` editor and
|
|
11
17
|
* terminal themes, the grid pin) import it without the theme runtime.
|
|
12
18
|
*/
|
|
13
|
-
import type { ThemeOption } from '../../_internal/platform/settings/settingsTypes.js';
|
|
19
|
+
import type { ThemeDesign, ThemeMode, ThemeOption } from '../../_internal/platform/settings/settingsTypes.js';
|
|
14
20
|
import type { IDisposable } from '../../_internal/base/lifecycle.js';
|
|
15
|
-
|
|
21
|
+
/** The designs and the ids of each design's dark and light theme. */
|
|
22
|
+
export declare const DESIGN_THEMES: Readonly<Record<ThemeDesign, Readonly<Record<ThemeMode, string>>>>;
|
|
23
|
+
/** The default design's dark theme. The active design's default: `getDefaultThemeId()`. */
|
|
24
|
+
export declare const DEFAULT_THEME_ID = "viper-dark";
|
|
16
25
|
/**
|
|
17
26
|
* Ids that earlier releases (and the host app, whose default is `darcula`) stored or
|
|
18
|
-
* stamped; they resolve to the
|
|
27
|
+
* stamped; they resolve to the palette that replaced them (decisions 0015, 0021).
|
|
19
28
|
*/
|
|
20
29
|
export declare const LEGACY_THEME_IDS: Readonly<Record<string, string>>;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the realm's design. Call it once, before the first theme is applied; a product does not mix
|
|
32
|
+
* designs.
|
|
33
|
+
*/
|
|
34
|
+
export declare function setThemeDesign(design: ThemeDesign): void;
|
|
35
|
+
/** The realm's design (`viper` unless `setThemeDesign` chose another). */
|
|
36
|
+
export declare function getThemeDesign(): ThemeDesign;
|
|
37
|
+
/** The id of the active design's dark (or light) theme. */
|
|
38
|
+
export declare function getDefaultThemeId(type?: ThemeMode): string;
|
|
21
39
|
/** A source of themes the host contributes (its user-imported themes, its plugins' themes). */
|
|
22
40
|
export interface ThemeSource {
|
|
23
41
|
byId(id: string): ThemeOption | null;
|
|
@@ -25,9 +43,12 @@ export interface ThemeSource {
|
|
|
25
43
|
}
|
|
26
44
|
/** Contributes a source of themes; its themes are listed and resolved until the registration is disposed. */
|
|
27
45
|
export declare function registerThemeSource(source: ThemeSource): IDisposable;
|
|
28
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* Resolve a theme by id (built-in → contributed), else the active design's default. A built-in theme
|
|
48
|
+
* of another design resolves to the active design's theme of the same type.
|
|
49
|
+
*/
|
|
29
50
|
export declare function getThemeById(rawId: string): ThemeOption;
|
|
30
|
-
/** All selectable themes: built-ins, then each source's in registration order. */
|
|
51
|
+
/** All selectable themes: the active design's built-ins, then each source's in registration order. */
|
|
31
52
|
export declare function getThemeOptions(): ThemeOption[];
|
|
32
|
-
/** True if the id names a real built-in or contributed theme (vs an unknown id). */
|
|
53
|
+
/** True if the id names a real built-in (of any design) or contributed theme (vs an unknown id). */
|
|
33
54
|
export declare function isKnownThemeId(rawId: string): boolean;
|
package/dist/tokens/theme.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ThemeProvider / applyAppTheme — the app theme application for @vokril/ui.
|
|
3
3
|
*
|
|
4
|
-
* A theme is one of the built-in
|
|
5
|
-
* `light`, `
|
|
6
|
-
*
|
|
4
|
+
* A theme is one of the built-in palettes — each design's dark and light theme (`viper-dark`
|
|
5
|
+
* — the default —, `viper-light`, `vokril-dark`, `vokril-light`) and the design-less
|
|
6
|
+
* `high-contrast-dark`, `high-contrast-light`; see `./palette/palettes` and decision 0021.
|
|
7
7
|
* Applying it does exactly what the host app's `applyPalette` does:
|
|
8
8
|
*
|
|
9
9
|
* 1. optional colour-vision-safe transform of the palette (Okabe–Ito) BEFORE derivation,
|
|
@@ -11,18 +11,21 @@
|
|
|
11
11
|
* <html> (accessible text/surface/on-* variants, derived input border, syntax, diff),
|
|
12
12
|
* 3. `light` | `dark` class on <html> AND <body> (tokens.css keys its shell weld and
|
|
13
13
|
* light accents on them), `color-scheme` on <html>, `data-app-theme` on <html>,
|
|
14
|
-
* 4. `data-
|
|
14
|
+
* 4. `data-design` on <html> for a theme of a design (tokens.css keys the design's type and
|
|
15
|
+
* shape on it),
|
|
16
|
+
* 5. `data-colorblind-safe` on <html> while the colour-vision-safe mode is on.
|
|
15
17
|
*
|
|
16
18
|
* The host app also caches splash colours in localStorage; that app-specific step is omitted.
|
|
17
19
|
* The same values are available without JS from the generated `palette.css`.
|
|
18
20
|
*
|
|
19
21
|
* The provider keeps the earlier @vokril/ui API (`theme`, `resolvedTheme`, `setTheme`,
|
|
20
|
-
* `toggleTheme`, `'dark' | 'light' | 'system'`): `'dark'`
|
|
22
|
+
* `toggleTheme`, `'dark' | 'light' | 'system'`): `'dark'` and `'light'` mean the active design's
|
|
23
|
+
* dark and light theme (`setThemeDesign`), `'system'` picks between them by
|
|
21
24
|
* `prefers-color-scheme`, and any palette id is accepted as well.
|
|
22
25
|
*/
|
|
23
26
|
import { type ParentComponent } from 'solid-js';
|
|
24
27
|
import type { ThemeOption } from '../_internal/platform/settings/settingsTypes.cjs';
|
|
25
|
-
/** `'dark'` (
|
|
28
|
+
/** `'dark'`, `'light'` (the active design's), `'system'`, or any built-in palette id. */
|
|
26
29
|
export type Theme = 'dark' | 'light' | 'system' | (string & {});
|
|
27
30
|
export type ResolvedTheme = 'dark' | 'light';
|
|
28
31
|
export interface ThemeContextValue {
|
|
@@ -30,7 +33,7 @@ export interface ThemeContextValue {
|
|
|
30
33
|
theme: () => Theme;
|
|
31
34
|
/** Light/dark type of the applied palette. */
|
|
32
35
|
resolvedTheme: () => ResolvedTheme;
|
|
33
|
-
/** Id of the applied palette (`
|
|
36
|
+
/** Id of the applied palette (`viper-dark`, `vokril-light`, …). */
|
|
34
37
|
themeId: () => string;
|
|
35
38
|
setTheme: (theme: Theme) => void;
|
|
36
39
|
toggleTheme: () => void;
|
|
@@ -55,7 +58,7 @@ export declare function getThemes(): ThemeOption[];
|
|
|
55
58
|
/** Where ThemeProvider keeps the chosen theme: `localStorage`, `sessionStorage` or your own. */
|
|
56
59
|
export type ThemeStorage = Pick<Storage, 'getItem' | 'setItem'>;
|
|
57
60
|
export interface ThemeProviderProps {
|
|
58
|
-
/** Initial theme when nothing is stored (default `'dark'
|
|
61
|
+
/** Initial theme when nothing is stored (default `'dark'`: the active design's dark theme). */
|
|
59
62
|
defaultTheme?: Theme;
|
|
60
63
|
/** Storage key for the chosen theme (default `'vokril-ui-theme'`); `null` disables persistence. */
|
|
61
64
|
storageKey?: string | null;
|
package/dist/tokens/theme.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* ThemeProvider / applyAppTheme — the app theme application for @vokril/ui.
|
|
3
3
|
*
|
|
4
|
-
* A theme is one of the built-in
|
|
5
|
-
* `light`, `
|
|
6
|
-
*
|
|
4
|
+
* A theme is one of the built-in palettes — each design's dark and light theme (`viper-dark`
|
|
5
|
+
* — the default —, `viper-light`, `vokril-dark`, `vokril-light`) and the design-less
|
|
6
|
+
* `high-contrast-dark`, `high-contrast-light`; see `./palette/palettes` and decision 0021.
|
|
7
7
|
* Applying it does exactly what the host app's `applyPalette` does:
|
|
8
8
|
*
|
|
9
9
|
* 1. optional colour-vision-safe transform of the palette (Okabe–Ito) BEFORE derivation,
|
|
@@ -11,18 +11,21 @@
|
|
|
11
11
|
* <html> (accessible text/surface/on-* variants, derived input border, syntax, diff),
|
|
12
12
|
* 3. `light` | `dark` class on <html> AND <body> (tokens.css keys its shell weld and
|
|
13
13
|
* light accents on them), `color-scheme` on <html>, `data-app-theme` on <html>,
|
|
14
|
-
* 4. `data-
|
|
14
|
+
* 4. `data-design` on <html> for a theme of a design (tokens.css keys the design's type and
|
|
15
|
+
* shape on it),
|
|
16
|
+
* 5. `data-colorblind-safe` on <html> while the colour-vision-safe mode is on.
|
|
15
17
|
*
|
|
16
18
|
* The host app also caches splash colours in localStorage; that app-specific step is omitted.
|
|
17
19
|
* The same values are available without JS from the generated `palette.css`.
|
|
18
20
|
*
|
|
19
21
|
* The provider keeps the earlier @vokril/ui API (`theme`, `resolvedTheme`, `setTheme`,
|
|
20
|
-
* `toggleTheme`, `'dark' | 'light' | 'system'`): `'dark'`
|
|
22
|
+
* `toggleTheme`, `'dark' | 'light' | 'system'`): `'dark'` and `'light'` mean the active design's
|
|
23
|
+
* dark and light theme (`setThemeDesign`), `'system'` picks between them by
|
|
21
24
|
* `prefers-color-scheme`, and any palette id is accepted as well.
|
|
22
25
|
*/
|
|
23
26
|
import { type ParentComponent } from 'solid-js';
|
|
24
27
|
import type { ThemeOption } from '../_internal/platform/settings/settingsTypes.js';
|
|
25
|
-
/** `'dark'` (
|
|
28
|
+
/** `'dark'`, `'light'` (the active design's), `'system'`, or any built-in palette id. */
|
|
26
29
|
export type Theme = 'dark' | 'light' | 'system' | (string & {});
|
|
27
30
|
export type ResolvedTheme = 'dark' | 'light';
|
|
28
31
|
export interface ThemeContextValue {
|
|
@@ -30,7 +33,7 @@ export interface ThemeContextValue {
|
|
|
30
33
|
theme: () => Theme;
|
|
31
34
|
/** Light/dark type of the applied palette. */
|
|
32
35
|
resolvedTheme: () => ResolvedTheme;
|
|
33
|
-
/** Id of the applied palette (`
|
|
36
|
+
/** Id of the applied palette (`viper-dark`, `vokril-light`, …). */
|
|
34
37
|
themeId: () => string;
|
|
35
38
|
setTheme: (theme: Theme) => void;
|
|
36
39
|
toggleTheme: () => void;
|
|
@@ -55,7 +58,7 @@ export declare function getThemes(): ThemeOption[];
|
|
|
55
58
|
/** Where ThemeProvider keeps the chosen theme: `localStorage`, `sessionStorage` or your own. */
|
|
56
59
|
export type ThemeStorage = Pick<Storage, 'getItem' | 'setItem'>;
|
|
57
60
|
export interface ThemeProviderProps {
|
|
58
|
-
/** Initial theme when nothing is stored (default `'dark'
|
|
61
|
+
/** Initial theme when nothing is stored (default `'dark'`: the active design's dark theme). */
|
|
59
62
|
defaultTheme?: Theme;
|
|
60
63
|
/** Storage key for the chosen theme (default `'vokril-ui-theme'`); `null` disables persistence. */
|
|
61
64
|
storageKey?: string | null;
|