@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.1.3 → 0.1.5

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 (164) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/index.d.ts +131 -131
  3. package/dist/index.esm.js +148 -148
  4. package/dist/index.js +148 -148
  5. package/dist/styles.css +1 -1
  6. package/package.json +1 -1
  7. package/src/components/ui/accessibility-demo.tsx +271 -0
  8. package/src/components/ui/advanced-component-architecture-demo.tsx +916 -0
  9. package/src/components/ui/advanced-transition-system-demo.tsx +670 -0
  10. package/src/components/ui/advanced-transition-system.tsx +395 -0
  11. package/src/components/ui/animation/animated-container.tsx +166 -0
  12. package/src/components/ui/animation/index.ts +19 -0
  13. package/src/components/ui/animation/staggered-container.tsx +68 -0
  14. package/src/components/ui/animation-demo.tsx +250 -0
  15. package/src/components/ui/badge.tsx +33 -0
  16. package/src/components/ui/battery-conscious-animation-demo.tsx +568 -0
  17. package/src/components/ui/border-radius-shadow-demo.tsx +187 -0
  18. package/src/components/ui/button.tsx +36 -0
  19. package/src/components/ui/card.tsx +207 -0
  20. package/src/components/ui/checkbox.tsx +30 -0
  21. package/src/components/ui/color-preview.tsx +411 -0
  22. package/src/components/ui/data-display/chart.tsx +653 -0
  23. package/src/components/ui/data-display/data-grid-simple.tsx +76 -0
  24. package/src/components/ui/data-display/data-grid.tsx +680 -0
  25. package/src/components/ui/data-display/list.tsx +456 -0
  26. package/src/components/ui/data-display/table.tsx +482 -0
  27. package/src/components/ui/data-display/timeline.tsx +441 -0
  28. package/src/components/ui/data-display/tree.tsx +602 -0
  29. package/src/components/ui/data-display/types.ts +536 -0
  30. package/src/components/ui/enterprise-mobile-experience-demo.tsx +749 -0
  31. package/src/components/ui/enterprise-mobile-experience.tsx +464 -0
  32. package/src/components/ui/feedback/alert.tsx +157 -0
  33. package/src/components/ui/feedback/progress.tsx +292 -0
  34. package/src/components/ui/feedback/skeleton.tsx +185 -0
  35. package/src/components/ui/feedback/toast.tsx +280 -0
  36. package/src/components/ui/feedback/types.ts +125 -0
  37. package/src/components/ui/font-preview.tsx +288 -0
  38. package/src/components/ui/form-demo.tsx +553 -0
  39. package/src/components/ui/hardware-acceleration-demo.tsx +547 -0
  40. package/src/components/ui/input.tsx +35 -0
  41. package/src/components/ui/label.tsx +16 -0
  42. package/src/components/ui/layout-demo.tsx +367 -0
  43. package/src/components/ui/layouts/adaptive-layout.tsx +139 -0
  44. package/src/components/ui/layouts/desktop-layout.tsx +224 -0
  45. package/src/components/ui/layouts/index.ts +10 -0
  46. package/src/components/ui/layouts/mobile-layout.tsx +162 -0
  47. package/src/components/ui/layouts/tablet-layout.tsx +197 -0
  48. package/src/components/ui/mobile-form-validation.tsx +451 -0
  49. package/src/components/ui/mobile-input-demo.tsx +201 -0
  50. package/src/components/ui/mobile-input.tsx +281 -0
  51. package/src/components/ui/mobile-skeleton-loading-demo.tsx +638 -0
  52. package/src/components/ui/navigation/breadcrumb.tsx +158 -0
  53. package/src/components/ui/navigation/index.ts +36 -0
  54. package/src/components/ui/navigation/menu.tsx +374 -0
  55. package/src/components/ui/navigation/navigation-demo.tsx +324 -0
  56. package/src/components/ui/navigation/pagination.tsx +272 -0
  57. package/src/components/ui/navigation/sidebar.tsx +383 -0
  58. package/src/components/ui/navigation/stepper.tsx +303 -0
  59. package/src/components/ui/navigation/tabs.tsx +205 -0
  60. package/src/components/ui/navigation/types.ts +299 -0
  61. package/src/components/ui/overlay/backdrop.tsx +81 -0
  62. package/src/components/ui/overlay/focus-manager.tsx +143 -0
  63. package/src/components/ui/overlay/index.ts +36 -0
  64. package/src/components/ui/overlay/modal.tsx +270 -0
  65. package/src/components/ui/overlay/overlay-manager.tsx +110 -0
  66. package/src/components/ui/overlay/popover.tsx +462 -0
  67. package/src/components/ui/overlay/portal.tsx +79 -0
  68. package/src/components/ui/overlay/tooltip.tsx +303 -0
  69. package/src/components/ui/overlay/types.ts +196 -0
  70. package/src/components/ui/performance-demo.tsx +596 -0
  71. package/src/components/ui/semantic-input-system-demo.tsx +502 -0
  72. package/src/components/ui/semantic-input-system-demo.tsx.disabled +873 -0
  73. package/src/components/ui/tablet-layout.tsx +192 -0
  74. package/src/components/ui/theme-customizer.tsx +386 -0
  75. package/src/components/ui/theme-preview.tsx +310 -0
  76. package/src/components/ui/theme-switcher.tsx +264 -0
  77. package/src/components/ui/theme-toggle.tsx +38 -0
  78. package/src/components/ui/token-demo.tsx +195 -0
  79. package/src/components/ui/touch-demo.tsx +462 -0
  80. package/src/components/ui/touch-friendly-interface-demo.tsx +519 -0
  81. package/src/components/ui/touch-friendly-interface.tsx +296 -0
  82. package/src/hooks/index.ts +190 -0
  83. package/src/hooks/use-accessibility-support.ts +518 -0
  84. package/src/hooks/use-adaptive-layout.ts +289 -0
  85. package/src/hooks/use-advanced-patterns.ts +294 -0
  86. package/src/hooks/use-advanced-transition-system.ts +393 -0
  87. package/src/hooks/use-animation-profile.ts +288 -0
  88. package/src/hooks/use-battery-animations.ts +384 -0
  89. package/src/hooks/use-battery-conscious-loading.ts +475 -0
  90. package/src/hooks/use-battery-optimization.ts +330 -0
  91. package/src/hooks/use-battery-status.ts +299 -0
  92. package/src/hooks/use-component-performance.ts +344 -0
  93. package/src/hooks/use-device-loading-states.ts +459 -0
  94. package/src/hooks/use-device.tsx +110 -0
  95. package/src/hooks/use-enterprise-mobile-experience.ts +488 -0
  96. package/src/hooks/use-form-feedback.ts +403 -0
  97. package/src/hooks/use-form-performance.ts +513 -0
  98. package/src/hooks/use-frame-rate.ts +251 -0
  99. package/src/hooks/use-gestures.ts +338 -0
  100. package/src/hooks/use-hardware-acceleration.ts +341 -0
  101. package/src/hooks/use-input-accessibility.ts +455 -0
  102. package/src/hooks/use-input-performance.ts +506 -0
  103. package/src/hooks/use-layout-performance.ts +319 -0
  104. package/src/hooks/use-loading-accessibility.ts +535 -0
  105. package/src/hooks/use-loading-performance.ts +473 -0
  106. package/src/hooks/use-memory-usage.ts +287 -0
  107. package/src/hooks/use-mobile-form-layout.ts +464 -0
  108. package/src/hooks/use-mobile-form-validation.ts +518 -0
  109. package/src/hooks/use-mobile-keyboard-optimization.ts +472 -0
  110. package/src/hooks/use-mobile-layout.ts +302 -0
  111. package/src/hooks/use-mobile-optimization.ts +406 -0
  112. package/src/hooks/use-mobile-skeleton.ts +402 -0
  113. package/src/hooks/use-mobile-touch.ts +414 -0
  114. package/src/hooks/use-performance-throttling.ts +348 -0
  115. package/src/hooks/use-performance.ts +316 -0
  116. package/src/hooks/use-reusable-architecture.ts +414 -0
  117. package/src/hooks/use-semantic-input-types.ts +357 -0
  118. package/src/hooks/use-semantic-input.ts +565 -0
  119. package/src/hooks/use-tablet-layout.ts +384 -0
  120. package/src/hooks/use-touch-friendly-input.ts +524 -0
  121. package/src/hooks/use-touch-friendly-interface.ts +331 -0
  122. package/src/hooks/use-touch-optimization.ts +375 -0
  123. package/src/index.ts +279 -279
  124. package/src/lib/utils.ts +6 -0
  125. package/src/themes/README.md +272 -0
  126. package/src/themes/ThemeContext.tsx +31 -0
  127. package/src/themes/ThemeProvider.tsx +232 -0
  128. package/src/themes/accessibility/index.ts +27 -0
  129. package/src/themes/accessibility.ts +259 -0
  130. package/src/themes/aria-patterns.ts +420 -0
  131. package/src/themes/base-themes.ts +55 -0
  132. package/src/themes/colorManager.ts +380 -0
  133. package/src/themes/examples/dark-theme.ts +154 -0
  134. package/src/themes/examples/minimal-theme.ts +108 -0
  135. package/src/themes/focus-management.ts +701 -0
  136. package/src/themes/fontLoader.ts +201 -0
  137. package/src/themes/high-contrast.ts +621 -0
  138. package/src/themes/index.ts +19 -0
  139. package/src/themes/inheritance.ts +227 -0
  140. package/src/themes/keyboard-navigation.ts +550 -0
  141. package/src/themes/motion-reduction.ts +662 -0
  142. package/src/themes/navigation.ts +238 -0
  143. package/src/themes/screen-reader.ts +645 -0
  144. package/src/themes/systemThemeDetector.ts +182 -0
  145. package/src/themes/themeCSSUpdater.ts +262 -0
  146. package/src/themes/themePersistence.ts +238 -0
  147. package/src/themes/themes/default.ts +586 -0
  148. package/src/themes/themes/harvey.ts +554 -0
  149. package/src/themes/themes/stan-design.ts +683 -0
  150. package/src/themes/types.ts +460 -0
  151. package/src/themes/useSystemTheme.ts +48 -0
  152. package/src/themes/useTheme.ts +87 -0
  153. package/src/themes/validation.ts +462 -0
  154. package/src/tokens/index.ts +34 -0
  155. package/src/tokens/tokenExporter.ts +397 -0
  156. package/src/tokens/tokenGenerator.ts +276 -0
  157. package/src/tokens/tokenManager.ts +248 -0
  158. package/src/tokens/tokenValidator.ts +543 -0
  159. package/src/tokens/types.ts +78 -0
  160. package/src/utils/bundle-analyzer.ts +260 -0
  161. package/src/utils/bundle-splitting.ts +483 -0
  162. package/src/utils/lazy-loading.ts +441 -0
  163. package/src/utils/performance-monitor.ts +513 -0
  164. package/src/utils/tree-shaking.ts +274 -0
@@ -0,0 +1,460 @@
1
+ // Multi-Theme System Type Definitions
2
+ // This file defines the core interfaces for theme configuration
3
+
4
+ export interface MultiThemeConfig {
5
+ fonts: FontThemeConfig;
6
+ colors: ColorThemeConfig;
7
+ navigation: NavigationThemeConfig;
8
+ spacing: SpacingThemeConfig;
9
+ shadows: ShadowThemeConfig;
10
+ transitions: TransitionThemeConfig;
11
+ borderRadius: BorderRadiusThemeConfig;
12
+ borderWidth: BorderWidthThemeConfig;
13
+ animation: AnimationThemeConfig;
14
+ accessibility: AccessibilityThemeConfig;
15
+ print: PrintThemeConfig;
16
+ containerQuery: ContainerQueryThemeConfig;
17
+ container: ContainerThemeConfig;
18
+ shimmer: ShimmerThemeConfig;
19
+ meta: ThemeMetadata;
20
+ extends?: string; // Optional property for theme inheritance
21
+
22
+ // NEW: Add light/dark mode configuration (colors only)
23
+ modes?: {
24
+ light?: {
25
+ colors?: Partial<ColorThemeConfig>;
26
+ };
27
+ dark?: {
28
+ colors?: Partial<ColorThemeConfig>;
29
+ };
30
+ };
31
+ }
32
+
33
+ export interface FontThemeConfig {
34
+ primary: FontConfig;
35
+ secondary: FontConfig;
36
+ display: FontConfig;
37
+ body: FontConfig;
38
+ mono: FontConfig;
39
+ }
40
+
41
+ export interface FontConfig {
42
+ family: string;
43
+ weights: number[];
44
+ sizes: FontSizeScale;
45
+ lineHeights: LineHeightScale;
46
+ letterSpacing: LetterSpacingScale;
47
+ fallbacks?: string[]; // Font fallback stack
48
+ display?: 'auto' | 'block' | 'swap' | 'fallback' | 'optional'; // Font loading strategy
49
+ source?: FontSource; // Font source configuration
50
+ features?: FontFeatures; // Advanced font features
51
+ }
52
+
53
+ export interface FontSource {
54
+ type: 'google' | 'custom' | 'system';
55
+ url?: string; // For custom fonts
56
+ files?: FontFiles; // For custom font files
57
+ }
58
+
59
+ export interface FontFiles {
60
+ woff2?: string;
61
+ woff?: string;
62
+ ttf?: string;
63
+ eot?: string;
64
+ svg?: string;
65
+ }
66
+
67
+ export interface FontFeatures {
68
+ ligatures?: boolean;
69
+ kerning?: boolean;
70
+ variant?: 'normal' | 'small-caps' | 'all-small-caps';
71
+ stretch?: 'normal' | 'condensed' | 'expanded';
72
+ styleSet?: number;
73
+ }
74
+
75
+ export interface FontSizeScale {
76
+ xs: string;
77
+ sm: string;
78
+ md: string;
79
+ lg: string;
80
+ xl: string;
81
+ '2xl': string;
82
+ '3xl': string;
83
+ '4xl': string;
84
+ '5xl': string;
85
+ '6xl': string;
86
+ }
87
+
88
+ export interface LineHeightScale {
89
+ tight: string;
90
+ normal: string;
91
+ relaxed: string;
92
+ loose: string;
93
+ }
94
+
95
+ export interface LetterSpacingScale {
96
+ tight: string;
97
+ normal: string;
98
+ wide: string;
99
+ wider: string;
100
+ widest: string;
101
+ }
102
+
103
+ export interface ColorThemeConfig {
104
+ primary: ColorScale;
105
+ secondary: ColorScale;
106
+ semantic: SemanticColors;
107
+ neutral: ColorScale;
108
+ surface: SurfaceColors;
109
+ text: TextColors;
110
+ interactive: InteractiveColors;
111
+ // Additional color properties referenced in CSS
112
+ accent?: string;
113
+ 'bg-primary'?: string;
114
+ 'bg-secondary'?: string;
115
+ 'surface-bg'?: string;
116
+ 'primary-hover'?: string;
117
+ 'primary-active'?: string;
118
+ 'accent-rgb'?: string;
119
+ border?: string;
120
+ 'border-transparent'?: string;
121
+ 'text-primary'?: string;
122
+ 'text-secondary'?: string;
123
+ }
124
+
125
+ export interface ColorScale {
126
+ 50: string;
127
+ 100: string;
128
+ 200: string;
129
+ 300: string;
130
+ 400: string;
131
+ 500: string;
132
+ 600: string;
133
+ 700: string;
134
+ 800: string;
135
+ 900: string;
136
+ // Additional color variations
137
+ light?: string; // Lighter than 50
138
+ dark?: string; // Darker than 900
139
+ contrast?: string; // High contrast version
140
+ // RGB versions for rgba() usage
141
+ '500-rgb'?: string;
142
+ '600-rgb'?: string;
143
+ '700-rgb'?: string;
144
+ }
145
+
146
+ export interface ColorAccessibility {
147
+ aa: boolean; // WCAG AA compliance
148
+ aaa: boolean; // WCAG AAA compliance
149
+ contrastRatio: number; // Actual contrast ratio
150
+ recommended: string[]; // Recommended improvements
151
+ }
152
+
153
+ export interface SemanticColors {
154
+ success: string;
155
+ warning: string;
156
+ error: string;
157
+ info: string;
158
+ // Enhanced semantic colors with accessibility
159
+ successLight?: string;
160
+ successDark?: string;
161
+ warningLight?: string;
162
+ warningDark?: string;
163
+ errorLight?: string;
164
+ errorDark?: string;
165
+ infoLight?: string;
166
+ infoDark?: string;
167
+ // RGB versions for rgba() usage
168
+ successRgb?: string;
169
+ warningRgb?: string;
170
+ errorRgb?: string;
171
+ errorDarkRgb?: string;
172
+ infoRgb?: string;
173
+ // Additional RGB versions referenced in CSS
174
+ 'success-rgb'?: string;
175
+ 'warning-rgb'?: string;
176
+ 'error-rgb'?: string;
177
+ 'error-dark-rgb'?: string;
178
+ 'info-rgb'?: string;
179
+ }
180
+
181
+ export interface NeutralColors {
182
+ 50: string;
183
+ 100: string;
184
+ 200: string;
185
+ 300: string;
186
+ 400: string;
187
+ 500: string;
188
+ 600: string;
189
+ 700: string;
190
+ 800: string;
191
+ 900: string;
192
+ }
193
+
194
+ export interface SurfaceColors {
195
+ background: string;
196
+ surface: string;
197
+ border: string;
198
+ divider: string;
199
+ }
200
+
201
+ export interface TextColors {
202
+ primary: string;
203
+ secondary: string;
204
+ muted: string;
205
+ inverse: string;
206
+ onPrimary: string;
207
+ onSecondary: string;
208
+ onSurface: string;
209
+ }
210
+
211
+ export interface InteractiveColors {
212
+ hover: string;
213
+ active: string;
214
+ focus: string;
215
+ disabled: string;
216
+ // Enhanced interactive states
217
+ hoverLight?: string;
218
+ hoverDark?: string;
219
+ activeLight?: string;
220
+ activeDark?: string;
221
+ focusRing?: string;
222
+ focusRingOffset?: string;
223
+ }
224
+
225
+ // Color generation and utility interfaces
226
+ export interface ColorGenerationConfig {
227
+ baseColor: string;
228
+ hueShift?: number;
229
+ saturationAdjust?: number;
230
+ lightnessAdjust?: number;
231
+ generateShades?: boolean;
232
+ generateTints?: boolean;
233
+ generateContrast?: boolean;
234
+ }
235
+
236
+ export interface ColorPalette {
237
+ name: string;
238
+ description: string;
239
+ colors: ColorScale;
240
+ accessibility: ColorAccessibility;
241
+ usage: string[];
242
+ tags: string[];
243
+ }
244
+
245
+ import type { NavigationThemeConfig } from './navigation';
246
+
247
+
248
+
249
+
250
+
251
+ export interface SpacingThemeConfig {
252
+ scale: SpacingScale;
253
+ component: ComponentSpacing;
254
+ layout: LayoutSpacing;
255
+ }
256
+
257
+ export interface SpacingScale {
258
+ xs: string;
259
+ sm: string;
260
+ md: string;
261
+ lg: string;
262
+ xl: string;
263
+ '2xl': string;
264
+ '3xl': string;
265
+ '4xl': string;
266
+ '5xl': string;
267
+ '6xl': string;
268
+ }
269
+
270
+ export interface ComponentSpacing {
271
+ button: {
272
+ padding: string;
273
+ margin: string;
274
+ gap: string;
275
+ };
276
+ input: {
277
+ padding: string;
278
+ margin: string;
279
+ gap: string;
280
+ };
281
+ card: {
282
+ padding: string;
283
+ margin: string;
284
+ gap: string;
285
+ };
286
+ }
287
+
288
+ export interface LayoutSpacing {
289
+ page: string;
290
+ section: string;
291
+ container: string;
292
+ grid: string;
293
+ }
294
+
295
+ export interface ShadowThemeConfig {
296
+ sm: string;
297
+ md: string;
298
+ lg: string;
299
+ xl: string;
300
+ '2xl': string;
301
+ inner: string;
302
+ none: string;
303
+ }
304
+
305
+ export interface TransitionThemeConfig {
306
+ duration: TransitionDuration;
307
+ easing: TransitionEasing;
308
+ properties: TransitionProperties;
309
+ }
310
+
311
+ export interface BorderRadiusThemeConfig {
312
+ none: string;
313
+ sm: string;
314
+ md: string;
315
+ lg: string;
316
+ xl: string;
317
+ '2xl': string;
318
+ full: string;
319
+ }
320
+
321
+ export interface BorderWidthThemeConfig {
322
+ none: string;
323
+ thin: string;
324
+ normal: string;
325
+ focus: string;
326
+ thick: string;
327
+ extraThick: string;
328
+ }
329
+
330
+ export interface AnimationThemeConfig {
331
+ duration: {
332
+ fast: string;
333
+ normal: string;
334
+ slow: string;
335
+ };
336
+ easing: {
337
+ linear: string;
338
+ ease: string;
339
+ easeIn: string;
340
+ easeOut: string;
341
+ easeInOut: string;
342
+ };
343
+ transforms: {
344
+ hoverY: string;
345
+ offsetY: string;
346
+ scale: string;
347
+ };
348
+ }
349
+
350
+ export interface AccessibilityThemeConfig {
351
+ focusRing: {
352
+ width: string;
353
+ offset: string;
354
+ color: string;
355
+ };
356
+ outline: {
357
+ offset: string;
358
+ };
359
+ highContrast: {
360
+ borderWidth: string;
361
+ outlineWidth: string;
362
+ };
363
+ disabled: {
364
+ cursor: string;
365
+ opacity: string;
366
+ };
367
+ }
368
+
369
+ export interface PrintThemeConfig {
370
+ borderColor: string;
371
+ textColor: string;
372
+ textSecondaryColor: string;
373
+ backgroundColor: string;
374
+ }
375
+
376
+ export interface ContainerQueryThemeConfig {
377
+ small: string;
378
+ medium: string;
379
+ large: string;
380
+ }
381
+
382
+ export interface ContainerThemeConfig {
383
+ width: {
384
+ small: string;
385
+ medium: string;
386
+ large: string;
387
+ xl: string;
388
+ full: string;
389
+ };
390
+ }
391
+
392
+ export interface ShimmerThemeConfig {
393
+ alpha: string;
394
+ color: string;
395
+ }
396
+
397
+ export interface TransitionDuration {
398
+ fast: string;
399
+ normal: string;
400
+ slow: string;
401
+ }
402
+
403
+ export interface TransitionEasing {
404
+ linear: string;
405
+ ease: string;
406
+ easeIn: string;
407
+ easeOut: string;
408
+ easeInOut: string;
409
+ }
410
+
411
+ export interface TransitionProperties {
412
+ colors: string;
413
+ transform: string;
414
+ opacity: string;
415
+ shadow: string;
416
+ }
417
+
418
+ export interface ThemeMetadata {
419
+ name: string;
420
+ description: string;
421
+ author: string;
422
+ version: string;
423
+ category: 'brand' | 'enterprise' | 'creative' | 'custom' | 'accessibility';
424
+ tags: string[];
425
+ preview: string; // URL to preview image
426
+ createdAt: string;
427
+ updatedAt: string;
428
+ }
429
+
430
+ // Theme validation types
431
+ export interface ThemeValidationResult {
432
+ isValid: boolean;
433
+ errors: ThemeValidationError[];
434
+ warnings: ThemeValidationWarning[];
435
+ }
436
+
437
+ export interface ThemeValidationError {
438
+ path: string;
439
+ message: string;
440
+ severity: 'error' | 'critical';
441
+ }
442
+
443
+ export interface ThemeValidationWarning {
444
+ path: string;
445
+ message: string;
446
+ severity: 'warning' | 'info';
447
+ }
448
+
449
+ // Theme inheritance types
450
+ export interface ThemeInheritance {
451
+ extends?: string; // Theme name to extend
452
+ overrides: Partial<MultiThemeConfig>; // Properties to override
453
+ additions: Partial<MultiThemeConfig>; // Properties to add
454
+ }
455
+
456
+ // Complete theme with inheritance
457
+ export interface CompleteThemeConfig extends MultiThemeConfig {
458
+ inheritance?: ThemeInheritance;
459
+ validation: ThemeValidationResult;
460
+ }
@@ -0,0 +1,48 @@
1
+ import { useState, useEffect, useRef, useCallback } from 'react';
2
+ import { SystemThemeDetector, SystemTheme, SystemThemeOptions } from './systemThemeDetector';
3
+
4
+ /**
5
+ * React hook for using system theme detection
6
+ */
7
+ export const useSystemTheme = (options: SystemThemeOptions = {}) => {
8
+ const [systemTheme, setSystemTheme] = useState<SystemTheme>('light');
9
+ const detectorRef = useRef<SystemThemeDetector | null>(null);
10
+
11
+ useEffect(() => {
12
+ if (typeof window === 'undefined') return;
13
+
14
+ detectorRef.current = new SystemThemeDetector(options);
15
+
16
+ // Set initial theme
17
+ const initialTheme = detectorRef.current.getSystemTheme();
18
+ setSystemTheme(initialTheme);
19
+
20
+ // Subscribe to changes
21
+ const unsubscribe = detectorRef.current.subscribe(setSystemTheme);
22
+
23
+ return () => {
24
+ unsubscribe();
25
+ detectorRef.current?.destroy();
26
+ };
27
+ }, [options.storageKey, options.enablePersistence]);
28
+
29
+ const setSystemThemePreference = useCallback((theme: SystemTheme) => {
30
+ if (detectorRef.current) {
31
+ detectorRef.current.setStoredPreference(theme);
32
+ setSystemTheme(theme);
33
+ }
34
+ }, []);
35
+
36
+ const applySystemThemeCSS = useCallback((theme: SystemTheme) => {
37
+ if (detectorRef.current) {
38
+ detectorRef.current.applySystemThemeCSS(theme);
39
+ }
40
+ }, []);
41
+
42
+ return {
43
+ systemTheme,
44
+ setSystemThemePreference,
45
+ applySystemThemeCSS,
46
+ isSupported: detectorRef.current?.isSupported() ?? false,
47
+ };
48
+ };
@@ -0,0 +1,87 @@
1
+ import { useContext } from 'react';
2
+ import { ThemeContext, ThemeContextType } from './ThemeContext';
3
+
4
+ /**
5
+ * Hook to access theme context
6
+ * Must be used within a ThemeProvider
7
+ *
8
+ * @returns ThemeContextType - The current theme context
9
+ * @throws Error if used outside of ThemeProvider
10
+ *
11
+ * @example
12
+ * ```tsx
13
+ * function MyComponent() {
14
+ * const { currentTheme, setTheme, currentThemeConfig } = useTheme();
15
+ *
16
+ * return (
17
+ * <button onClick={() => setTheme('harvey')}>
18
+ * Switch to Harvey Theme
19
+ * </button>
20
+ * );
21
+ * }
22
+ * ```
23
+ */
24
+ export const useTheme = (): ThemeContextType => {
25
+ const context = useContext(ThemeContext);
26
+
27
+ if (!context) {
28
+ throw new Error('useTheme must be used within ThemeProvider');
29
+ }
30
+
31
+ return context;
32
+ };
33
+
34
+ /**
35
+ * Hook to get a specific theme by name
36
+ * Useful for accessing theme data without switching
37
+ *
38
+ * @param themeName - Name of the theme to retrieve
39
+ * @returns CompleteThemeConfig | null - The requested theme or null if not found
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * function ThemePreview() {
44
+ * const harveyTheme = useThemeByName('harvey');
45
+ *
46
+ * if (!harveyTheme) return <div>Theme not found</div>;
47
+ *
48
+ * return (
49
+ * <div style={{ color: harveyTheme.colors.primary[500] }}>
50
+ * Harvey Theme Preview
51
+ * </div>
52
+ * );
53
+ * }
54
+ * ```
55
+ */
56
+ export const useThemeByName = (themeName: string) => {
57
+ const { getTheme } = useTheme();
58
+ return getTheme(themeName);
59
+ };
60
+
61
+ /**
62
+ * Hook to check if a specific theme is available
63
+ *
64
+ * @param themeName - Name of the theme to check
65
+ * @returns boolean - True if theme is available
66
+ *
67
+ * @example
68
+ * ```tsx
69
+ * function ThemeSwitcher() {
70
+ * const hasHarveyTheme = useThemeAvailable('harvey');
71
+ *
72
+ * return (
73
+ * <div>
74
+ * {hasHarveyTheme && (
75
+ * <button onClick={() => setTheme('harvey')}>
76
+ * Harvey Theme
77
+ * </button>
78
+ * )}
79
+ * </div>
80
+ * );
81
+ * }
82
+ * ```
83
+ */
84
+ export const useThemeAvailable = (themeName: string): boolean => {
85
+ const { availableThemes } = useTheme();
86
+ return availableThemes.includes(themeName);
87
+ };