@skdx/tokens 0.27.0 → 0.29.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/LICENSE +21 -0
- package/README.md +92 -69
- package/dist/foundation.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/themes/AntDark.cjs +1 -1
- package/dist/themes/AntDark.d.cts +3 -12
- package/dist/themes/AntDark.d.ts +3 -12
- package/dist/themes/AntDark.js +1 -1
- package/dist/themes/{AntBrand.cjs → AntLight.cjs} +1 -1
- package/dist/themes/{AntBrand.d.cts → AntLight.d.cts} +1 -1
- package/dist/themes/{AntBrand.d.ts → AntLight.d.ts} +1 -1
- package/dist/themes/{AntBrand.js → AntLight.js} +1 -1
- package/dist/themes/CatppuccinLatte.cjs +1 -1
- package/dist/themes/CatppuccinLatte.d.cts +1 -7
- package/dist/themes/CatppuccinLatte.d.ts +1 -7
- package/dist/themes/CatppuccinLatte.js +1 -1
- package/dist/themes/CatppuccinMocha.cjs +1 -1
- package/dist/themes/CatppuccinMocha.d.cts +1 -7
- package/dist/themes/CatppuccinMocha.d.ts +1 -7
- package/dist/themes/CatppuccinMocha.js +1 -1
- package/dist/themes/ChakraDark.cjs +1 -1
- package/dist/themes/ChakraDark.d.cts +3 -12
- package/dist/themes/ChakraDark.d.ts +3 -12
- package/dist/themes/ChakraDark.js +1 -1
- package/dist/themes/{ChakraBrand.cjs → ChakraLight.cjs} +1 -1
- package/dist/themes/{ChakraBrand.d.cts → ChakraLight.d.cts} +1 -1
- package/dist/themes/{ChakraBrand.d.ts → ChakraLight.d.ts} +1 -1
- package/dist/themes/{ChakraBrand.js → ChakraLight.js} +1 -1
- package/dist/themes/CupcakeDark.cjs +1 -1
- package/dist/themes/CupcakeDark.d.cts +3 -5
- package/dist/themes/CupcakeDark.d.ts +3 -5
- package/dist/themes/CupcakeLight.cjs +1 -1
- package/dist/themes/CupcakeLight.d.cts +1 -8
- package/dist/themes/CupcakeLight.d.ts +1 -8
- package/dist/themes/CupcakeLight.js +1 -1
- package/dist/themes/DefaultTheme.cjs +1 -1
- package/dist/themes/DefaultTheme.d.cts +3 -15
- package/dist/themes/DefaultTheme.d.ts +3 -15
- package/dist/themes/DefaultTheme.js +1 -1
- package/dist/themes/DraculaLight.cjs +1 -1
- package/dist/themes/DraculaLight.d.cts +3 -10
- package/dist/themes/DraculaLight.d.ts +3 -10
- package/dist/themes/DraculaLight.js +1 -1
- package/dist/themes/EmeraldDark.cjs +1 -1
- package/dist/themes/EmeraldDark.d.cts +3 -8
- package/dist/themes/EmeraldDark.d.ts +3 -8
- package/dist/themes/EmeraldDark.js +1 -1
- package/dist/themes/{EmeraldBrand.cjs → EmeraldLight.cjs} +1 -1
- package/dist/themes/{EmeraldBrand.d.cts → EmeraldLight.d.cts} +1 -1
- package/dist/themes/{EmeraldBrand.d.ts → EmeraldLight.d.ts} +1 -1
- package/dist/themes/{EmeraldBrand.js → EmeraldLight.js} +1 -1
- package/dist/themes/EverforestDark.cjs +1 -1
- package/dist/themes/EverforestDark.d.cts +1 -2
- package/dist/themes/EverforestDark.d.ts +1 -2
- package/dist/themes/EverforestDark.js +1 -1
- package/dist/themes/EverforestLight.cjs +1 -1
- package/dist/themes/EverforestLight.d.cts +3 -9
- package/dist/themes/EverforestLight.d.ts +3 -9
- package/dist/themes/FluentDark.cjs +1 -1
- package/dist/themes/FluentDark.d.cts +3 -11
- package/dist/themes/FluentDark.d.ts +3 -11
- package/dist/themes/FluentDark.js +1 -1
- package/dist/themes/{FluentBrand.cjs → FluentLight.cjs} +1 -1
- package/dist/themes/{FluentBrand.d.cts → FluentLight.d.cts} +1 -1
- package/dist/themes/{FluentBrand.d.ts → FluentLight.d.ts} +1 -1
- package/dist/themes/{FluentBrand.js → FluentLight.js} +1 -1
- package/dist/themes/GraphiteDark.cjs +1 -1
- package/dist/themes/GraphiteDark.d.cts +3 -8
- package/dist/themes/GraphiteDark.d.ts +3 -8
- package/dist/themes/GraphiteDark.js +1 -1
- package/dist/themes/{GraphiteBrand.cjs → GraphiteLight.cjs} +1 -1
- package/dist/themes/{GraphiteBrand.d.cts → GraphiteLight.d.cts} +1 -1
- package/dist/themes/{GraphiteBrand.d.ts → GraphiteLight.d.ts} +1 -1
- package/dist/themes/{GraphiteBrand.js → GraphiteLight.js} +1 -1
- package/dist/themes/GruvboxDark.cjs +1 -1
- package/dist/themes/GruvboxDark.d.cts +1 -7
- package/dist/themes/GruvboxDark.d.ts +1 -7
- package/dist/themes/GruvboxDark.js +1 -1
- package/dist/themes/GruvboxLight.cjs +1 -1
- package/dist/themes/GruvboxLight.d.cts +3 -13
- package/dist/themes/GruvboxLight.d.ts +3 -13
- package/dist/themes/GruvboxLight.js +1 -1
- package/dist/themes/MaterialDark.cjs +1 -1
- package/dist/themes/MaterialDark.d.cts +3 -12
- package/dist/themes/MaterialDark.d.ts +3 -12
- package/dist/themes/MaterialDark.js +1 -1
- package/dist/themes/{MaterialBrand.cjs → MaterialLight.cjs} +1 -1
- package/dist/themes/MaterialLight.d.cts +3 -0
- package/dist/themes/MaterialLight.d.ts +3 -0
- package/dist/themes/{MaterialBrand.js → MaterialLight.js} +1 -1
- package/dist/themes/MidnightDark.cjs +1 -0
- package/dist/themes/MidnightDark.d.cts +3 -0
- package/dist/themes/MidnightDark.d.ts +3 -0
- package/dist/themes/{MidnightBrand.js → MidnightDark.js} +1 -1
- package/dist/themes/MidnightLight.cjs +1 -1
- package/dist/themes/MidnightLight.d.cts +4 -6
- package/dist/themes/MidnightLight.d.ts +4 -6
- package/dist/themes/MidnightLight.js +1 -1
- package/dist/themes/NordDark.cjs +1 -1
- package/dist/themes/NordDark.js +1 -1
- package/dist/themes/NordLight.cjs +1 -1
- package/dist/themes/NordLight.d.cts +3 -13
- package/dist/themes/NordLight.d.ts +3 -13
- package/dist/themes/NordLight.js +1 -1
- package/dist/themes/OneDark.cjs +1 -1
- package/dist/themes/OneDark.d.cts +1 -7
- package/dist/themes/OneDark.d.ts +1 -7
- package/dist/themes/OneDark.js +1 -1
- package/dist/themes/OneLight.cjs +1 -1
- package/dist/themes/OneLight.d.cts +3 -9
- package/dist/themes/OneLight.d.ts +3 -9
- package/dist/themes/OneLight.js +1 -1
- package/dist/themes/PrimerDark.cjs +1 -1
- package/dist/themes/PrimerDark.d.cts +0 -1
- package/dist/themes/PrimerDark.d.ts +0 -1
- package/dist/themes/PrimerDark.js +1 -1
- package/dist/themes/PrimerLight.d.cts +1 -7
- package/dist/themes/PrimerLight.d.ts +1 -7
- package/dist/themes/RosePine.cjs +1 -1
- package/dist/themes/RosePine.d.cts +1 -7
- package/dist/themes/RosePine.d.ts +1 -7
- package/dist/themes/RosePine.js +1 -1
- package/dist/themes/RosePineDawn.cjs +1 -1
- package/dist/themes/RosePineDawn.d.cts +3 -9
- package/dist/themes/RosePineDawn.d.ts +3 -9
- package/dist/themes/RosePineDawn.js +1 -1
- package/dist/themes/SkandaDark.cjs +1 -1
- package/dist/themes/SkandaDark.d.cts +5 -8
- package/dist/themes/SkandaDark.d.ts +5 -8
- package/dist/themes/SkandaDark.js +1 -1
- package/dist/themes/SkandaLight.cjs +1 -1
- package/dist/themes/SkandaLight.js +1 -1
- package/dist/themes/SolarizedDark.d.cts +1 -7
- package/dist/themes/SolarizedDark.d.ts +1 -7
- package/dist/themes/SolarizedLight.cjs +1 -1
- package/dist/themes/SolarizedLight.d.cts +1 -7
- package/dist/themes/SolarizedLight.d.ts +1 -7
- package/dist/themes/SolarizedLight.js +1 -1
- package/dist/themes/SynthwaveDark.d.cts +1 -7
- package/dist/themes/SynthwaveDark.d.ts +1 -7
- package/dist/themes/SynthwaveLight.cjs +1 -1
- package/dist/themes/SynthwaveLight.d.cts +3 -12
- package/dist/themes/SynthwaveLight.d.ts +3 -12
- package/dist/themes/SynthwaveLight.js +1 -1
- package/dist/themes/brands.cjs +1 -1
- package/dist/themes/brands.d.cts +5 -28
- package/dist/themes/brands.d.ts +5 -28
- package/dist/themes/brands.js +1 -1
- package/dist/themes/createBrandTheme.cjs +1 -1
- package/dist/themes/createBrandTheme.d.cts +11 -23
- package/dist/themes/createBrandTheme.d.ts +11 -23
- package/dist/themes/createBrandTheme.js +1 -1
- package/dist/themes/index.cjs +1 -1
- package/dist/themes/index.d.cts +10 -9
- package/dist/themes/index.d.ts +10 -9
- package/dist/themes/index.js +1 -1
- package/dist/themes.css +1 -1
- package/dist/tokens.css +1 -1
- package/dist/tokens.dtcg.json +14246 -0
- package/dist/utils/aliases.cjs +9 -3
- package/dist/utils/aliases.d.cts +19 -99
- package/dist/utils/aliases.d.ts +19 -99
- package/dist/utils/aliases.js +9 -3
- package/dist/utils/contrast.d.cts +2 -17
- package/dist/utils/contrast.d.ts +2 -17
- package/dist/utils/cssVars.cjs +2 -2
- package/dist/utils/cssVars.d.cts +12 -37
- package/dist/utils/cssVars.d.ts +12 -37
- package/dist/utils/cssVars.js +2 -2
- package/dist/utils/foundation.cjs +4 -4
- package/dist/utils/foundation.d.cts +24 -177
- package/dist/utils/foundation.d.ts +24 -177
- package/dist/utils/foundation.js +3 -3
- package/dist/utils/mode.cjs +1 -1
- package/dist/utils/mode.d.cts +18 -57
- package/dist/utils/mode.d.ts +18 -57
- package/dist/utils/mode.js +1 -1
- package/dist/utils/theme.cjs +1 -1
- package/dist/utils/theme.d.cts +68 -292
- package/dist/utils/theme.d.ts +68 -292
- package/dist/utils/toCss.cjs +5 -5
- package/dist/utils/toCss.d.cts +22 -60
- package/dist/utils/toCss.d.ts +22 -60
- package/dist/utils/toCss.js +5 -5
- package/package.json +5 -4
- package/dist/themes/MaterialBrand.d.cts +0 -3
- package/dist/themes/MaterialBrand.d.ts +0 -3
- package/dist/themes/MidnightBrand.cjs +0 -1
- package/dist/themes/MidnightBrand.d.cts +0 -11
- package/dist/themes/MidnightBrand.d.ts +0 -11
package/dist/utils/mode.d.cts
CHANGED
|
@@ -1,89 +1,50 @@
|
|
|
1
|
-
/** `localStorage` key
|
|
1
|
+
/** `localStorage` key for mode preference (`'light' | 'dark' | 'system'`). @public */
|
|
2
2
|
export declare const MODE_STORAGE_KEY = "skdx-mode";
|
|
3
|
-
/** `localStorage` key
|
|
3
|
+
/** `localStorage` key for brand preference (a {@link Brand} name). @public */
|
|
4
4
|
export declare const BRAND_STORAGE_KEY = "skdx-brand";
|
|
5
5
|
/** Options for {@link watchSystemMode}. @public */
|
|
6
6
|
export interface WatchSystemModeOptions {
|
|
7
|
-
/** Brand
|
|
7
|
+
/** Brand pair to apply (unknown names fall back to default). @default 'skanda' */
|
|
8
8
|
brand?: string;
|
|
9
|
-
/**
|
|
9
|
+
/** Target element for theme. @default document.documentElement */
|
|
10
10
|
element?: HTMLElement;
|
|
11
|
-
/**
|
|
11
|
+
/** Mirror resolved mode to `localStorage`. @default false */
|
|
12
12
|
persist?: boolean;
|
|
13
|
-
/** `localStorage` key
|
|
13
|
+
/** `localStorage` key when `persist` is on. @default MODE_STORAGE_KEY */
|
|
14
14
|
storageKey?: string;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Follows
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* returned function on unmount.
|
|
21
|
-
*
|
|
22
|
-
* Browser-only (it reads `window.matchMedia`); guard it behind a mounted
|
|
23
|
-
* effect in an SSR framework, and pair it with {@link getThemeInitScript} so
|
|
24
|
-
* the first paint already matches.
|
|
25
|
-
*
|
|
26
|
-
* @returns An unsubscribe function that detaches the change listener.
|
|
17
|
+
* Follows OS color-scheme, applying and re-applying the theme on change; browser-only, guard behind a mounted effect in SSR.
|
|
18
|
+
* Pair with {@link getThemeInitScript} so first paint matches. A persisted explicit `'light'`/`'dark'` under
|
|
19
|
+
* `storageKey` takes precedence over the OS preference until a `'system'` value is stored again.
|
|
27
20
|
*
|
|
21
|
+
* @returns Unsubscribe function (detaches listener).
|
|
28
22
|
* @example
|
|
29
23
|
* ```ts
|
|
30
24
|
* import { watchSystemMode } from '@skdx/tokens';
|
|
31
|
-
*
|
|
32
25
|
* const stop = watchSystemMode({ brand: 'nord', persist: true });
|
|
33
|
-
* // later…
|
|
34
26
|
* stop();
|
|
35
27
|
* ```
|
|
36
|
-
*
|
|
37
28
|
* @public
|
|
38
29
|
*/
|
|
39
30
|
export declare function watchSystemMode(options?: WatchSystemModeOptions): () => void;
|
|
40
31
|
/** Options for {@link getThemeInitScript}. @public */
|
|
41
32
|
export interface ThemeInitScriptOptions {
|
|
42
|
-
/** `localStorage` key
|
|
33
|
+
/** `localStorage` key for brand name. @default BRAND_STORAGE_KEY */
|
|
43
34
|
brandKey?: string;
|
|
44
|
-
/** `localStorage` key
|
|
35
|
+
/** `localStorage` key for mode. @default MODE_STORAGE_KEY */
|
|
45
36
|
modeKey?: string;
|
|
46
|
-
/** Brand
|
|
47
|
-
|
|
37
|
+
/** Brand to fall back to when nothing is persisted or the persisted name is unknown. @default 'skanda' */
|
|
38
|
+
brand?: string;
|
|
48
39
|
}
|
|
49
40
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* of the light theme. It reads the persisted brand and mode, resolves
|
|
53
|
-
* `'system'` through `prefers-color-scheme`, and maps brand + mode to the
|
|
54
|
-
* theme name your stylesheet is keyed by — the brand→theme-name table is
|
|
55
|
-
* baked into the returned string at call time from {@link brands}.
|
|
56
|
-
*
|
|
57
|
-
* Returns bare JavaScript (no `<script>` wrapper) so each framework can inject
|
|
58
|
-
* it its own way. It only sets attributes, so the page's CSS must already
|
|
59
|
-
* contain a `[data-skdx-theme="…"]` block per theme (see `themeToCss`).
|
|
41
|
+
* Blocking snippet that stamps `data-skdx-theme`/`-mode` on `<html>` before first paint, resolving `'system'` via `prefers-color-scheme`.
|
|
42
|
+
* Returns bare JS (no `<script>` wrapper); your CSS needs `[data-skdx-theme="…"]` blocks.
|
|
60
43
|
*
|
|
61
|
-
* @example Next.js
|
|
44
|
+
* @example Next.js
|
|
62
45
|
* ```tsx
|
|
63
|
-
* <
|
|
64
|
-
* <script dangerouslySetInnerHTML={{ __html: getThemeInitScript() }} />
|
|
65
|
-
* </head>
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @example Nuxt (`nuxt.config.ts`)
|
|
69
|
-
* ```ts
|
|
70
|
-
* app: { head: { script: [{ innerHTML: getThemeInitScript(), tagPosition: 'head' }] } }
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* @example SvelteKit (`src/app.html`) — write the string into the template at
|
|
74
|
-
* build time, e.g. from a Vite plugin replacing a `%skdx.themeInit%` token:
|
|
75
|
-
* ```html
|
|
76
|
-
* <head>
|
|
77
|
-
* %sveltekit.head%
|
|
78
|
-
* <script>%skdx.themeInit%</script>
|
|
79
|
-
* </head>
|
|
46
|
+
* <script dangerouslySetInnerHTML={{ __html: getThemeInitScript() }} />
|
|
80
47
|
* ```
|
|
81
|
-
*
|
|
82
|
-
* @example Astro (`src/layouts/Base.astro`)
|
|
83
|
-
* ```astro
|
|
84
|
-
* <script is:inline set:html={getThemeInitScript()} />
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
48
|
* @public
|
|
88
49
|
*/
|
|
89
50
|
export declare function getThemeInitScript(options?: ThemeInitScriptOptions): string;
|
package/dist/utils/mode.d.ts
CHANGED
|
@@ -1,89 +1,50 @@
|
|
|
1
|
-
/** `localStorage` key
|
|
1
|
+
/** `localStorage` key for mode preference (`'light' | 'dark' | 'system'`). @public */
|
|
2
2
|
export declare const MODE_STORAGE_KEY = "skdx-mode";
|
|
3
|
-
/** `localStorage` key
|
|
3
|
+
/** `localStorage` key for brand preference (a {@link Brand} name). @public */
|
|
4
4
|
export declare const BRAND_STORAGE_KEY = "skdx-brand";
|
|
5
5
|
/** Options for {@link watchSystemMode}. @public */
|
|
6
6
|
export interface WatchSystemModeOptions {
|
|
7
|
-
/** Brand
|
|
7
|
+
/** Brand pair to apply (unknown names fall back to default). @default 'skanda' */
|
|
8
8
|
brand?: string;
|
|
9
|
-
/**
|
|
9
|
+
/** Target element for theme. @default document.documentElement */
|
|
10
10
|
element?: HTMLElement;
|
|
11
|
-
/**
|
|
11
|
+
/** Mirror resolved mode to `localStorage`. @default false */
|
|
12
12
|
persist?: boolean;
|
|
13
|
-
/** `localStorage` key
|
|
13
|
+
/** `localStorage` key when `persist` is on. @default MODE_STORAGE_KEY */
|
|
14
14
|
storageKey?: string;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Follows
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* returned function on unmount.
|
|
21
|
-
*
|
|
22
|
-
* Browser-only (it reads `window.matchMedia`); guard it behind a mounted
|
|
23
|
-
* effect in an SSR framework, and pair it with {@link getThemeInitScript} so
|
|
24
|
-
* the first paint already matches.
|
|
25
|
-
*
|
|
26
|
-
* @returns An unsubscribe function that detaches the change listener.
|
|
17
|
+
* Follows OS color-scheme, applying and re-applying the theme on change; browser-only, guard behind a mounted effect in SSR.
|
|
18
|
+
* Pair with {@link getThemeInitScript} so first paint matches. A persisted explicit `'light'`/`'dark'` under
|
|
19
|
+
* `storageKey` takes precedence over the OS preference until a `'system'` value is stored again.
|
|
27
20
|
*
|
|
21
|
+
* @returns Unsubscribe function (detaches listener).
|
|
28
22
|
* @example
|
|
29
23
|
* ```ts
|
|
30
24
|
* import { watchSystemMode } from '@skdx/tokens';
|
|
31
|
-
*
|
|
32
25
|
* const stop = watchSystemMode({ brand: 'nord', persist: true });
|
|
33
|
-
* // later…
|
|
34
26
|
* stop();
|
|
35
27
|
* ```
|
|
36
|
-
*
|
|
37
28
|
* @public
|
|
38
29
|
*/
|
|
39
30
|
export declare function watchSystemMode(options?: WatchSystemModeOptions): () => void;
|
|
40
31
|
/** Options for {@link getThemeInitScript}. @public */
|
|
41
32
|
export interface ThemeInitScriptOptions {
|
|
42
|
-
/** `localStorage` key
|
|
33
|
+
/** `localStorage` key for brand name. @default BRAND_STORAGE_KEY */
|
|
43
34
|
brandKey?: string;
|
|
44
|
-
/** `localStorage` key
|
|
35
|
+
/** `localStorage` key for mode. @default MODE_STORAGE_KEY */
|
|
45
36
|
modeKey?: string;
|
|
46
|
-
/** Brand
|
|
47
|
-
|
|
37
|
+
/** Brand to fall back to when nothing is persisted or the persisted name is unknown. @default 'skanda' */
|
|
38
|
+
brand?: string;
|
|
48
39
|
}
|
|
49
40
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
* of the light theme. It reads the persisted brand and mode, resolves
|
|
53
|
-
* `'system'` through `prefers-color-scheme`, and maps brand + mode to the
|
|
54
|
-
* theme name your stylesheet is keyed by — the brand→theme-name table is
|
|
55
|
-
* baked into the returned string at call time from {@link brands}.
|
|
56
|
-
*
|
|
57
|
-
* Returns bare JavaScript (no `<script>` wrapper) so each framework can inject
|
|
58
|
-
* it its own way. It only sets attributes, so the page's CSS must already
|
|
59
|
-
* contain a `[data-skdx-theme="…"]` block per theme (see `themeToCss`).
|
|
41
|
+
* Blocking snippet that stamps `data-skdx-theme`/`-mode` on `<html>` before first paint, resolving `'system'` via `prefers-color-scheme`.
|
|
42
|
+
* Returns bare JS (no `<script>` wrapper); your CSS needs `[data-skdx-theme="…"]` blocks.
|
|
60
43
|
*
|
|
61
|
-
* @example Next.js
|
|
44
|
+
* @example Next.js
|
|
62
45
|
* ```tsx
|
|
63
|
-
* <
|
|
64
|
-
* <script dangerouslySetInnerHTML={{ __html: getThemeInitScript() }} />
|
|
65
|
-
* </head>
|
|
66
|
-
* ```
|
|
67
|
-
*
|
|
68
|
-
* @example Nuxt (`nuxt.config.ts`)
|
|
69
|
-
* ```ts
|
|
70
|
-
* app: { head: { script: [{ innerHTML: getThemeInitScript(), tagPosition: 'head' }] } }
|
|
71
|
-
* ```
|
|
72
|
-
*
|
|
73
|
-
* @example SvelteKit (`src/app.html`) — write the string into the template at
|
|
74
|
-
* build time, e.g. from a Vite plugin replacing a `%skdx.themeInit%` token:
|
|
75
|
-
* ```html
|
|
76
|
-
* <head>
|
|
77
|
-
* %sveltekit.head%
|
|
78
|
-
* <script>%skdx.themeInit%</script>
|
|
79
|
-
* </head>
|
|
46
|
+
* <script dangerouslySetInnerHTML={{ __html: getThemeInitScript() }} />
|
|
80
47
|
* ```
|
|
81
|
-
*
|
|
82
|
-
* @example Astro (`src/layouts/Base.astro`)
|
|
83
|
-
* ```astro
|
|
84
|
-
* <script is:inline set:html={getThemeInitScript()} />
|
|
85
|
-
* ```
|
|
86
|
-
*
|
|
87
48
|
* @public
|
|
88
49
|
*/
|
|
89
50
|
export declare function getThemeInitScript(options?: ThemeInitScriptOptions): string;
|
package/dist/utils/mode.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{brands as
|
|
1
|
+
import{brands as y,defaultBrand as p,getBrand as S}from"../themes/brands.js";import{applyTheme as b}from"./toCss.js";var f="skdx-mode",O="skdx-brand",u="(prefers-color-scheme: dark)";function x(o={}){let{brand:t,element:a,persist:i=!1,storageKey:r=f}=o,e=(t===void 0?void 0:S(t))??p,s=window.matchMedia(u),c,l=d=>{let n=null;try{n=localStorage.getItem(r)}catch{}let g=n==="light"||n==="dark"?n:void 0,m=(g!==c?g:void 0)??(d?"dark":"light");if(b(e.themes[m],a),!!i)try{localStorage.setItem(r,m),c=m}catch{}};l(s.matches);let h=d=>l(d.matches);return s.addEventListener("change",h),()=>s.removeEventListener("change",h)}function M(o={}){let{brandKey:t=O,modeKey:a=f,brand:i=p.name}=o,r=Object.fromEntries(y.map(e=>[e.name,[e.themes.light.name,e.themes.dark.name]]));return`(function(){try{var t=${JSON.stringify(r)},f=${JSON.stringify(i)};var b=localStorage.getItem(${JSON.stringify(t)})||f;var m=localStorage.getItem(${JSON.stringify(a)});if(m!=="light"&&m!=="dark")m=matchMedia(${JSON.stringify(u)}).matches?"dark":"light";var p=t[b]||t[f];if(!p)return;var e=document.documentElement;e.setAttribute("data-skdx-theme",p[m==="dark"?1:0]);e.setAttribute("data-skdx-mode",m);}catch(e){}})();`}export{O as BRAND_STORAGE_KEY,f as MODE_STORAGE_KEY,M as getThemeInitScript,x as watchSystemMode};
|
package/dist/utils/theme.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var m=(r,t)=>{for(var n in t)e(r,n,{get:t[n],enumerable:!0})},l=(r,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of o(t))!a.call(r,i)&&i!==n&&e(r,i,{get:()=>t[i],enumerable:!(s=g(t,i))||s.enumerable});return r};var d=r=>l(e({},"__esModule",{value:!0}),r);var h={};m(h,{defaultMotion:()=>c});module.exports=d(h);var c={durationInstant:"0ms",durationFast:"100ms",durationNormal:"200ms",durationSlow:"300ms",easing:"cubic-bezier(0.16, 1, 0.3, 1)",easingExit:"cubic-bezier(0.4, 0, 1, 1)",easingSteady:"cubic-bezier(0.4, 0, 0.2, 1)",easingLinear:"linear",staggerTight:"4ms",staggerLoose:"40ms"};0&&(module.exports={defaultMotion});
|