@shohojdhara/atomix 0.3.0 → 0.3.1
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/dist/atomix.css +309 -105
- package/dist/atomix.min.css +3 -5
- package/dist/index.d.ts +804 -53
- package/dist/index.esm.js +16367 -16413
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16275 -16336
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/themes/applemix.css +309 -105
- package/dist/themes/applemix.min.css +5 -7
- package/dist/themes/boomdevs.css +202 -10
- package/dist/themes/boomdevs.min.css +3 -5
- package/dist/themes/esrar.css +309 -105
- package/dist/themes/esrar.min.css +4 -6
- package/dist/themes/flashtrade.css +310 -105
- package/dist/themes/flashtrade.min.css +5 -7
- package/dist/themes/mashroom.css +300 -96
- package/dist/themes/mashroom.min.css +4 -6
- package/dist/themes/shaj-default.css +300 -96
- package/dist/themes/shaj-default.min.css +4 -6
- package/package.json +1 -1
- package/src/components/AtomixGlass/AtomixGlass.test.tsx +21 -32
- package/src/components/AtomixGlass/AtomixGlass.tsx +55 -42
- package/src/components/AtomixGlass/AtomixGlassContainer.tsx +205 -57
- package/src/components/AtomixGlass/GlassFilter.tsx +22 -8
- package/src/components/AtomixGlass/__snapshots__/AtomixGlass.test.tsx.snap +221 -0
- package/src/components/AtomixGlass/atomixGLass.old.tsx +0 -3
- package/src/components/AtomixGlass/shader-utils.ts +8 -0
- package/src/components/AtomixGlass/stories/AtomixGlass.stories.tsx +319 -100
- package/src/components/AtomixGlass/stories/Examples.stories.tsx +601 -105
- package/src/components/AtomixGlass/stories/Modes.stories.tsx +30 -12
- package/src/components/AtomixGlass/stories/Playground.stories.tsx +173 -38
- package/src/components/AtomixGlass/stories/ShaderVariants.stories.tsx +18 -18
- package/src/components/AtomixGlass/stories/shared-components.tsx +27 -5
- package/src/components/Button/Button.tsx +62 -17
- package/src/components/Callout/Callout.test.tsx +8 -14
- package/src/components/Card/Card.tsx +103 -1
- package/src/components/Card/index.ts +3 -2
- package/src/components/Icon/index.ts +1 -1
- package/src/components/Modal/Modal.stories.tsx +29 -38
- package/src/components/Modal/Modal.tsx +4 -4
- package/src/components/Navigation/SideMenu/SideMenu.tsx +49 -41
- package/src/components/Navigation/SideMenu/SideMenuItem.tsx +63 -24
- package/src/components/Popover/Popover.tsx +1 -1
- package/src/components/VideoPlayer/VideoPlayer.stories.tsx +977 -400
- package/src/components/VideoPlayer/VideoPlayer.tsx +1 -6
- package/src/lib/composables/shared-mouse-tracker.ts +133 -0
- package/src/lib/composables/useAtomixGlass.ts +303 -115
- package/src/lib/theme/ThemeManager.integration.test.ts +124 -0
- package/src/lib/theme/ThemeManager.stories.tsx +13 -13
- package/src/lib/theme/ThemeManager.test.ts +4 -0
- package/src/lib/theme/ThemeManager.ts +203 -59
- package/src/lib/theme/ThemeProvider.tsx +183 -33
- package/src/lib/theme/composeTheme.ts +375 -0
- package/src/lib/theme/createTheme.test.ts +475 -0
- package/src/lib/theme/createTheme.ts +510 -0
- package/src/lib/theme/generateCSSVariables.ts +713 -0
- package/src/lib/theme/index.ts +67 -0
- package/src/lib/theme/themeUtils.ts +333 -0
- package/src/lib/theme/types.ts +337 -8
- package/src/lib/theme/useTheme.test.tsx +2 -1
- package/src/lib/theme/useTheme.ts +6 -22
- package/src/lib/types/components.ts +148 -59
- package/src/styles/01-settings/_index.scss +2 -2
- package/src/styles/01-settings/_settings.badge.scss +2 -2
- package/src/styles/01-settings/_settings.border-radius.scss +1 -1
- package/src/styles/01-settings/{_settings.maps.scss → _settings.design-tokens.scss} +163 -49
- package/src/styles/01-settings/_settings.modal.scss +1 -1
- package/src/styles/01-settings/_settings.spacing.scss +14 -13
- package/src/styles/03-generic/_generic.root.scss +131 -50
- package/src/styles/05-objects/_objects.block.scss +1 -1
- package/src/styles/06-components/_components.atomix-glass.scss +20 -22
- package/src/styles/06-components/_components.badge.scss +2 -2
- package/src/styles/06-components/_components.button.scss +1 -1
- package/src/styles/06-components/_components.callout.scss +1 -1
- package/src/styles/06-components/_components.card.scss +74 -2
- package/src/styles/06-components/_components.chart.scss +1 -1
- package/src/styles/06-components/_components.dropdown.scss +6 -0
- package/src/styles/06-components/_components.footer.scss +1 -1
- package/src/styles/06-components/_components.list-group.scss +1 -1
- package/src/styles/06-components/_components.list.scss +1 -1
- package/src/styles/06-components/_components.menu.scss +1 -1
- package/src/styles/06-components/_components.messages.scss +1 -1
- package/src/styles/06-components/_components.modal.scss +7 -2
- package/src/styles/06-components/_components.navbar.scss +1 -1
- package/src/styles/06-components/_components.popover.scss +10 -0
- package/src/styles/06-components/_components.product-review.scss +1 -1
- package/src/styles/06-components/_components.progress.scss +1 -1
- package/src/styles/06-components/_components.rating.scss +1 -1
- package/src/styles/06-components/_components.spinner.scss +1 -1
- package/src/styles/99-utilities/_utilities.background.scss +1 -1
- package/src/styles/99-utilities/_utilities.border.scss +1 -1
- package/src/styles/99-utilities/_utilities.link.scss +1 -1
- package/src/styles/99-utilities/_utilities.text.scss +1 -1
package/src/lib/theme/types.ts
CHANGED
|
@@ -48,7 +48,7 @@ export interface ThemeManagerConfig {
|
|
|
48
48
|
/** Available themes metadata */
|
|
49
49
|
themes: Record<string, ThemeMetadata>;
|
|
50
50
|
/** Default theme to use */
|
|
51
|
-
defaultTheme?: string;
|
|
51
|
+
defaultTheme?: string | Theme;
|
|
52
52
|
/** Base path for theme CSS files */
|
|
53
53
|
basePath?: string;
|
|
54
54
|
/** CDN path for theme CSS files (optional) */
|
|
@@ -68,7 +68,7 @@ export interface ThemeManagerConfig {
|
|
|
68
68
|
/** Use minified CSS files */
|
|
69
69
|
useMinified?: boolean;
|
|
70
70
|
/** Callback when theme changes */
|
|
71
|
-
onThemeChange?: (theme: string) => void;
|
|
71
|
+
onThemeChange?: (theme: string | Theme) => void;
|
|
72
72
|
/** Callback when theme load fails */
|
|
73
73
|
onError?: (error: Error, themeName: string) => void;
|
|
74
74
|
}
|
|
@@ -81,6 +81,8 @@ export interface ThemeChangeEvent {
|
|
|
81
81
|
previousTheme: string | null;
|
|
82
82
|
/** New theme name */
|
|
83
83
|
currentTheme: string;
|
|
84
|
+
/** Theme object (for JS themes) */
|
|
85
|
+
themeObject?: Theme | null;
|
|
84
86
|
/** Timestamp of the change */
|
|
85
87
|
timestamp: number;
|
|
86
88
|
/** Whether the change was from user action or system */
|
|
@@ -155,7 +157,7 @@ export interface UseThemeOptions {
|
|
|
155
157
|
/** Custom storage key */
|
|
156
158
|
storageKey?: string;
|
|
157
159
|
/** Callback when theme changes */
|
|
158
|
-
onChange?: (theme: string) => void;
|
|
160
|
+
onChange?: (theme: string | Theme) => void;
|
|
159
161
|
}
|
|
160
162
|
|
|
161
163
|
/**
|
|
@@ -164,8 +166,10 @@ export interface UseThemeOptions {
|
|
|
164
166
|
export interface UseThemeReturn {
|
|
165
167
|
/** Current theme name */
|
|
166
168
|
theme: string;
|
|
169
|
+
/** Current active theme object (for JS themes) */
|
|
170
|
+
activeTheme: Theme | null;
|
|
167
171
|
/** Function to change theme */
|
|
168
|
-
setTheme: (theme: string, options?: ThemeLoadOptions) => Promise<void>;
|
|
172
|
+
setTheme: (theme: string | Theme, options?: ThemeLoadOptions) => Promise<void>;
|
|
169
173
|
/** Available themes */
|
|
170
174
|
availableThemes: ThemeMetadata[];
|
|
171
175
|
/** Whether a theme is currently loading */
|
|
@@ -185,7 +189,7 @@ export interface ThemeProviderProps {
|
|
|
185
189
|
/** Child components */
|
|
186
190
|
children: React.ReactNode;
|
|
187
191
|
/** Default theme */
|
|
188
|
-
defaultTheme?: string;
|
|
192
|
+
defaultTheme?: string | Theme;
|
|
189
193
|
/** Available themes */
|
|
190
194
|
themes?: Record<string, ThemeMetadata>;
|
|
191
195
|
/** Base path for theme CSS */
|
|
@@ -205,7 +209,7 @@ export interface ThemeProviderProps {
|
|
|
205
209
|
/** Use minified CSS */
|
|
206
210
|
useMinified?: boolean;
|
|
207
211
|
/** Callback when theme changes */
|
|
208
|
-
onThemeChange?: (theme: string) => void;
|
|
212
|
+
onThemeChange?: (theme: string | Theme) => void;
|
|
209
213
|
/** Callback on error */
|
|
210
214
|
onError?: (error: Error, themeName: string) => void;
|
|
211
215
|
}
|
|
@@ -214,10 +218,12 @@ export interface ThemeProviderProps {
|
|
|
214
218
|
* Theme context value
|
|
215
219
|
*/
|
|
216
220
|
export interface ThemeContextValue {
|
|
217
|
-
/** Current theme */
|
|
221
|
+
/** Current theme name */
|
|
218
222
|
theme: string;
|
|
223
|
+
/** Current active theme object (for JS themes) */
|
|
224
|
+
activeTheme: Theme | null;
|
|
219
225
|
/** Set theme function */
|
|
220
|
-
setTheme: (theme: string, options?: ThemeLoadOptions) => Promise<void>;
|
|
226
|
+
setTheme: (theme: string | Theme, options?: ThemeLoadOptions) => Promise<void>;
|
|
221
227
|
/** Available themes */
|
|
222
228
|
availableThemes: ThemeMetadata[];
|
|
223
229
|
/** Loading state */
|
|
@@ -232,6 +238,329 @@ export interface ThemeContextValue {
|
|
|
232
238
|
themeManager: ThemeManagerType;
|
|
233
239
|
}
|
|
234
240
|
|
|
241
|
+
// ============================================================================
|
|
242
|
+
// createTheme System Types
|
|
243
|
+
// ============================================================================
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Color palette configuration for a single color
|
|
247
|
+
*/
|
|
248
|
+
export interface PaletteColor {
|
|
249
|
+
/** Main color value */
|
|
250
|
+
main: string;
|
|
251
|
+
/** Light variant (auto-generated if not provided) */
|
|
252
|
+
light?: string;
|
|
253
|
+
/** Dark variant (auto-generated if not provided) */
|
|
254
|
+
dark?: string;
|
|
255
|
+
/** Contrast text color (auto-generated if not provided) */
|
|
256
|
+
contrastText?: string;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Palette configuration options for createTheme
|
|
261
|
+
*/
|
|
262
|
+
export interface PaletteOptions {
|
|
263
|
+
/** Primary color configuration */
|
|
264
|
+
primary?: Partial<PaletteColor> | string;
|
|
265
|
+
/** Secondary color configuration */
|
|
266
|
+
secondary?: Partial<PaletteColor> | string;
|
|
267
|
+
/** Error color configuration */
|
|
268
|
+
error?: Partial<PaletteColor> | string;
|
|
269
|
+
/** Warning color configuration */
|
|
270
|
+
warning?: Partial<PaletteColor> | string;
|
|
271
|
+
/** Info color configuration */
|
|
272
|
+
info?: Partial<PaletteColor> | string;
|
|
273
|
+
/** Success color configuration */
|
|
274
|
+
success?: Partial<PaletteColor> | string;
|
|
275
|
+
/** Background colors */
|
|
276
|
+
background?: {
|
|
277
|
+
default?: string;
|
|
278
|
+
paper?: string;
|
|
279
|
+
subtle?: string;
|
|
280
|
+
};
|
|
281
|
+
/** Text colors */
|
|
282
|
+
text?: {
|
|
283
|
+
primary?: string;
|
|
284
|
+
secondary?: string;
|
|
285
|
+
disabled?: string;
|
|
286
|
+
};
|
|
287
|
+
/** Additional custom colors */
|
|
288
|
+
[key: string]: any;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
/**
|
|
292
|
+
* Typography configuration options for createTheme
|
|
293
|
+
*/
|
|
294
|
+
export interface TypographyOptions {
|
|
295
|
+
/** Font family */
|
|
296
|
+
fontFamily?: string;
|
|
297
|
+
/** Base font size in pixels */
|
|
298
|
+
fontSize?: number;
|
|
299
|
+
/** Font weight scale */
|
|
300
|
+
fontWeightLight?: number;
|
|
301
|
+
fontWeightRegular?: number;
|
|
302
|
+
fontWeightMedium?: number;
|
|
303
|
+
fontWeightSemiBold?: number;
|
|
304
|
+
fontWeightBold?: number;
|
|
305
|
+
/** Heading configurations */
|
|
306
|
+
h1?: {
|
|
307
|
+
fontSize?: string | number;
|
|
308
|
+
fontWeight?: number;
|
|
309
|
+
lineHeight?: number | string;
|
|
310
|
+
letterSpacing?: string;
|
|
311
|
+
};
|
|
312
|
+
h2?: {
|
|
313
|
+
fontSize?: string | number;
|
|
314
|
+
fontWeight?: number;
|
|
315
|
+
lineHeight?: number | string;
|
|
316
|
+
letterSpacing?: string;
|
|
317
|
+
};
|
|
318
|
+
h3?: {
|
|
319
|
+
fontSize?: string | number;
|
|
320
|
+
fontWeight?: number;
|
|
321
|
+
lineHeight?: number | string;
|
|
322
|
+
letterSpacing?: string;
|
|
323
|
+
};
|
|
324
|
+
h4?: {
|
|
325
|
+
fontSize?: string | number;
|
|
326
|
+
fontWeight?: number;
|
|
327
|
+
lineHeight?: number | string;
|
|
328
|
+
letterSpacing?: string;
|
|
329
|
+
};
|
|
330
|
+
h5?: {
|
|
331
|
+
fontSize?: string | number;
|
|
332
|
+
fontWeight?: number;
|
|
333
|
+
lineHeight?: number | string;
|
|
334
|
+
letterSpacing?: string;
|
|
335
|
+
};
|
|
336
|
+
h6?: {
|
|
337
|
+
fontSize?: string | number;
|
|
338
|
+
fontWeight?: number;
|
|
339
|
+
lineHeight?: number | string;
|
|
340
|
+
letterSpacing?: string;
|
|
341
|
+
};
|
|
342
|
+
/** Body text configurations */
|
|
343
|
+
body1?: {
|
|
344
|
+
fontSize?: string | number;
|
|
345
|
+
fontWeight?: number;
|
|
346
|
+
lineHeight?: number | string;
|
|
347
|
+
};
|
|
348
|
+
body2?: {
|
|
349
|
+
fontSize?: string | number;
|
|
350
|
+
fontWeight?: number;
|
|
351
|
+
lineHeight?: number | string;
|
|
352
|
+
};
|
|
353
|
+
/** Additional custom typography */
|
|
354
|
+
[key: string]: any;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
/**
|
|
358
|
+
* Spacing function type
|
|
359
|
+
*/
|
|
360
|
+
export type SpacingFunction = (...values: number[]) => string;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* Spacing configuration options for createTheme
|
|
364
|
+
*/
|
|
365
|
+
export type SpacingOptions = number | number[] | SpacingFunction;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* Breakpoint values configuration
|
|
369
|
+
*/
|
|
370
|
+
export interface BreakpointValues {
|
|
371
|
+
xs?: number;
|
|
372
|
+
sm?: number;
|
|
373
|
+
md?: number;
|
|
374
|
+
lg?: number;
|
|
375
|
+
xl?: number;
|
|
376
|
+
[key: string]: number | undefined;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* Breakpoints configuration options for createTheme
|
|
381
|
+
*/
|
|
382
|
+
export interface BreakpointsOptions {
|
|
383
|
+
/** Breakpoint values in pixels */
|
|
384
|
+
values?: BreakpointValues;
|
|
385
|
+
/** Unit for breakpoints (default: 'px') */
|
|
386
|
+
unit?: string;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Shadow configuration
|
|
391
|
+
*/
|
|
392
|
+
export interface ShadowOptions {
|
|
393
|
+
xs?: string;
|
|
394
|
+
sm?: string;
|
|
395
|
+
md?: string;
|
|
396
|
+
lg?: string;
|
|
397
|
+
xl?: string;
|
|
398
|
+
[key: string]: string | undefined;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* Transition configuration
|
|
403
|
+
*/
|
|
404
|
+
export interface TransitionOptions {
|
|
405
|
+
/** Transition duration values */
|
|
406
|
+
duration?: {
|
|
407
|
+
shortest?: number;
|
|
408
|
+
shorter?: number;
|
|
409
|
+
short?: number;
|
|
410
|
+
standard?: number;
|
|
411
|
+
complex?: number;
|
|
412
|
+
enteringScreen?: number;
|
|
413
|
+
leavingScreen?: number;
|
|
414
|
+
};
|
|
415
|
+
/** Easing functions */
|
|
416
|
+
easing?: {
|
|
417
|
+
easeInOut?: string;
|
|
418
|
+
easeOut?: string;
|
|
419
|
+
easeIn?: string;
|
|
420
|
+
sharp?: string;
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Z-index configuration
|
|
426
|
+
*/
|
|
427
|
+
export interface ZIndexOptions {
|
|
428
|
+
mobileStepper?: number;
|
|
429
|
+
speedDial?: number;
|
|
430
|
+
appBar?: number;
|
|
431
|
+
drawer?: number;
|
|
432
|
+
modal?: number;
|
|
433
|
+
snackbar?: number;
|
|
434
|
+
tooltip?: number;
|
|
435
|
+
[key: string]: number | undefined;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Border radius configuration
|
|
440
|
+
*/
|
|
441
|
+
export interface BorderRadiusOptions {
|
|
442
|
+
/** Base border radius */
|
|
443
|
+
base?: string | number;
|
|
444
|
+
/** Small border radius */
|
|
445
|
+
sm?: string | number;
|
|
446
|
+
/** Medium border radius */
|
|
447
|
+
md?: string | number;
|
|
448
|
+
/** Large border radius */
|
|
449
|
+
lg?: string | number;
|
|
450
|
+
/** Extra large border radius */
|
|
451
|
+
xl?: string | number;
|
|
452
|
+
/** 2X large border radius */
|
|
453
|
+
xxl?: string | number;
|
|
454
|
+
/** 3X large border radius */
|
|
455
|
+
'3xl'?: string | number;
|
|
456
|
+
/** 4X large border radius */
|
|
457
|
+
'4xl'?: string | number;
|
|
458
|
+
/** Pill shape (fully rounded) */
|
|
459
|
+
pill?: string | number;
|
|
460
|
+
[key: string]: string | number | undefined;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Custom theme properties for extension
|
|
465
|
+
* Users can augment this interface via module augmentation
|
|
466
|
+
*/
|
|
467
|
+
export interface ThemeCustomProperties {
|
|
468
|
+
[key: string]: any;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Theme configuration options for createTheme
|
|
473
|
+
* Extends ThemeMetadata to support both CSS and JS theme properties
|
|
474
|
+
*/
|
|
475
|
+
export interface ThemeOptions extends Partial<ThemeMetadata> {
|
|
476
|
+
/** Color palette configuration */
|
|
477
|
+
palette?: PaletteOptions;
|
|
478
|
+
/** Typography configuration */
|
|
479
|
+
typography?: TypographyOptions;
|
|
480
|
+
/** Spacing configuration */
|
|
481
|
+
spacing?: SpacingOptions;
|
|
482
|
+
/** Breakpoints configuration */
|
|
483
|
+
breakpoints?: BreakpointsOptions;
|
|
484
|
+
/** Shadow configuration */
|
|
485
|
+
shadows?: ShadowOptions;
|
|
486
|
+
/** Transition configuration */
|
|
487
|
+
transitions?: TransitionOptions;
|
|
488
|
+
/** Z-index configuration */
|
|
489
|
+
zIndex?: ZIndexOptions;
|
|
490
|
+
/** Border radius configuration */
|
|
491
|
+
borderRadius?: BorderRadiusOptions;
|
|
492
|
+
/** Custom properties */
|
|
493
|
+
custom?: ThemeCustomProperties;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* Complete theme object with computed values
|
|
498
|
+
* Generated by createTheme function
|
|
499
|
+
*/
|
|
500
|
+
export interface Theme extends ThemeMetadata {
|
|
501
|
+
/** Color palette with computed values */
|
|
502
|
+
palette: {
|
|
503
|
+
primary: PaletteColor;
|
|
504
|
+
secondary: PaletteColor;
|
|
505
|
+
error: PaletteColor;
|
|
506
|
+
warning: PaletteColor;
|
|
507
|
+
info: PaletteColor;
|
|
508
|
+
success: PaletteColor;
|
|
509
|
+
background: {
|
|
510
|
+
default: string;
|
|
511
|
+
paper: string;
|
|
512
|
+
subtle: string;
|
|
513
|
+
};
|
|
514
|
+
text: {
|
|
515
|
+
primary: string;
|
|
516
|
+
secondary: string;
|
|
517
|
+
disabled: string;
|
|
518
|
+
};
|
|
519
|
+
[key: string]: any;
|
|
520
|
+
};
|
|
521
|
+
/** Typography with computed values */
|
|
522
|
+
typography: {
|
|
523
|
+
fontFamily: string;
|
|
524
|
+
fontSize: number;
|
|
525
|
+
fontWeightLight: number;
|
|
526
|
+
fontWeightRegular: number;
|
|
527
|
+
fontWeightMedium: number;
|
|
528
|
+
fontWeightSemiBold: number;
|
|
529
|
+
fontWeightBold: number;
|
|
530
|
+
h1: Required<NonNullable<TypographyOptions['h1']>>;
|
|
531
|
+
h2: Required<NonNullable<TypographyOptions['h2']>>;
|
|
532
|
+
h3: Required<NonNullable<TypographyOptions['h3']>>;
|
|
533
|
+
h4: Required<NonNullable<TypographyOptions['h4']>>;
|
|
534
|
+
h5: Required<NonNullable<TypographyOptions['h5']>>;
|
|
535
|
+
h6: Required<NonNullable<TypographyOptions['h6']>>;
|
|
536
|
+
body1: Required<NonNullable<TypographyOptions['body1']>>;
|
|
537
|
+
body2: Required<NonNullable<TypographyOptions['body2']>>;
|
|
538
|
+
[key: string]: any;
|
|
539
|
+
};
|
|
540
|
+
/** Spacing function */
|
|
541
|
+
spacing: SpacingFunction;
|
|
542
|
+
/** Breakpoints with computed values */
|
|
543
|
+
breakpoints: {
|
|
544
|
+
values: Required<BreakpointValues>;
|
|
545
|
+
unit: string;
|
|
546
|
+
up: (key: keyof BreakpointValues | number) => string;
|
|
547
|
+
down: (key: keyof BreakpointValues | number) => string;
|
|
548
|
+
between: (start: keyof BreakpointValues | number, end: keyof BreakpointValues | number) => string;
|
|
549
|
+
};
|
|
550
|
+
/** Shadows */
|
|
551
|
+
shadows: Required<ShadowOptions>;
|
|
552
|
+
/** Transitions */
|
|
553
|
+
transitions: Required<TransitionOptions>;
|
|
554
|
+
/** Z-index values */
|
|
555
|
+
zIndex: Required<ZIndexOptions>;
|
|
556
|
+
/** Border radius values */
|
|
557
|
+
borderRadius: Required<BorderRadiusOptions>;
|
|
558
|
+
/** Custom properties */
|
|
559
|
+
custom: ThemeCustomProperties;
|
|
560
|
+
/** Indicates this is a JS theme (not CSS-only) */
|
|
561
|
+
__isJSTheme: true;
|
|
562
|
+
}
|
|
563
|
+
|
|
235
564
|
/**
|
|
236
565
|
* Storage adapter interface for custom storage implementations
|
|
237
566
|
*/
|
|
@@ -12,6 +12,7 @@ describe('useTheme', () => {
|
|
|
12
12
|
|
|
13
13
|
const mockContextValue: ThemeContextValue = {
|
|
14
14
|
theme: 'default-theme',
|
|
15
|
+
activeTheme: null,
|
|
15
16
|
setTheme: mockSetTheme,
|
|
16
17
|
availableThemes: [{ name: 'Default', class: 'default-theme' }],
|
|
17
18
|
isLoading: false,
|
|
@@ -60,7 +61,7 @@ describe('useTheme', () => {
|
|
|
60
61
|
await result.current.setTheme('new-theme');
|
|
61
62
|
});
|
|
62
63
|
|
|
63
|
-
expect(mockSetTheme).toHaveBeenCalledWith('new-theme');
|
|
64
|
+
expect(mockSetTheme).toHaveBeenCalledWith('new-theme', undefined);
|
|
64
65
|
expect(onChangeSpy).toHaveBeenCalledWith('new-theme');
|
|
65
66
|
});
|
|
66
67
|
});
|
|
@@ -6,31 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
import { useContext, useCallback } from 'react';
|
|
8
8
|
import { ThemeContext } from './ThemeContext';
|
|
9
|
-
import type { UseThemeReturn, UseThemeOptions, ThemeLoadOptions } from './types';
|
|
9
|
+
import type { UseThemeReturn, UseThemeOptions, ThemeLoadOptions, Theme } from './types';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* useTheme hook
|
|
13
13
|
*
|
|
14
14
|
* Access theme context and manage theme state in React components.
|
|
15
15
|
* Must be used within a ThemeProvider.
|
|
16
|
-
*
|
|
17
|
-
* @param options - Hook options
|
|
18
|
-
* @returns Theme state and methods
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```tsx
|
|
22
|
-
* function ThemeSwitcher() {
|
|
23
|
-
* const { theme, setTheme, availableThemes, isLoading } = useTheme();
|
|
24
|
-
*
|
|
25
|
-
* return (
|
|
26
|
-
* <select value={theme} onChange={(e) => setTheme(e.target.value)}>
|
|
27
|
-
* {availableThemes.map(t => (
|
|
28
|
-
* <option key={t.class} value={t.class}>{t.name}</option>
|
|
29
|
-
* ))}
|
|
30
|
-
* </select>
|
|
31
|
-
* );
|
|
32
|
-
* }
|
|
33
|
-
* ```
|
|
34
16
|
*/
|
|
35
17
|
export const useTheme = (options: UseThemeOptions = {}): UseThemeReturn => {
|
|
36
18
|
const context = useContext(ThemeContext);
|
|
@@ -44,6 +26,7 @@ export const useTheme = (options: UseThemeOptions = {}): UseThemeReturn => {
|
|
|
44
26
|
|
|
45
27
|
const {
|
|
46
28
|
theme,
|
|
29
|
+
activeTheme,
|
|
47
30
|
setTheme: contextSetTheme,
|
|
48
31
|
availableThemes,
|
|
49
32
|
isLoading,
|
|
@@ -57,10 +40,10 @@ export const useTheme = (options: UseThemeOptions = {}): UseThemeReturn => {
|
|
|
57
40
|
|
|
58
41
|
// Wrap setTheme to call onChange callback if provided
|
|
59
42
|
const setTheme = useCallback(
|
|
60
|
-
async (
|
|
61
|
-
await contextSetTheme(
|
|
43
|
+
async (themeOrName: string | Theme, themeOptions?: ThemeLoadOptions): Promise<void> => {
|
|
44
|
+
await contextSetTheme(themeOrName, themeOptions);
|
|
62
45
|
if (onChange) {
|
|
63
|
-
onChange(
|
|
46
|
+
onChange(themeOrName);
|
|
64
47
|
}
|
|
65
48
|
},
|
|
66
49
|
[contextSetTheme, onChange]
|
|
@@ -68,6 +51,7 @@ export const useTheme = (options: UseThemeOptions = {}): UseThemeReturn => {
|
|
|
68
51
|
|
|
69
52
|
return {
|
|
70
53
|
theme,
|
|
54
|
+
activeTheme,
|
|
71
55
|
setTheme,
|
|
72
56
|
availableThemes,
|
|
73
57
|
isLoading,
|