@skdx/tokens 0.26.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/README.md +439 -0
- package/dist/foundation.css +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +1 -0
- package/dist/themes/AntBrand.cjs +1 -0
- package/dist/themes/AntBrand.d.cts +3 -0
- package/dist/themes/AntBrand.d.ts +3 -0
- package/dist/themes/AntBrand.js +1 -0
- package/dist/themes/AntDark.cjs +1 -0
- package/dist/themes/AntDark.d.cts +12 -0
- package/dist/themes/AntDark.d.ts +12 -0
- package/dist/themes/AntDark.js +1 -0
- package/dist/themes/CatppuccinLatte.cjs +1 -0
- package/dist/themes/CatppuccinLatte.d.cts +9 -0
- package/dist/themes/CatppuccinLatte.d.ts +9 -0
- package/dist/themes/CatppuccinLatte.js +1 -0
- package/dist/themes/CatppuccinMocha.cjs +1 -0
- package/dist/themes/CatppuccinMocha.d.cts +9 -0
- package/dist/themes/CatppuccinMocha.d.ts +9 -0
- package/dist/themes/CatppuccinMocha.js +1 -0
- package/dist/themes/ChakraBrand.cjs +1 -0
- package/dist/themes/ChakraBrand.d.cts +3 -0
- package/dist/themes/ChakraBrand.d.ts +3 -0
- package/dist/themes/ChakraBrand.js +1 -0
- package/dist/themes/ChakraDark.cjs +1 -0
- package/dist/themes/ChakraDark.d.cts +12 -0
- package/dist/themes/ChakraDark.d.ts +12 -0
- package/dist/themes/ChakraDark.js +1 -0
- package/dist/themes/CupcakeDark.cjs +1 -0
- package/dist/themes/CupcakeDark.d.cts +9 -0
- package/dist/themes/CupcakeDark.d.ts +9 -0
- package/dist/themes/CupcakeDark.js +1 -0
- package/dist/themes/CupcakeLight.cjs +1 -0
- package/dist/themes/CupcakeLight.d.cts +10 -0
- package/dist/themes/CupcakeLight.d.ts +10 -0
- package/dist/themes/CupcakeLight.js +1 -0
- package/dist/themes/DefaultTheme.cjs +1 -0
- package/dist/themes/DefaultTheme.d.cts +37 -0
- package/dist/themes/DefaultTheme.d.ts +37 -0
- package/dist/themes/DefaultTheme.js +1 -0
- package/dist/themes/DraculaDark.cjs +1 -0
- package/dist/themes/DraculaDark.d.cts +3 -0
- package/dist/themes/DraculaDark.d.ts +3 -0
- package/dist/themes/DraculaDark.js +1 -0
- package/dist/themes/DraculaLight.cjs +1 -0
- package/dist/themes/DraculaLight.d.cts +14 -0
- package/dist/themes/DraculaLight.d.ts +14 -0
- package/dist/themes/DraculaLight.js +1 -0
- package/dist/themes/EmeraldBrand.cjs +1 -0
- package/dist/themes/EmeraldBrand.d.cts +3 -0
- package/dist/themes/EmeraldBrand.d.ts +3 -0
- package/dist/themes/EmeraldBrand.js +1 -0
- package/dist/themes/EmeraldDark.cjs +1 -0
- package/dist/themes/EmeraldDark.d.cts +8 -0
- package/dist/themes/EmeraldDark.d.ts +8 -0
- package/dist/themes/EmeraldDark.js +1 -0
- package/dist/themes/EverforestDark.cjs +1 -0
- package/dist/themes/EverforestDark.d.cts +9 -0
- package/dist/themes/EverforestDark.d.ts +9 -0
- package/dist/themes/EverforestDark.js +1 -0
- package/dist/themes/EverforestLight.cjs +1 -0
- package/dist/themes/EverforestLight.d.cts +13 -0
- package/dist/themes/EverforestLight.d.ts +13 -0
- package/dist/themes/EverforestLight.js +1 -0
- package/dist/themes/FluentBrand.cjs +1 -0
- package/dist/themes/FluentBrand.d.cts +3 -0
- package/dist/themes/FluentBrand.d.ts +3 -0
- package/dist/themes/FluentBrand.js +1 -0
- package/dist/themes/FluentDark.cjs +1 -0
- package/dist/themes/FluentDark.d.cts +11 -0
- package/dist/themes/FluentDark.d.ts +11 -0
- package/dist/themes/FluentDark.js +1 -0
- package/dist/themes/GraphiteBrand.cjs +1 -0
- package/dist/themes/GraphiteBrand.d.cts +3 -0
- package/dist/themes/GraphiteBrand.d.ts +3 -0
- package/dist/themes/GraphiteBrand.js +1 -0
- package/dist/themes/GraphiteDark.cjs +1 -0
- package/dist/themes/GraphiteDark.d.cts +8 -0
- package/dist/themes/GraphiteDark.d.ts +8 -0
- package/dist/themes/GraphiteDark.js +1 -0
- package/dist/themes/GruvboxDark.cjs +1 -0
- package/dist/themes/GruvboxDark.d.cts +9 -0
- package/dist/themes/GruvboxDark.d.ts +9 -0
- package/dist/themes/GruvboxDark.js +1 -0
- package/dist/themes/GruvboxLight.cjs +1 -0
- package/dist/themes/GruvboxLight.d.cts +13 -0
- package/dist/themes/GruvboxLight.d.ts +13 -0
- package/dist/themes/GruvboxLight.js +1 -0
- package/dist/themes/MaterialBrand.cjs +1 -0
- package/dist/themes/MaterialBrand.d.cts +3 -0
- package/dist/themes/MaterialBrand.d.ts +3 -0
- package/dist/themes/MaterialBrand.js +1 -0
- package/dist/themes/MaterialDark.cjs +1 -0
- package/dist/themes/MaterialDark.d.cts +12 -0
- package/dist/themes/MaterialDark.d.ts +12 -0
- package/dist/themes/MaterialDark.js +1 -0
- package/dist/themes/MidnightBrand.cjs +1 -0
- package/dist/themes/MidnightBrand.d.cts +11 -0
- package/dist/themes/MidnightBrand.d.ts +11 -0
- package/dist/themes/MidnightBrand.js +1 -0
- package/dist/themes/MidnightLight.cjs +1 -0
- package/dist/themes/MidnightLight.d.cts +10 -0
- package/dist/themes/MidnightLight.d.ts +10 -0
- package/dist/themes/MidnightLight.js +1 -0
- package/dist/themes/NordDark.cjs +1 -0
- package/dist/themes/NordDark.d.cts +3 -0
- package/dist/themes/NordDark.d.ts +3 -0
- package/dist/themes/NordDark.js +1 -0
- package/dist/themes/NordLight.cjs +1 -0
- package/dist/themes/NordLight.d.cts +13 -0
- package/dist/themes/NordLight.d.ts +13 -0
- package/dist/themes/NordLight.js +1 -0
- package/dist/themes/OneDark.cjs +1 -0
- package/dist/themes/OneDark.d.cts +9 -0
- package/dist/themes/OneDark.d.ts +9 -0
- package/dist/themes/OneDark.js +1 -0
- package/dist/themes/OneLight.cjs +1 -0
- package/dist/themes/OneLight.d.cts +13 -0
- package/dist/themes/OneLight.d.ts +13 -0
- package/dist/themes/OneLight.js +1 -0
- package/dist/themes/PrimerDark.cjs +1 -0
- package/dist/themes/PrimerDark.d.cts +9 -0
- package/dist/themes/PrimerDark.d.ts +9 -0
- package/dist/themes/PrimerDark.js +1 -0
- package/dist/themes/PrimerLight.cjs +1 -0
- package/dist/themes/PrimerLight.d.cts +9 -0
- package/dist/themes/PrimerLight.d.ts +9 -0
- package/dist/themes/PrimerLight.js +1 -0
- package/dist/themes/RosePine.cjs +1 -0
- package/dist/themes/RosePine.d.cts +9 -0
- package/dist/themes/RosePine.d.ts +9 -0
- package/dist/themes/RosePine.js +1 -0
- package/dist/themes/RosePineDawn.cjs +1 -0
- package/dist/themes/RosePineDawn.d.cts +13 -0
- package/dist/themes/RosePineDawn.d.ts +13 -0
- package/dist/themes/RosePineDawn.js +1 -0
- package/dist/themes/SkandaDark.cjs +1 -0
- package/dist/themes/SkandaDark.d.cts +12 -0
- package/dist/themes/SkandaDark.d.ts +12 -0
- package/dist/themes/SkandaDark.js +1 -0
- package/dist/themes/SkandaLight.cjs +1 -0
- package/dist/themes/SkandaLight.d.cts +3 -0
- package/dist/themes/SkandaLight.d.ts +3 -0
- package/dist/themes/SkandaLight.js +1 -0
- package/dist/themes/SolarizedDark.cjs +1 -0
- package/dist/themes/SolarizedDark.d.cts +9 -0
- package/dist/themes/SolarizedDark.d.ts +9 -0
- package/dist/themes/SolarizedDark.js +1 -0
- package/dist/themes/SolarizedLight.cjs +1 -0
- package/dist/themes/SolarizedLight.d.cts +9 -0
- package/dist/themes/SolarizedLight.d.ts +9 -0
- package/dist/themes/SolarizedLight.js +1 -0
- package/dist/themes/SynthwaveDark.cjs +1 -0
- package/dist/themes/SynthwaveDark.d.cts +9 -0
- package/dist/themes/SynthwaveDark.d.ts +9 -0
- package/dist/themes/SynthwaveDark.js +1 -0
- package/dist/themes/SynthwaveLight.cjs +1 -0
- package/dist/themes/SynthwaveLight.d.cts +12 -0
- package/dist/themes/SynthwaveLight.d.ts +12 -0
- package/dist/themes/SynthwaveLight.js +1 -0
- package/dist/themes/brands.cjs +1 -0
- package/dist/themes/brands.d.cts +41 -0
- package/dist/themes/brands.d.ts +41 -0
- package/dist/themes/brands.js +1 -0
- package/dist/themes/createBrandTheme.cjs +1 -0
- package/dist/themes/createBrandTheme.d.cts +55 -0
- package/dist/themes/createBrandTheme.d.ts +55 -0
- package/dist/themes/createBrandTheme.js +1 -0
- package/dist/themes/index.cjs +1 -0
- package/dist/themes/index.d.cts +41 -0
- package/dist/themes/index.d.ts +41 -0
- package/dist/themes/index.js +1 -0
- package/dist/themes.css +1 -0
- package/dist/tokens.css +1 -0
- package/dist/utils/aliases.cjs +9 -0
- package/dist/utils/aliases.d.cts +121 -0
- package/dist/utils/aliases.d.ts +121 -0
- package/dist/utils/aliases.js +9 -0
- package/dist/utils/contrast.cjs +1 -0
- package/dist/utils/contrast.d.cts +27 -0
- package/dist/utils/contrast.d.ts +27 -0
- package/dist/utils/contrast.js +1 -0
- package/dist/utils/cssVars.cjs +2 -0
- package/dist/utils/cssVars.d.cts +37 -0
- package/dist/utils/cssVars.d.ts +37 -0
- package/dist/utils/cssVars.js +2 -0
- package/dist/utils/foundation.cjs +15 -0
- package/dist/utils/foundation.d.cts +300 -0
- package/dist/utils/foundation.d.ts +300 -0
- package/dist/utils/foundation.js +15 -0
- package/dist/utils/mode.cjs +1 -0
- package/dist/utils/mode.d.cts +89 -0
- package/dist/utils/mode.d.ts +89 -0
- package/dist/utils/mode.js +1 -0
- package/dist/utils/theme.cjs +1 -0
- package/dist/utils/theme.d.cts +503 -0
- package/dist/utils/theme.d.ts +503 -0
- package/dist/utils/theme.js +1 -0
- package/dist/utils/toCss.cjs +10 -0
- package/dist/utils/toCss.d.cts +92 -0
- package/dist/utils/toCss.d.ts +92 -0
- package/dist/utils/toCss.js +10 -0
- package/package.json +70 -0
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { type ThemeControls, type ThemeControlsCoarse, type ThemeMotion, type ThemeRadii, type ThemeShadows, type ThemeSpace, type ThemeTypography } from './theme.js';
|
|
2
|
+
/**
|
|
3
|
+
* The type system: one font stack, one scale, one set of weights,
|
|
4
|
+
* line-heights and tracking steps, shared by every theme.
|
|
5
|
+
*
|
|
6
|
+
* A theme picks colors. It does not get to resize the type scale, because a
|
|
7
|
+
* layout that reflows when you switch brand is a layout that was never
|
|
8
|
+
* designed — it was designed once, against one scale, and every other brand
|
|
9
|
+
* was hoping. The two font *stacks* are the only part a theme can override,
|
|
10
|
+
* and only through {@link ThemeTypographyDeviation}, because impersonating a
|
|
11
|
+
* design language means impersonating its typeface.
|
|
12
|
+
*
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
15
|
+
export declare const typography: ThemeTypography;
|
|
16
|
+
/**
|
|
17
|
+
* The spacing scale — a 4px base with the usual gaps (no `7`, no `9`) so the
|
|
18
|
+
* steps stay memorable rather than exhaustive. Structural: gap and padding are
|
|
19
|
+
* rhythm, and rhythm is a property of the design system, not of the brand
|
|
20
|
+
* painted on top of it.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
24
|
+
export declare const space: ThemeSpace;
|
|
25
|
+
/**
|
|
26
|
+
* The corner-radius scale. Shared for the same reason {@link space} is: a
|
|
27
|
+
* component's silhouette is part of the system's shape language, and a brand
|
|
28
|
+
* that rounds its corners differently is a different component library
|
|
29
|
+
* wearing the same class names.
|
|
30
|
+
*
|
|
31
|
+
* @public
|
|
32
|
+
*/
|
|
33
|
+
export declare const radii: ThemeRadii;
|
|
34
|
+
/**
|
|
35
|
+
* The elevation scale — geometry only. Every value defers its color to
|
|
36
|
+
* `var(--skdx-shadow-color)` and scales its alpha by
|
|
37
|
+
* `var(--skdx-shadow-strength)`, both of which a theme supplies (see
|
|
38
|
+
* {@link ThemeShadowColor}).
|
|
39
|
+
*
|
|
40
|
+
* This split is the whole reason shadows can be shared at all. A shadow is one
|
|
41
|
+
* CSS string that welds geometry to a color, so before this every theme
|
|
42
|
+
* restated `0 4px 6px -1px` purely to be able to change `rgb(…)` at the end of
|
|
43
|
+
* it — 38 copies of the same three offsets, and no way to tell a deliberate
|
|
44
|
+
* elevation change from a color change.
|
|
45
|
+
*
|
|
46
|
+
* The base alphas below are the original `skanda-light` values, so a theme
|
|
47
|
+
* with `strength: '1'` renders exactly what it did before the split.
|
|
48
|
+
* Substitution is lazy: these live at `:root`, but `var(--skdx-shadow-color)`
|
|
49
|
+
* resolves against the element the shadow is finally *used* on, so the active
|
|
50
|
+
* `[data-skdx-theme]` block wins. `calc()` is legal in the alpha slot, and an
|
|
51
|
+
* alpha above 1 clamps rather than erroring — which is what keeps a
|
|
52
|
+
* high-strength dark theme from being a footgun.
|
|
53
|
+
*
|
|
54
|
+
* @public
|
|
55
|
+
*/
|
|
56
|
+
export declare const shadows: ThemeShadows;
|
|
57
|
+
/**
|
|
58
|
+
* The shared animation timing — re-exported from {@link defaultMotion}, which
|
|
59
|
+
* remains the single source so that `themeToCssVars` can keep merging it under
|
|
60
|
+
* a theme's {@link Theme.motion} without importing this module.
|
|
61
|
+
*
|
|
62
|
+
* See {@link ThemeMotion} for why motion is theme-invariant.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
*/
|
|
66
|
+
export declare const motion: Required<ThemeMotion>;
|
|
67
|
+
/**
|
|
68
|
+
* A structural stacking-order scale for overlay-class UI (dropdowns, sticky
|
|
69
|
+
* headers, dialog/popover backdrops, floating content, toasts). Unlike the
|
|
70
|
+
* rest of the token system, z-index isn't a per-brand visual choice — every
|
|
71
|
+
* theme should stack the same way — so it's exported once here rather than
|
|
72
|
+
* duplicated into all 38 {@link Theme} objects. Consumers building an app
|
|
73
|
+
* with multiple concurrent overlay types (e.g. a `Select` opened from inside
|
|
74
|
+
* a `Dialog`, with a `Toast` on top of both) should coordinate their own
|
|
75
|
+
* z-indices against this scale instead of picking ad hoc numbers per
|
|
76
|
+
* component.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```css
|
|
80
|
+
* .dialog-overlay { z-index: var(--skdx-z-index-overlay); }
|
|
81
|
+
* .select-content { z-index: var(--skdx-z-index-popover); }
|
|
82
|
+
* .toast-viewport { z-index: var(--skdx-z-index-toast); }
|
|
83
|
+
* ```
|
|
84
|
+
*
|
|
85
|
+
* @public
|
|
86
|
+
*/
|
|
87
|
+
export declare const zIndex: {
|
|
88
|
+
readonly base: 0;
|
|
89
|
+
readonly dropdown: 10;
|
|
90
|
+
readonly sticky: 20;
|
|
91
|
+
/** The scrim behind a modal surface. */
|
|
92
|
+
readonly overlay: 30;
|
|
93
|
+
/** The modal surface itself — above its own scrim, below any popover opened from inside it. */
|
|
94
|
+
readonly modal: 35;
|
|
95
|
+
readonly popover: 40;
|
|
96
|
+
readonly toast: 50;
|
|
97
|
+
/**
|
|
98
|
+
* Escape hatch for the one thing that must sit above everything, e.g. a
|
|
99
|
+
* debug overlay or an "app is offline" banner. Deliberately far above
|
|
100
|
+
* `toast` so app code never has to guess a bigger number.
|
|
101
|
+
*/
|
|
102
|
+
readonly max: 9999;
|
|
103
|
+
};
|
|
104
|
+
/** The shape of the {@link zIndex} scale — a map of named stacking layers (`sticky`, `overlay`, `popover`, `toast`, …) to their numeric `z-index`. @public */
|
|
105
|
+
export type ZIndexScale = typeof zIndex;
|
|
106
|
+
/**
|
|
107
|
+
* Structural focus-ring geometry (width/offset) — the *color* half of the
|
|
108
|
+
* focus-ring contract is themed per brand ({@link SemanticColors.focusRing}),
|
|
109
|
+
* but the ring's thickness and offset are a layout constant every theme
|
|
110
|
+
* should share, so they live here rather than being repeated as identical
|
|
111
|
+
* values across all 38 bundled themes.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```css
|
|
115
|
+
* :focus-visible {
|
|
116
|
+
* outline: var(--skdx-focus-ring-width) solid var(--skdx-color-semantic-focus-ring);
|
|
117
|
+
* outline-offset: var(--skdx-focus-ring-offset);
|
|
118
|
+
* }
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* @public
|
|
122
|
+
*/
|
|
123
|
+
export declare const focusRing: {
|
|
124
|
+
readonly width: "2px";
|
|
125
|
+
readonly offset: "2px";
|
|
126
|
+
/**
|
|
127
|
+
* The offset a *clipping* container hands down to its children.
|
|
128
|
+
*
|
|
129
|
+
* An outline is painted outward from the border edge and is clipped by an
|
|
130
|
+
* ancestor's `overflow` exactly like any other overflowing paint — which
|
|
131
|
+
* sliced the ring off inside every control group that rounds its corners by
|
|
132
|
+
* clipping. Because `outline-offset` is read from a custom property, such a
|
|
133
|
+
* container sets this on itself and every descendant ring moves *inside* the
|
|
134
|
+
* border box, where nothing can reach it. One declaration per clipping
|
|
135
|
+
* container, no per-part focus rules.
|
|
136
|
+
*
|
|
137
|
+
* Negative by exactly the ring width, which lands it flush against the
|
|
138
|
+
* inside of the edge rather than floating in from it.
|
|
139
|
+
*/
|
|
140
|
+
readonly offsetInset: "calc(-1 * var(--skdx-focus-ring-width))";
|
|
141
|
+
};
|
|
142
|
+
/** The shape of the {@link focusRing} geometry — the structural `width`/`offset` of the focus ring (its color is themed separately). @public */
|
|
143
|
+
export type FocusRingScale = typeof focusRing;
|
|
144
|
+
/**
|
|
145
|
+
* Border thicknesses. Structural for the same reason {@link focusRing}'s
|
|
146
|
+
* geometry is: a brand changes border *color* (see
|
|
147
|
+
* {@link SemanticColors.border}), not how many pixels thick a hairline is.
|
|
148
|
+
* Three steps only — a hairline, an emphasis weight (focus/selected/invalid
|
|
149
|
+
* outlines drawn without the focus ring), and a heavy weight for deliberate
|
|
150
|
+
* structural rules. There is no `0`: that's `border: none`, not a token.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```css
|
|
154
|
+
* .card { border: var(--skdx-border-width-thin) solid var(--skdx-color-semantic-border); }
|
|
155
|
+
* .card[data-invalid] { border-width: var(--skdx-border-width-thick); }
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
export declare const borderWidth: {
|
|
161
|
+
readonly thin: "1px";
|
|
162
|
+
readonly thick: "2px";
|
|
163
|
+
readonly thicker: "4px";
|
|
164
|
+
};
|
|
165
|
+
/** The shape of the {@link borderWidth} scale — `thin`/`thick`/`thicker` border thicknesses. @public */
|
|
166
|
+
export type BorderWidthScale = typeof borderWidth;
|
|
167
|
+
/**
|
|
168
|
+
* The shared control geometry — heights, paddings, icon boxes, row heights and
|
|
169
|
+
* overlay insets. See {@link ThemeControls} for why this is structural rather
|
|
170
|
+
* than per-brand, and for the retuning escape hatch.
|
|
171
|
+
*
|
|
172
|
+
* The ladder is an even 6px step (30/36/42) and every rung sits inside the
|
|
173
|
+
* range the two reference libraries surveyed occupy. Several values are
|
|
174
|
+
* `var()` references rather than lengths on purpose: a control's inline
|
|
175
|
+
* padding *is* a step of {@link space}, and restating `0.75rem` here would let
|
|
176
|
+
* the two drift. The exceptions are the four numbers that are deliberately off
|
|
177
|
+
* a scale — `padding.sm` (10px), `height.compact` (32px), `item.gap` (2px) and
|
|
178
|
+
* `target.min` (24px) — each documented where it is declared.
|
|
179
|
+
*
|
|
180
|
+
* @public
|
|
181
|
+
*/
|
|
182
|
+
export declare const controls: ThemeControls;
|
|
183
|
+
/**
|
|
184
|
+
* What a coarse pointer overrides. Emitted by {@link foundationToCss} as a
|
|
185
|
+
* `@media (pointer: coarse)` block; see {@link ThemeControlsCoarse} for why
|
|
186
|
+
* only hit sizes are listed.
|
|
187
|
+
*
|
|
188
|
+
* @public
|
|
189
|
+
*/
|
|
190
|
+
export declare const controlsCoarse: ThemeControlsCoarse;
|
|
191
|
+
/**
|
|
192
|
+
* The two opacities the system actually has an opinion about. Deliberately
|
|
193
|
+
* *not* a 0–100 ramp: an arbitrary ramp invents decisions nobody made, while
|
|
194
|
+
* these two are real, repeated cross-component choices — how faded a disabled
|
|
195
|
+
* control is, and how much a modal scrim dims the page behind it.
|
|
196
|
+
*
|
|
197
|
+
* Scrim *color* is themed ({@link SemanticColors.overlay}); this is the
|
|
198
|
+
* structural strength of the dim, so every brand's scrim occludes equally.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```css
|
|
202
|
+
* [data-disabled] { opacity: var(--skdx-opacity-disabled); }
|
|
203
|
+
* .dialog-overlay { background: var(--skdx-color-semantic-overlay); opacity: var(--skdx-opacity-scrim); }
|
|
204
|
+
* ```
|
|
205
|
+
*
|
|
206
|
+
* @public
|
|
207
|
+
*/
|
|
208
|
+
export declare const opacity: {
|
|
209
|
+
readonly disabled: "0.5";
|
|
210
|
+
readonly scrim: "0.6";
|
|
211
|
+
};
|
|
212
|
+
/** The shape of the {@link opacity} scale — the `disabled` and `scrim` opacities. @public */
|
|
213
|
+
export type OpacityScale = typeof opacity;
|
|
214
|
+
/**
|
|
215
|
+
* Viewport widths, in pixels, as **TypeScript exports only** — deliberately
|
|
216
|
+
* not emitted as CSS custom properties by {@link foundationToCss}. A custom
|
|
217
|
+
* property cannot be used in a `@media` query's condition (`@media (min-width:
|
|
218
|
+
* var(--x))` is invalid CSS), so a `--skdx-breakpoint-*` variable would be a
|
|
219
|
+
* token that looks usable and isn't. Consume these from JS/TS, or from a
|
|
220
|
+
* build step that inlines the number into your own media queries.
|
|
221
|
+
*
|
|
222
|
+
* The components themselves are headless and ship no responsive behavior;
|
|
223
|
+
* this exists so consumers building a styled layer on top don't have to
|
|
224
|
+
* invent their own set.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* import { breakpoints } from '@skdx/tokens';
|
|
229
|
+
*
|
|
230
|
+
* const isDesktop = window.matchMedia(`(min-width: ${breakpoints.lg}px)`).matches;
|
|
231
|
+
* ```
|
|
232
|
+
*
|
|
233
|
+
* @public
|
|
234
|
+
*/
|
|
235
|
+
export declare const breakpoints: {
|
|
236
|
+
readonly sm: 640;
|
|
237
|
+
readonly md: 768;
|
|
238
|
+
readonly lg: 1024;
|
|
239
|
+
readonly xl: 1280;
|
|
240
|
+
};
|
|
241
|
+
/** The shape of the {@link breakpoints} scale — named viewport widths in pixels. @public */
|
|
242
|
+
export type BreakpointScale = typeof breakpoints;
|
|
243
|
+
/**
|
|
244
|
+
* Flattens every shared token into a map of CSS custom property names to
|
|
245
|
+
* values — the foundation's counterpart to `themeToCssVars`. Together the two
|
|
246
|
+
* maps are the complete `--skdx-*` surface, and they never overlap.
|
|
247
|
+
*
|
|
248
|
+
* {@link breakpoints} is not included — see its docs for why a breakpoint
|
|
249
|
+
* can't be a CSS custom property.
|
|
250
|
+
*
|
|
251
|
+
* @returns A plain object keyed by CSS custom property name (e.g. `'--skdx-space-4'`), unprefixed by any selector.
|
|
252
|
+
*
|
|
253
|
+
* @public
|
|
254
|
+
*/
|
|
255
|
+
export declare function foundationToCssVars(): Record<string, string>;
|
|
256
|
+
/**
|
|
257
|
+
* The control metrics a coarse pointer overrides, as a var map — the
|
|
258
|
+
* `@media (pointer: coarse)` counterpart to {@link foundationToCssVars}.
|
|
259
|
+
*
|
|
260
|
+
* Exported because `@skdx/skins` renders its own no-tokens fallback copy of
|
|
261
|
+
* both blocks from these functions rather than restating the values, which is
|
|
262
|
+
* the only thing that keeps the two in step.
|
|
263
|
+
*
|
|
264
|
+
* @public
|
|
265
|
+
*/
|
|
266
|
+
export declare function coarsePointerToCssVars(): Record<string, string>;
|
|
267
|
+
/**
|
|
268
|
+
* Renders every shared token as a `:root`-scoped `--skdx-*` rule block — the
|
|
269
|
+
* theme-invariant counterpart to {@link themeToCss}. **Inject this exactly
|
|
270
|
+
* once**, then inject `themeToCss(theme)` per theme alongside it. Without it
|
|
271
|
+
* the type scale, spacing, radii, shadow geometry and motion are simply
|
|
272
|
+
* absent, because no theme declares them any more.
|
|
273
|
+
*
|
|
274
|
+
* Followed by a `@media (prefers-reduced-motion: reduce)` block that
|
|
275
|
+
* re-declares every `--skdx-motion-duration-*` and `--skdx-motion-stagger-*` as
|
|
276
|
+
* `0ms`. Components are headless and animate nothing themselves, so honoring
|
|
277
|
+
* the preference has to happen where the durations are *defined* rather than
|
|
278
|
+
* where they're used — this way a consumer who writes `transition-duration:
|
|
279
|
+
* var(--skdx-motion-duration-normal)` gets WCAG 2.3.3 behavior for free instead
|
|
280
|
+
* of having to remember the media query at every call site. The easing curve
|
|
281
|
+
* is left alone: it's a shape, not a duration, and is inert at `0ms`. A theme
|
|
282
|
+
* that retunes motion via `ThemeMotionDeviation` emits its own copy of this
|
|
283
|
+
* block, so the guarantee survives the escape hatch.
|
|
284
|
+
*
|
|
285
|
+
* Then a `@media (pointer: coarse)` block re-declaring the hit sizes from
|
|
286
|
+
* {@link controlsCoarse}, for the same reason: the preference has to be honored
|
|
287
|
+
* where the metric is *defined*, so a consumer who writes
|
|
288
|
+
* `block-size: var(--skdx-control-height-md)` gets a touch-sized control without
|
|
289
|
+
* having to remember the query.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```ts
|
|
293
|
+
* import { foundationToCss, themeToCss, themes } from '@skdx/tokens';
|
|
294
|
+
*
|
|
295
|
+
* const css = foundationToCss() + themes.map((t) => themeToCss(t)).join('');
|
|
296
|
+
* ```
|
|
297
|
+
*
|
|
298
|
+
* @public
|
|
299
|
+
*/
|
|
300
|
+
export declare function foundationToCss(): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{reducedMotionVarNames as m,sectionsToCssVars as a,varsToDeclarations as s}from"./cssVars.js";import{defaultMotion as p}from"./theme.js";var e="skdx",c={fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fontFamilyMono:"'SF Mono', SFMono-Regular, ui-monospace, Menlo, Consolas, monospace",fontSize:{xs:"0.75rem",sm:"0.875rem",md:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem"},fontWeight:{regular:400,medium:500,semibold:600,bold:700},lineHeight:{tight:"1.25",snug:"1.43",normal:"1.5",relaxed:"1.75"},letterSpacing:{tight:"-0.015em",normal:"0em",wide:"0.025em",wider:"0.05em"}},d={1:"0.25rem",2:"0.5rem",3:"0.75rem",4:"1rem",5:"1.25rem",6:"1.5rem",8:"2rem",10:"2.5rem",12:"3rem",16:"4rem"},l={sm:"0.25rem",inner:"0.375rem",md:"0.5rem",lg:"0.75rem",xl:"1rem",full:"9999px"},g={sm:`0 1px 2px 0 ${n(.05)}`,md:`0 4px 6px -1px ${n(.1)}, 0 2px 4px -2px ${n(.1)}`,lg:`0 10px 15px -3px ${n(.1)}, 0 4px 6px -4px ${n(.1)}`,overlay:`0 25px 50px -12px ${n(.25)}`};function n(r){return`rgb(var(--${e}-shadow-color) / calc(${r} * var(--${e}-shadow-strength)))`}var x=p,u={base:0,dropdown:10,sticky:20,overlay:30,modal:35,popover:40,toast:50,max:9999},h={width:"2px",offset:"2px",offsetInset:"calc(-1 * var(--skdx-focus-ring-width))"},y={thin:"1px",thick:"2px",thicker:"4px"},f={control:{height:{sm:"1.875rem",md:"2.25rem",lg:"2.625rem",compact:"2rem"},padding:{sm:"0.625rem",md:`var(--${e}-space-3)`,lg:`var(--${e}-space-4)`},gap:{sm:`var(--${e}-space-1)`,md:`var(--${e}-space-2)`,lg:`var(--${e}-space-2)`}},iconSize:{sm:"1rem",md:"1.25rem",lg:"1.5rem"},indicatorSize:{sm:"1rem",md:"1.25rem",lg:"1.5rem"},item:{height:{sm:"1.75rem",md:"2.25rem",lg:"2.5rem"},gap:"2px"},overlay:{padding:`var(--${e}-space-1)`,radius:`var(--${e}-radius-lg)`,minWidth:"7.5rem"},field:{gap:`var(--${e}-space-1)`,labelGap:`var(--${e}-space-1)`},target:{min:"24px"}},w={control:{height:{sm:"2.25rem",md:"2.75rem",lg:"3rem",compact:"2.75rem"}},item:{height:{sm:"2.25rem",md:"2.75rem",lg:"3rem"}},target:{min:"44px"}},k={disabled:"0.5",scrim:"0.6"},v={sm:640,md:768,lg:1024,xl:1280};function T(){return a([["font",c],["space",d],["radius",l],["shadow",g],["motion",x],["z-index",u],["focus-ring",h],["border-width",y],["opacity",k],...i(f)])}function i(r){let o=t=>r[t];return[["control",o("control")],["icon-size",o("iconSize")],["indicator-size",o("indicatorSize")],["item",o("item")],["overlay",o("overlay")],["field",o("field")],["target",o("target")]]}function R(){return a(i(w))}function C(){let r=T(),o=m(r).map(t=>` ${t}: 0ms;`);return`:root {
|
|
2
|
+
${s(r)}
|
|
3
|
+
}
|
|
4
|
+
@media (prefers-reduced-motion: reduce) {
|
|
5
|
+
:root {
|
|
6
|
+
${o.join(`
|
|
7
|
+
`)}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
@media (pointer: coarse) {
|
|
11
|
+
:root {
|
|
12
|
+
${s(R()," ")}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
`}export{y as borderWidth,v as breakpoints,R as coarsePointerToCssVars,f as controls,w as controlsCoarse,h as focusRing,C as foundationToCss,T as foundationToCssVars,x as motion,k as opacity,l as radii,g as shadows,d as space,c as typography,u as zIndex};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var d=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var b=Object.prototype.hasOwnProperty;var O=(t,e)=>{for(var n in e)d(t,n,{get:e[n],enumerable:!0})},k=(t,e,n,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of S(e))!b.call(t,r)&&r!==n&&d(t,r,{get:()=>e[r],enumerable:!(o=u(e,r))||o.enumerable});return t};var E=t=>k(d({},"__esModule",{value:!0}),t);var M={};O(M,{BRAND_STORAGE_KEY:()=>g,MODE_STORAGE_KEY:()=>c,getThemeInitScript:()=>x,watchSystemMode:()=>v});module.exports=E(M);var a=require("../themes/brands.cjs"),f=require("./toCss.cjs"),c="skdx-mode",g="skdx-brand",y="(prefers-color-scheme: dark)";function v(t={}){let{brand:e,element:n,persist:o=!1,storageKey:r=c}=t,s=(e===void 0?void 0:(0,a.getBrand)(e))??a.defaultBrand,i=window.matchMedia(y),h=m=>{let p=m?"dark":"light";if((0,f.applyTheme)(s.themes[p],n),!!o)try{localStorage.setItem(r,p)}catch{}};h(i.matches);let l=m=>h(m.matches);return i.addEventListener("change",l),()=>i.removeEventListener("change",l)}function x(t={}){let{brandKey:e=g,modeKey:n=c,fallbackBrand:o=a.defaultBrand.name}=t,r=Object.fromEntries(a.brands.map(s=>[s.name,[s.themes.light.name,s.themes.dark.name]]));return`(function(){try{var t=${JSON.stringify(r)},f=${JSON.stringify(o)};var b=localStorage.getItem(${JSON.stringify(e)})||f;var m=localStorage.getItem(${JSON.stringify(n)});if(m!=="light"&&m!=="dark")m=matchMedia(${JSON.stringify(y)}).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){}})();`}0&&(module.exports={BRAND_STORAGE_KEY,MODE_STORAGE_KEY,getThemeInitScript,watchSystemMode});
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** `localStorage` key the mode preference (`'light' | 'dark' | 'system'`) is read from and written to. @public */
|
|
2
|
+
export declare const MODE_STORAGE_KEY = "skdx-mode";
|
|
3
|
+
/** `localStorage` key the brand preference (a {@link Brand} name, e.g. `'nord'`) is read from. @public */
|
|
4
|
+
export declare const BRAND_STORAGE_KEY = "skdx-brand";
|
|
5
|
+
/** Options for {@link watchSystemMode}. @public */
|
|
6
|
+
export interface WatchSystemModeOptions {
|
|
7
|
+
/** Brand whose light/dark pair is applied. Unknown names fall back to the default brand. @default 'skanda' */
|
|
8
|
+
brand?: string;
|
|
9
|
+
/** Element the resolved theme is applied to. @default document.documentElement */
|
|
10
|
+
element?: HTMLElement;
|
|
11
|
+
/** Whether to mirror the resolved mode into `localStorage` under {@link storageKey}. @default false */
|
|
12
|
+
persist?: boolean;
|
|
13
|
+
/** `localStorage` key used when `persist` is on. @default MODE_STORAGE_KEY */
|
|
14
|
+
storageKey?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Follows the OS color-scheme preference: applies the brand's theme for the
|
|
18
|
+
* currently resolved mode, then re-applies it whenever the preference flips
|
|
19
|
+
* — the runtime half of "mode: system". Call it once on mount and call the
|
|
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.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { watchSystemMode } from '@skdx/tokens';
|
|
31
|
+
*
|
|
32
|
+
* const stop = watchSystemMode({ brand: 'nord', persist: true });
|
|
33
|
+
* // later…
|
|
34
|
+
* stop();
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare function watchSystemMode(options?: WatchSystemModeOptions): () => void;
|
|
40
|
+
/** Options for {@link getThemeInitScript}. @public */
|
|
41
|
+
export interface ThemeInitScriptOptions {
|
|
42
|
+
/** `localStorage` key holding the brand name. @default BRAND_STORAGE_KEY */
|
|
43
|
+
brandKey?: string;
|
|
44
|
+
/** `localStorage` key holding `'light' | 'dark' | 'system'`. @default MODE_STORAGE_KEY */
|
|
45
|
+
modeKey?: string;
|
|
46
|
+
/** Brand used when nothing is persisted or the persisted name is unknown. @default 'skanda' */
|
|
47
|
+
fallbackBrand?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Builds the blocking snippet that stamps `data-skdx-theme` and `data-skdx-mode`
|
|
51
|
+
* on `<html>` *before first paint*, so a dark-mode visitor never sees a flash
|
|
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`).
|
|
60
|
+
*
|
|
61
|
+
* @example Next.js (App Router, `app/layout.tsx`)
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <head>
|
|
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>
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example Astro (`src/layouts/Base.astro`)
|
|
83
|
+
* ```astro
|
|
84
|
+
* <script is:inline set:html={getThemeInitScript()} />
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
export declare function getThemeInitScript(options?: ThemeInitScriptOptions): string;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** `localStorage` key the mode preference (`'light' | 'dark' | 'system'`) is read from and written to. @public */
|
|
2
|
+
export declare const MODE_STORAGE_KEY = "skdx-mode";
|
|
3
|
+
/** `localStorage` key the brand preference (a {@link Brand} name, e.g. `'nord'`) is read from. @public */
|
|
4
|
+
export declare const BRAND_STORAGE_KEY = "skdx-brand";
|
|
5
|
+
/** Options for {@link watchSystemMode}. @public */
|
|
6
|
+
export interface WatchSystemModeOptions {
|
|
7
|
+
/** Brand whose light/dark pair is applied. Unknown names fall back to the default brand. @default 'skanda' */
|
|
8
|
+
brand?: string;
|
|
9
|
+
/** Element the resolved theme is applied to. @default document.documentElement */
|
|
10
|
+
element?: HTMLElement;
|
|
11
|
+
/** Whether to mirror the resolved mode into `localStorage` under {@link storageKey}. @default false */
|
|
12
|
+
persist?: boolean;
|
|
13
|
+
/** `localStorage` key used when `persist` is on. @default MODE_STORAGE_KEY */
|
|
14
|
+
storageKey?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Follows the OS color-scheme preference: applies the brand's theme for the
|
|
18
|
+
* currently resolved mode, then re-applies it whenever the preference flips
|
|
19
|
+
* — the runtime half of "mode: system". Call it once on mount and call the
|
|
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.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { watchSystemMode } from '@skdx/tokens';
|
|
31
|
+
*
|
|
32
|
+
* const stop = watchSystemMode({ brand: 'nord', persist: true });
|
|
33
|
+
* // later…
|
|
34
|
+
* stop();
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
39
|
+
export declare function watchSystemMode(options?: WatchSystemModeOptions): () => void;
|
|
40
|
+
/** Options for {@link getThemeInitScript}. @public */
|
|
41
|
+
export interface ThemeInitScriptOptions {
|
|
42
|
+
/** `localStorage` key holding the brand name. @default BRAND_STORAGE_KEY */
|
|
43
|
+
brandKey?: string;
|
|
44
|
+
/** `localStorage` key holding `'light' | 'dark' | 'system'`. @default MODE_STORAGE_KEY */
|
|
45
|
+
modeKey?: string;
|
|
46
|
+
/** Brand used when nothing is persisted or the persisted name is unknown. @default 'skanda' */
|
|
47
|
+
fallbackBrand?: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Builds the blocking snippet that stamps `data-skdx-theme` and `data-skdx-mode`
|
|
51
|
+
* on `<html>` *before first paint*, so a dark-mode visitor never sees a flash
|
|
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`).
|
|
60
|
+
*
|
|
61
|
+
* @example Next.js (App Router, `app/layout.tsx`)
|
|
62
|
+
* ```tsx
|
|
63
|
+
* <head>
|
|
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>
|
|
80
|
+
* ```
|
|
81
|
+
*
|
|
82
|
+
* @example Astro (`src/layouts/Base.astro`)
|
|
83
|
+
* ```astro
|
|
84
|
+
* <script is:inline set:html={getThemeInitScript()} />
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @public
|
|
88
|
+
*/
|
|
89
|
+
export declare function getThemeInitScript(options?: ThemeInitScriptOptions): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{brands as f,defaultBrand as h,getBrand as g}from"../themes/brands.js";import{applyTheme as y}from"./toCss.js";var l="skdx-mode",u="skdx-brand",p="(prefers-color-scheme: dark)";function O(r={}){let{brand:t,element:n,persist:a=!1,storageKey:o=l}=r,e=(t===void 0?void 0:g(t))??h,s=window.matchMedia(p),m=i=>{let c=i?"dark":"light";if(y(e.themes[c],n),!!a)try{localStorage.setItem(o,c)}catch{}};m(s.matches);let d=i=>m(i.matches);return s.addEventListener("change",d),()=>s.removeEventListener("change",d)}function k(r={}){let{brandKey:t=u,modeKey:n=l,fallbackBrand:a=h.name}=r,o=Object.fromEntries(f.map(e=>[e.name,[e.themes.light.name,e.themes.dark.name]]));return`(function(){try{var t=${JSON.stringify(o)},f=${JSON.stringify(a)};var b=localStorage.getItem(${JSON.stringify(t)})||f;var m=localStorage.getItem(${JSON.stringify(n)});if(m!=="light"&&m!=="dark")m=matchMedia(${JSON.stringify(p)}).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{u as BRAND_STORAGE_KEY,l as MODE_STORAGE_KEY,k as getThemeInitScript,O as watchSystemMode};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var m=(r,t)=>{for(var e in t)n(r,e,{get:t[e],enumerable:!0})},l=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of o(t))!a.call(r,i)&&i!==e&&n(r,i,{get:()=>t[i],enumerable:!(s=g(t,i))||s.enumerable});return r};var d=r=>l(n({},"__esModule",{value:!0}),r);var c={};m(c,{defaultMotion:()=>h});module.exports=d(c);var h={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});
|