@svadmin/core 0.56.0 → 0.57.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/package.json +1 -1
- package/src/theme.svelte.ts +31 -3
package/package.json
CHANGED
package/src/theme.svelte.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { definedOptions } from './defined-options';
|
|
|
6
6
|
// - 'dark-first': adds 'light' class for light mode (dark-first)
|
|
7
7
|
|
|
8
8
|
export type ThemeMode='light'|'dark'|'system';
|
|
9
|
-
export type ColorTheme='blue'|'green'|'rose'|'orange'|'violet'|'neutral';
|
|
9
|
+
export type ColorTheme='blue'|'green'|'rose'|'orange'|'violet'|'neutral'|'indigo'|'stripe';
|
|
10
10
|
|
|
11
11
|
/** Controls how the theme class is applied to <html> */
|
|
12
12
|
export type ThemeStrategy='standard'|'dark-first';
|
|
@@ -190,6 +190,29 @@ export const builtinPresets: Record<string,ColorPreset>=$state({
|
|
|
190
190
|
'--chart-1': 'oklch(0.65 0.25 293)',
|
|
191
191
|
},
|
|
192
192
|
},
|
|
193
|
+
stripe: {
|
|
194
|
+
name: 'stripe',
|
|
195
|
+
label: 'Stripe',
|
|
196
|
+
color: '#635bff',
|
|
197
|
+
light: {
|
|
198
|
+
'--primary': 'oklch(0.54 0.24 293)',
|
|
199
|
+
'--primary-foreground': 'oklch(0.99 0 0)',
|
|
200
|
+
'--ring': 'oklch(0.54 0.24 293)',
|
|
201
|
+
'--sidebar-primary': 'oklch(0.54 0.24 293)',
|
|
202
|
+
'--sidebar-primary-foreground': 'oklch(0.99 0 0)',
|
|
203
|
+
'--sidebar-ring': 'oklch(0.54 0.24 293)',
|
|
204
|
+
'--chart-1': 'oklch(0.54 0.24 293)',
|
|
205
|
+
},
|
|
206
|
+
dark: {
|
|
207
|
+
'--primary': 'oklch(0.72 0.19 293)',
|
|
208
|
+
'--primary-foreground': 'oklch(0.16 0.02 270)',
|
|
209
|
+
'--ring': 'oklch(0.72 0.19 293)',
|
|
210
|
+
'--sidebar-primary': 'oklch(0.72 0.19 293)',
|
|
211
|
+
'--sidebar-primary-foreground': 'oklch(0.16 0.02 270)',
|
|
212
|
+
'--sidebar-ring': 'oklch(0.72 0.19 293)',
|
|
213
|
+
'--chart-1': 'oklch(0.72 0.19 293)',
|
|
214
|
+
},
|
|
215
|
+
},
|
|
193
216
|
});
|
|
194
217
|
|
|
195
218
|
/** Register a custom color preset. Overwrites any built-in preset with the same name. */
|
|
@@ -297,7 +320,8 @@ function readStoredTheme(): ThemeMode|undefined {
|
|
|
297
320
|
|
|
298
321
|
function readStoredColorTheme(): ColorTheme {
|
|
299
322
|
const stored=getStorage()?.getItem(COLOR_STORAGE_KEY);
|
|
300
|
-
|
|
323
|
+
// Stripe is the product default; an existing persisted preset remains authoritative.
|
|
324
|
+
return stored&&builtinPresets[stored]? stored as ColorTheme:'stripe';
|
|
301
325
|
}
|
|
302
326
|
|
|
303
327
|
function persistSelection(key: string,value: string): void {
|
|
@@ -331,9 +355,10 @@ function clearAppliedArtifacts(): void {
|
|
|
331
355
|
removeCssProperties(activePresetVars);
|
|
332
356
|
activeCssOverrideVars=[];
|
|
333
357
|
activePresetVars=[];
|
|
334
|
-
root.classList.remove('layout-clean-flat','light','dark');
|
|
358
|
+
root.classList.remove('layout-clean-flat','light','dark','svadmin-theme-light','svadmin-theme-dark');
|
|
335
359
|
root.style.removeProperty('color-scheme');
|
|
336
360
|
root.removeAttribute('data-theme');
|
|
361
|
+
root.removeAttribute('data-theme-mode');
|
|
337
362
|
}
|
|
338
363
|
|
|
339
364
|
function applyThemeClasses(themeMode: ThemeMode,config: ThemeConfig): void {
|
|
@@ -350,6 +375,9 @@ function applyThemeClasses(themeMode: ThemeMode,config: ThemeConfig): void {
|
|
|
350
375
|
root.classList.toggle('dark',resolved==='dark');
|
|
351
376
|
root.classList.remove('light');
|
|
352
377
|
}
|
|
378
|
+
root.classList.toggle('svadmin-theme-light',resolved==='light');
|
|
379
|
+
root.classList.toggle('svadmin-theme-dark',resolved==='dark');
|
|
380
|
+
root.setAttribute('data-theme-mode',resolved);
|
|
353
381
|
|
|
354
382
|
if(!config.disableColorScheme) root.style.colorScheme=resolved;
|
|
355
383
|
}
|