svelte-multistyle-ui 0.0.4-alpha → 0.0.6-alpha

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.
Files changed (77) hide show
  1. package/README.md +1 -1
  2. package/cli/bin.js +90 -0
  3. package/cli/emit.js +228 -0
  4. package/cli/fixtures/sample.expected.svelte +69 -0
  5. package/cli/fixtures/sample.yaml +128 -0
  6. package/cli/generate.js +68 -0
  7. package/cli/registry.js +95 -0
  8. package/cli/schema.js +145 -0
  9. package/dist/components/Button.svelte +3 -1
  10. package/dist/components/Button.svelte.d.ts +2 -0
  11. package/dist/components/DatePicker.svelte +47 -12
  12. package/dist/components/FAB.svelte +3 -1
  13. package/dist/components/FAB.svelte.d.ts +2 -0
  14. package/dist/components/IconButton.svelte +3 -1
  15. package/dist/components/IconButton.svelte.d.ts +2 -0
  16. package/dist/components/Input.svelte +0 -1
  17. package/dist/components/MultiSelect.svelte +0 -1
  18. package/dist/components/Select.svelte +0 -1
  19. package/dist/components/Stepper.svelte +91 -33
  20. package/dist/components/Textarea.svelte +0 -1
  21. package/dist/components/accordion-styles.css +1 -9
  22. package/dist/components/alert-styles.css +1 -4
  23. package/dist/components/avatar-styles.css +1 -4
  24. package/dist/components/breadcrumb-styles.css +1 -7
  25. package/dist/components/button-styles.css +44 -52
  26. package/dist/components/buttongroup-styles.css +1 -5
  27. package/dist/components/card-styles.css +1 -9
  28. package/dist/components/carousel-styles.css +1 -5
  29. package/dist/components/charts/Chart.svelte +63 -3
  30. package/dist/components/charts/chart-config.d.ts +27 -2
  31. package/dist/components/charts/chart-config.js +180 -67
  32. package/dist/components/charts/chart-styles.css +32 -17
  33. package/dist/components/checkbox-styles.css +2 -10
  34. package/dist/components/chip-styles.css +1 -4
  35. package/dist/components/commandpalette-styles.css +0 -4
  36. package/dist/components/datepicker-styles.css +967 -1027
  37. package/dist/components/divider-styles.css +1 -4
  38. package/dist/components/drawer-styles.css +0 -4
  39. package/dist/components/dropdown-styles.css +0 -5
  40. package/dist/components/fab-styles.css +18 -12
  41. package/dist/components/fileupload-styles.css +2 -10
  42. package/dist/components/iconbutton-styles.css +33 -34
  43. package/dist/components/input-styles.css +5 -37
  44. package/dist/components/modal-styles.css +0 -8
  45. package/dist/components/multiselect-styles.css +5 -32
  46. package/dist/components/pagination-styles.css +2 -5
  47. package/dist/components/popover-styles.css +0 -4
  48. package/dist/components/progressbar-styles.css +1 -5
  49. package/dist/components/radio-styles.css +1 -8
  50. package/dist/components/rating-styles.css +1 -4
  51. package/dist/components/select-styles.css +5 -18
  52. package/dist/components/skeleton-styles.css +1 -4
  53. package/dist/components/slider-styles.css +1 -5
  54. package/dist/components/sortablelist-styles.css +0 -13
  55. package/dist/components/spinner-styles.css +1 -4
  56. package/dist/components/stepper-styles.css +59 -8
  57. package/dist/components/table-styles.css +1 -5
  58. package/dist/components/tabs-styles.css +3 -7
  59. package/dist/components/textarea-styles.css +5 -18
  60. package/dist/components/theme-base.css +19 -2
  61. package/dist/components/theme.css +329 -333
  62. package/dist/components/toast-styles.css +1 -4
  63. package/dist/components/toggle-styles.css +1 -11
  64. package/dist/components/tooltip-styles.css +1 -4
  65. package/dist/index.d.ts +1 -0
  66. package/dist/index.js +3 -0
  67. package/dist/themes/color.d.ts +52 -0
  68. package/dist/themes/color.js +91 -0
  69. package/dist/themes/generator.d.ts +41 -0
  70. package/dist/themes/generator.js +174 -0
  71. package/dist/themes/index.d.ts +3 -0
  72. package/dist/themes/index.js +4 -0
  73. package/dist/themes/presets.d.ts +445 -0
  74. package/dist/themes/presets.js +144 -0
  75. package/dist/themes/schema.d.ts +47 -0
  76. package/dist/themes/schema.js +34 -0
  77. package/package.json +18 -4
@@ -100,7 +100,4 @@
100
100
  .s-toast-carbon { border-radius: 0; border: 1px solid var(--t-border); border-left: 3px solid var(--t-primary); font-family: 'IBM Plex Sans', sans-serif; }
101
101
 
102
102
  /* Liquid Glass */
103
- .s-toast-liquid-glass { border-radius: 16px; backdrop-filter: blur(24px) saturate(1.6); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); box-shadow: var(--t-shadow-lg), inset 0 1px 0 rgba(255,255,255,0.3); }
104
-
105
- /* Legacy iOS */
106
- .s-toast-legacy-ios { border-radius: 10px; border: 1px solid var(--t-border); background: linear-gradient(180deg, rgba(255,255,255,0.9) 0%, var(--t-surface) 100%); box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), var(--t-shadow-md); }
103
+ .s-toast-liquid-glass { border-radius: 16px; backdrop-filter: blur(24px) saturate(1.6); background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); box-shadow: var(--t-shadow-lg), inset 0 1px 0 rgba(255,255,255,0.3); }
@@ -118,14 +118,4 @@
118
118
  border: 1px solid rgba(255,255,255,0.2);
119
119
  box-shadow: var(--t-shadow-sm), inset 0 1px 0 rgba(255,255,255,0.3);
120
120
  }
121
- .s-toggle-liquid-glass.checked .s-toggle-track { background: color-mix(in srgb, var(--t-primary) 60%, transparent); }
122
-
123
- /* Legacy iOS */
124
- .s-toggle-legacy-ios .s-toggle-track {
125
- border: var(--t-border-width) solid var(--t-border);
126
- background: linear-gradient(180deg, rgba(255,255,255,0.8) 0%, var(--t-surface) 100%);
127
- box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
128
- }
129
- .s-toggle-legacy-ios.checked .s-toggle-track {
130
- background: linear-gradient(180deg, color-mix(in srgb, var(--t-primary) 80%, #fff) 0%, var(--t-primary) 100%);
131
- }
121
+ .s-toggle-liquid-glass.checked .s-toggle-track { background: color-mix(in srgb, var(--t-primary) 60%, transparent); }
@@ -50,7 +50,4 @@
50
50
  .s-tooltip-carbon .s-tooltip { border-radius: 0; font-family: 'IBM Plex Sans', sans-serif; font-size: 11px; }
51
51
 
52
52
  /* Liquid Glass */
53
- .s-tooltip-liquid-glass .s-tooltip { border-radius: 12px; backdrop-filter: blur(16px); background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.2); }
54
-
55
- /* Legacy iOS */
56
- .s-tooltip-legacy-ios .s-tooltip { border-radius: 8px; background: rgba(0,0,0,0.75); box-shadow: var(--t-shadow-md); }
53
+ .s-tooltip-liquid-glass .s-tooltip { border-radius: 12px; backdrop-filter: blur(16px); background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.2); }
package/dist/index.d.ts CHANGED
@@ -51,3 +51,4 @@ export { default as StackedBarChart } from "./components/charts/StackedBarChart.
51
51
  export { default as StackedLineChart } from "./components/charts/StackedLineChart.svelte";
52
52
  export { default as ComboChart } from "./components/charts/ComboChart.svelte";
53
53
  export { default as FAB } from "./components/FAB.svelte";
54
+ export { themes, generateThemeCss, resolveLight, resolveDark, applyThemeToElement, hexToHsl, hslToCss, invert, invertHex } from "./themes/index.js";
package/dist/index.js CHANGED
@@ -1,6 +1,9 @@
1
1
  // Global configuration
2
2
  export { initMultistyleUI } from "./config.js";
3
3
 
4
+ // Theme system — structured config + CSS generator (runtime API for custom themes)
5
+ export { themes, generateThemeCss, resolveLight, resolveDark, applyThemeToElement, hexToHsl, hslToCss, invert, invertHex } from "./themes/index.js";
6
+
4
7
  // Actions
5
8
  export { portal } from "./actions/portal.js";
6
9
 
@@ -0,0 +1,52 @@
1
+ /**
2
+ * @typedef {Object} Hsl
3
+ * @property {number} h hue 0..360
4
+ * @property {number} s saturation 0..100
5
+ * @property {number} l lightness 0..100
6
+ */
7
+ /**
8
+ * Convert a hex color string to HSL.
9
+ * Accepts #rgb, #rgba, #rrggbb, #rrggbbaa (alpha ignored).
10
+ * @param {string} hex
11
+ * @returns {Hsl}
12
+ */
13
+ export function hexToHsl(hex: string): Hsl;
14
+ /**
15
+ * Format an Hsl object as a css hsl() string.
16
+ * @param {Hsl} hsl
17
+ * @returns {string}
18
+ */
19
+ export function hslToCss({ h, s, l }: Hsl): string;
20
+ /**
21
+ * Invert an Hsl color for dark-mode derivation. Lightness is flipped
22
+ * (l -> 100 - l) then lifted by `lift` (default 20) so a light surface (e.g.
23
+ * white, l=100) does not collapse to pure black (0%) — it lands at ~20% (a
24
+ * dark gray). A smaller lift yields a darker result (surfaces), a larger lift
25
+ * yields a lighter result (text). Result clamped to [0, 100].
26
+ * Hue and saturation kept.
27
+ * @param {Hsl} hsl
28
+ * @param {number} [lift=20]
29
+ * @returns {Hsl}
30
+ */
31
+ export function invert(hsl: Hsl, lift?: number): Hsl;
32
+ /**
33
+ * Invert a hex color and return a css hsl() string.
34
+ * @param {string} hex
35
+ * @param {number} [lift=20]
36
+ * @returns {string}
37
+ */
38
+ export function invertHex(hex: string, lift?: number): string;
39
+ export type Hsl = {
40
+ /**
41
+ * hue 0..360
42
+ */
43
+ h: number;
44
+ /**
45
+ * saturation 0..100
46
+ */
47
+ s: number;
48
+ /**
49
+ * lightness 0..100
50
+ */
51
+ l: number;
52
+ };
@@ -0,0 +1,91 @@
1
+ /* ===== Color helpers =====
2
+ * Pure JS (no Svelte) so this runs in Node (build script) and the browser
3
+ * (App.svelte live preview). Used by generator.js to derive dark-mode colors
4
+ * via HSL lightness inversion: hsl(h, s, calc(100% - l)).
5
+ */
6
+
7
+ /**
8
+ * @typedef {Object} Hsl
9
+ * @property {number} h hue 0..360
10
+ * @property {number} s saturation 0..100
11
+ * @property {number} l lightness 0..100
12
+ */
13
+
14
+ /**
15
+ * Convert a hex color string to HSL.
16
+ * Accepts #rgb, #rgba, #rrggbb, #rrggbbaa (alpha ignored).
17
+ * @param {string} hex
18
+ * @returns {Hsl}
19
+ */
20
+ export function hexToHsl(hex) {
21
+ const m = String(hex).replace("#", "").trim();
22
+ let r, g, b;
23
+ if (m.length === 3 || m.length === 4) {
24
+ r = parseInt(m[0] + m[0], 16);
25
+ g = parseInt(m[1] + m[1], 16);
26
+ b = parseInt(m[2] + m[2], 16);
27
+ } else {
28
+ r = parseInt(m.slice(0, 2), 16);
29
+ g = parseInt(m.slice(2, 4), 16);
30
+ b = parseInt(m.slice(4, 6), 16);
31
+ }
32
+ r /= 255;
33
+ g /= 255;
34
+ b /= 255;
35
+ const max = Math.max(r, g, b);
36
+ const min = Math.min(r, g, b);
37
+ const l = (max + min) / 2;
38
+ let h = 0;
39
+ let s = 0;
40
+ if (max !== min) {
41
+ const d = max - min;
42
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
43
+ switch (max) {
44
+ case r:
45
+ h = (g - b) / d + (g < b ? 6 : 0);
46
+ break;
47
+ case g:
48
+ h = (b - r) / d + 2;
49
+ break;
50
+ default:
51
+ h = (r - g) / d + 4;
52
+ }
53
+ h *= 60;
54
+ }
55
+ return { h: Math.round(h), s: Math.round(s * 100), l: Math.round(l * 100) };
56
+ }
57
+
58
+ /**
59
+ * Format an Hsl object as a css hsl() string.
60
+ * @param {Hsl} hsl
61
+ * @returns {string}
62
+ */
63
+ export function hslToCss({ h, s, l }) {
64
+ return `hsl(${Math.round(h)}, ${Math.round(s)}%, ${Math.round(l)}%)`;
65
+ }
66
+
67
+ /**
68
+ * Invert an Hsl color for dark-mode derivation. Lightness is flipped
69
+ * (l -> 100 - l) then lifted by `lift` (default 20) so a light surface (e.g.
70
+ * white, l=100) does not collapse to pure black (0%) — it lands at ~20% (a
71
+ * dark gray). A smaller lift yields a darker result (surfaces), a larger lift
72
+ * yields a lighter result (text). Result clamped to [0, 100].
73
+ * Hue and saturation kept.
74
+ * @param {Hsl} hsl
75
+ * @param {number} [lift=20]
76
+ * @returns {Hsl}
77
+ */
78
+ export function invert(hsl, lift = 20) {
79
+ const l = Math.min(100, Math.max(0, 100 - hsl.l + lift));
80
+ return { h: hsl.h, s: hsl.s, l };
81
+ }
82
+
83
+ /**
84
+ * Invert a hex color and return a css hsl() string.
85
+ * @param {string} hex
86
+ * @param {number} [lift=20]
87
+ * @returns {string}
88
+ */
89
+ export function invertHex(hex, lift = 20) {
90
+ return hslToCss(invert(hexToHsl(hex), lift));
91
+ }
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Resolve the light-mode token map for a config.
3
+ * @param {object} c theme config
4
+ * @returns {Record<string, string>}
5
+ */
6
+ export function resolveLight(c: object): Record<string, string>;
7
+ /**
8
+ * Resolve the dark-mode token map. null dark fields are HSL-inverted from
9
+ * their light counterpart; explicit (non-null) values win.
10
+ *
11
+ * Only dark-specific tokens are emitted (text, surface, cardSurface + their
12
+ * derivations). Common tokens (primary, status colors, radii, border-width,
13
+ * text-on-primary, btn-bg, brand/status text) are NOT re-emitted — they
14
+ * inherit from the `.theme-<name>` light block on the same element. This keeps
15
+ * the dark block small and avoids restating values that do not change.
16
+ * @param {object} c theme config
17
+ * @returns {Record<string, string>}
18
+ */
19
+ export function resolveDark(c: object): Record<string, string>;
20
+ /**
21
+ * Generate the `.theme-<name>` and `html.dark .theme-<name>` CSS rules.
22
+ * @param {string} name theme name
23
+ * @param {object} config { common, light, dark }
24
+ * @param {{ light?: object, dark?: object }|null} [override] style-override layer
25
+ * @returns {{ light: string, dark: string }}
26
+ */
27
+ export function generateThemeCss(name: string, config: object, override?: {
28
+ light?: object;
29
+ dark?: object;
30
+ } | null): {
31
+ light: string;
32
+ dark: string;
33
+ };
34
+ /**
35
+ * Apply a theme config's CSS vars directly to a DOM element (live preview).
36
+ * Sets every resolved token; clears any previously-set --t-* var not in the new map.
37
+ * @param {HTMLElement} el
38
+ * @param {object} config { common, light, dark }
39
+ * @param {boolean} isDark
40
+ */
41
+ export function applyThemeToElement(el: HTMLElement, config: object, isDark: boolean): void;
@@ -0,0 +1,174 @@
1
+ /* ===== Theme CSS generator =====
2
+ * Pure JS (no Svelte). Produces `.theme-<name>` (light) and
3
+ * `html.dark .theme-<name>` (dark) CSS rule bodies from a structured config.
4
+ *
5
+ * Config shape (only these fields are configurable; everything else is derived):
6
+ * common: { primary, secondary, info, success, warning, error, textOnPrimary,
7
+ * buttonRadius, cardRadius, inputRadius, borderWidth }
8
+ * light: { text, surface, cardSurface } // all required hex
9
+ * dark: { text, surface, cardSurface } // null = HSL-invert from light
10
+ *
11
+ * Derived (NOT configurable):
12
+ * --t-text-hint / --t-text-muted / --t-text-disabled = 50% transparency of --t-text
13
+ * --t-text-primary = primary, --t-text-secondary = secondary,
14
+ * --t-text-info/success/warning/error = info/success/warning/error
15
+ * --t-card-bg = surface, --t-card-border-color = mix(text 14%, surface),
16
+ * --t-surface-bg = mix(surface 85%, #000), --t-btn-bg = primary
17
+ */
18
+
19
+ import { invertHex } from "./color.js";
20
+
21
+ /** Stable output order so generated theme.css is byte-stable across runs. */
22
+ const TOKEN_ORDER = [
23
+ "--t-primary", "--t-secondary", "--t-info", "--t-success", "--t-warning", "--t-error",
24
+ "--t-text-on-primary",
25
+ "--t-surface", "--t-card-bg", "--t-card-surface", "--t-card-border-color", "--t-surface-bg",
26
+ "--t-text", "--t-text-hint", "--t-text-muted", "--t-text-disabled",
27
+ "--t-text-primary", "--t-text-secondary",
28
+ "--t-text-info", "--t-text-success", "--t-text-warning", "--t-text-error",
29
+ "--t-btn-bg", "--t-btn-border-color", "--t-btn-radius", "--t-card-radius", "--t-input-radius",
30
+ "--t-border-width",
31
+ ];
32
+
33
+ /** 50% transparency of a text color css string. */
34
+ function hintOf(textCss) {
35
+ return `color-mix(in srgb, ${textCss} 50%, transparent)`;
36
+ }
37
+
38
+ /**
39
+ * Resolve the light-mode token map for a config.
40
+ * @param {object} c theme config
41
+ * @returns {Record<string, string>}
42
+ */
43
+ export function resolveLight(c) {
44
+ const { common: cm, light: l } = c;
45
+ return {
46
+ "--t-primary": cm.primary,
47
+ "--t-secondary": cm.secondary,
48
+ "--t-info": cm.info,
49
+ "--t-success": cm.success,
50
+ "--t-warning": cm.warning,
51
+ "--t-error": cm.error,
52
+ "--t-text-on-primary": cm.textOnPrimary,
53
+ "--t-btn-radius": cm.buttonRadius,
54
+ "--t-card-radius": cm.cardRadius,
55
+ "--t-input-radius": cm.inputRadius,
56
+ "--t-border-width": cm.borderWidth,
57
+ "--t-btn-bg": cm.primary,
58
+ "--t-btn-border-color": "transparent",
59
+ "--t-text": l.text,
60
+ "--t-surface": l.surface,
61
+ "--t-card-surface": l.cardSurface,
62
+ "--t-card-bg": l.surface,
63
+ "--t-card-border-color": `color-mix(in srgb, ${l.text} 14%, ${l.surface})`,
64
+ "--t-surface-bg": `color-mix(in srgb, ${l.surface} 85%, #000)`,
65
+ "--t-text-primary": cm.primary,
66
+ "--t-text-secondary": cm.secondary,
67
+ "--t-text-info": cm.info,
68
+ "--t-text-success": cm.success,
69
+ "--t-text-warning": cm.warning,
70
+ "--t-text-error": cm.error,
71
+ // --t-text-hint / --t-text-muted / --t-text-disabled MUST be emitted here,
72
+ // not left to theme-base.css. A color-mix() custom property bakes at the
73
+ // declaring element using THAT element's --t-text; the :root derivation
74
+ // bakes with :root's (light) text and is inherited as a fixed dark color,
75
+ // so it never follows --t-text when a theme/style/dark block changes it.
76
+ // Emitting per mode re-bakes with the correct (light or dark) text.
77
+ "--t-text-hint": hintOf(l.text),
78
+ "--t-text-muted": hintOf(l.text),
79
+ "--t-text-disabled": hintOf(l.text),
80
+ };
81
+ }
82
+
83
+ /**
84
+ * Resolve the dark-mode token map. null dark fields are HSL-inverted from
85
+ * their light counterpart; explicit (non-null) values win.
86
+ *
87
+ * Only dark-specific tokens are emitted (text, surface, cardSurface + their
88
+ * derivations). Common tokens (primary, status colors, radii, border-width,
89
+ * text-on-primary, btn-bg, brand/status text) are NOT re-emitted — they
90
+ * inherit from the `.theme-<name>` light block on the same element. This keeps
91
+ * the dark block small and avoids restating values that do not change.
92
+ * @param {object} c theme config
93
+ * @returns {Record<string, string>}
94
+ */
95
+ export function resolveDark(c) {
96
+ const { light: l, dark: d } = c;
97
+ // Text lifts high (stays light); surfaces lift low (stay darker than text).
98
+ const darkText = d.text ?? invertHex(l.text, 20);
99
+ const darkSurface = d.surface ?? invertHex(l.surface, 10);
100
+ const darkCard = d.cardSurface ?? invertHex(l.cardSurface, 14);
101
+ return {
102
+ "--t-text": darkText,
103
+ "--t-surface": darkSurface,
104
+ "--t-card-surface": darkCard,
105
+ "--t-card-bg": darkSurface,
106
+ "--t-card-border-color": `color-mix(in srgb, ${darkText} 14%, ${darkSurface})`,
107
+ "--t-surface-bg": `color-mix(in srgb, ${darkSurface} 85%, #000)`,
108
+ // Re-bake the hint/muted/disabled derivations with the DARK text so they
109
+ // stay light in dark mode (see resolveLight comment for the baking rule).
110
+ "--t-text-hint": hintOf(darkText),
111
+ "--t-text-muted": hintOf(darkText),
112
+ "--t-text-disabled": hintOf(darkText),
113
+ };
114
+ }
115
+
116
+ /** Emit a token map as indented `--t-*: value;` lines, in TOKEN_ORDER, skipping null. */
117
+ function emit(map) {
118
+ return TOKEN_ORDER
119
+ .filter((k) => map[k] != null)
120
+ .map((k) => ` ${k}: ${map[k]};`)
121
+ .join("\n");
122
+ }
123
+
124
+ /**
125
+ * Merge a style-override layer onto a base token map.
126
+ * override value === null -> drop that token (preserve the style's own value);
127
+ * non-null -> overwrite. Used for per-style null opt-outs (e.g. liquid-glass).
128
+ * @param {Record<string,string>} base
129
+ * @param {Record<string, string|null>|null} override
130
+ * @returns {Record<string,string>}
131
+ */
132
+ function mergeLayer(base, override) {
133
+ if (!override) return base;
134
+ const out = { ...base };
135
+ for (const [k, v] of Object.entries(override)) {
136
+ if (v == null) delete out[k];
137
+ else out[k] = v;
138
+ }
139
+ return out;
140
+ }
141
+
142
+ /**
143
+ * Generate the `.theme-<name>` and `html.dark .theme-<name>` CSS rules.
144
+ * @param {string} name theme name
145
+ * @param {object} config { common, light, dark }
146
+ * @param {{ light?: object, dark?: object }|null} [override] style-override layer
147
+ * @returns {{ light: string, dark: string }}
148
+ */
149
+ export function generateThemeCss(name, config, override = null) {
150
+ const lightMap = mergeLayer(resolveLight(config), override?.light);
151
+ const darkMap = mergeLayer(resolveDark(config), override?.dark);
152
+ const light = `.theme-${name} {\n${emit(lightMap)}\n}`;
153
+ const dark = `html.dark .theme-${name} {\n${emit(darkMap)}\n}`;
154
+ return { light, dark };
155
+ }
156
+
157
+ /**
158
+ * Apply a theme config's CSS vars directly to a DOM element (live preview).
159
+ * Sets every resolved token; clears any previously-set --t-* var not in the new map.
160
+ * @param {HTMLElement} el
161
+ * @param {object} config { common, light, dark }
162
+ * @param {boolean} isDark
163
+ */
164
+ export function applyThemeToElement(el, config, isDark) {
165
+ const map = isDark ? resolveDark(config) : resolveLight(config);
166
+ // clear stale --t-* vars set by a previous apply
167
+ for (let i = el.style.length - 1; i >= 0; i--) {
168
+ const prop = el.style[i];
169
+ if (prop.startsWith("--t-")) el.style.removeProperty(prop);
170
+ }
171
+ for (const [k, v] of Object.entries(map)) {
172
+ if (v != null) el.style.setProperty(k, v);
173
+ }
174
+ }
@@ -0,0 +1,3 @@
1
+ export { themes, DEFAULT, ocean, forest, rose, midnight, gold, slate, candy, storm, royal } from "./presets.js";
2
+ export { generateThemeCss, resolveLight, resolveDark, applyThemeToElement } from "./generator.js";
3
+ export { hexToHsl, hslToCss, invert, invertHex } from "./color.js";
@@ -0,0 +1,4 @@
1
+ /* ===== Public theme API ===== */
2
+ export { themes, DEFAULT, ocean, forest, rose, midnight, gold, slate, candy, storm, royal } from "./presets.js";
3
+ export { generateThemeCss, resolveLight, resolveDark, applyThemeToElement } from "./generator.js";
4
+ export { hexToHsl, hslToCss, invert, invertHex } from "./color.js";