@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.2.8 → 0.2.10
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/CHANGELOG.md +1 -1
- package/dist/components/ui/accessibility-demo.esm.js +30 -24
- package/dist/components/ui/accessibility-demo.js +30 -24
- package/dist/components/ui/advanced-component-architecture-demo.esm.js +235 -179
- package/dist/components/ui/advanced-component-architecture-demo.js +235 -179
- package/dist/components/ui/advanced-transition-system-demo.esm.js +110 -64
- package/dist/components/ui/advanced-transition-system-demo.js +110 -64
- package/dist/components/ui/advanced-transition-system.esm.js +166 -122
- package/dist/components/ui/advanced-transition-system.js +166 -122
- package/dist/components/ui/animation/animated-container.esm.js +52 -29
- package/dist/components/ui/animation/animated-container.js +52 -29
- package/dist/components/ui/animation/staggered-container.esm.js +18 -9
- package/dist/components/ui/animation/staggered-container.js +18 -9
- package/dist/components/ui/animation-demo.esm.js +67 -35
- package/dist/components/ui/animation-demo.js +67 -35
- package/dist/components/ui/badge.esm.js +9 -6
- package/dist/components/ui/badge.js +9 -6
- package/dist/components/ui/battery-conscious-animation-demo.esm.js +122 -87
- package/dist/components/ui/battery-conscious-animation-demo.js +122 -87
- package/dist/components/ui/border-radius-shadow-demo.esm.js +23 -12
- package/dist/components/ui/border-radius-shadow-demo.js +23 -12
- package/dist/components/ui/button.esm.js +8 -2
- package/dist/components/ui/button.js +8 -2
- package/dist/components/ui/card.esm.js +33 -8
- package/dist/components/ui/card.js +33 -8
- package/dist/components/ui/checkbox.esm.js +3 -3
- package/dist/components/ui/checkbox.js +3 -3
- package/dist/components/ui/color-preview.esm.js +68 -45
- package/dist/components/ui/color-preview.js +68 -45
- package/dist/components/ui/data-display/chart.esm.js +112 -84
- package/dist/components/ui/data-display/chart.js +112 -84
- package/dist/components/ui/data-display/data-grid-simple.esm.js +1 -1
- package/dist/components/ui/data-display/data-grid-simple.js +1 -1
- package/dist/components/ui/data-display/data-grid.esm.js +80 -67
- package/dist/components/ui/data-display/data-grid.js +80 -67
- package/dist/components/ui/data-display/list.esm.js +53 -45
- package/dist/components/ui/data-display/list.js +53 -45
- package/dist/components/ui/data-display/table.esm.js +62 -54
- package/dist/components/ui/data-display/table.js +62 -54
- package/dist/components/ui/data-display/timeline.esm.js +39 -34
- package/dist/components/ui/data-display/timeline.js +39 -34
- package/dist/components/ui/data-display/tree.esm.js +116 -84
- package/dist/components/ui/data-display/tree.js +116 -84
- package/dist/components/ui/data-display/types.esm.js +389 -364
- package/dist/components/ui/data-display/types.js +389 -364
- package/dist/components/ui/enterprise-mobile-experience-demo.esm.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience-demo.js +120 -70
- package/dist/components/ui/enterprise-mobile-experience.esm.js +124 -73
- package/dist/components/ui/enterprise-mobile-experience.js +124 -73
- package/dist/components/ui/feedback/alert.esm.js +22 -15
- package/dist/components/ui/feedback/alert.js +22 -15
- package/dist/components/ui/feedback/progress.esm.js +47 -24
- package/dist/components/ui/feedback/progress.js +47 -24
- package/dist/components/ui/feedback/skeleton.esm.js +39 -29
- package/dist/components/ui/feedback/skeleton.js +39 -29
- package/dist/components/ui/feedback/toast.esm.js +62 -38
- package/dist/components/ui/feedback/toast.js +62 -38
- package/dist/components/ui/feedback/types.esm.js +83 -83
- package/dist/components/ui/feedback/types.js +83 -83
- package/dist/components/ui/font-preview.esm.js +41 -39
- package/dist/components/ui/font-preview.js +41 -39
- package/dist/components/ui/form-demo.esm.js +150 -113
- package/dist/components/ui/form-demo.js +150 -113
- package/dist/components/ui/hardware-acceleration-demo.esm.js +137 -87
- package/dist/components/ui/hardware-acceleration-demo.js +137 -87
- package/dist/components/ui/input.esm.js +4 -1
- package/dist/components/ui/input.js +4 -1
- package/dist/components/ui/layout-demo.esm.js +81 -56
- package/dist/components/ui/layout-demo.js +81 -56
- package/dist/components/ui/layouts/adaptive-layout.esm.js +27 -8
- package/dist/components/ui/layouts/adaptive-layout.js +27 -8
- package/dist/components/ui/layouts/desktop-layout.esm.js +39 -19
- package/dist/components/ui/layouts/desktop-layout.js +39 -19
- package/dist/components/ui/layouts/mobile-layout.esm.js +19 -9
- package/dist/components/ui/layouts/mobile-layout.js +19 -9
- package/dist/components/ui/layouts/tablet-layout.esm.js +28 -14
- package/dist/components/ui/layouts/tablet-layout.js +28 -14
- package/dist/components/ui/mobile-form-validation.esm.js +120 -87
- package/dist/components/ui/mobile-form-validation.js +120 -87
- package/dist/components/ui/mobile-input-demo.esm.js +19 -13
- package/dist/components/ui/mobile-input-demo.js +19 -13
- package/dist/components/ui/mobile-input.esm.js +185 -120
- package/dist/components/ui/mobile-input.js +185 -120
- package/dist/components/ui/mobile-skeleton-loading-demo.esm.js +128 -111
- package/dist/components/ui/mobile-skeleton-loading-demo.js +128 -111
- package/dist/components/ui/navigation/breadcrumb.esm.js +17 -14
- package/dist/components/ui/navigation/breadcrumb.js +17 -14
- package/dist/components/ui/navigation/index.esm.js +23 -1
- package/dist/components/ui/navigation/index.js +23 -1
- package/dist/components/ui/navigation/menu.esm.js +49 -35
- package/dist/components/ui/navigation/menu.js +49 -35
- package/dist/components/ui/navigation/navigation-demo.esm.js +81 -74
- package/dist/components/ui/navigation/navigation-demo.js +81 -74
- package/dist/components/ui/navigation/pagination.esm.js +62 -50
- package/dist/components/ui/navigation/pagination.js +62 -50
- package/dist/components/ui/navigation/sidebar.esm.js +56 -42
- package/dist/components/ui/navigation/sidebar.js +56 -42
- package/dist/components/ui/navigation/stepper.esm.js +34 -23
- package/dist/components/ui/navigation/stepper.js +34 -23
- package/dist/components/ui/navigation/tabs.esm.js +32 -21
- package/dist/components/ui/navigation/tabs.js +32 -21
- package/dist/components/ui/navigation/types.esm.js +196 -195
- package/dist/components/ui/navigation/types.js +196 -195
- package/dist/components/ui/overlay/backdrop.esm.js +17 -16
- package/dist/components/ui/overlay/backdrop.js +17 -16
- package/dist/components/ui/overlay/focus-manager.esm.js +21 -19
- package/dist/components/ui/overlay/focus-manager.js +21 -19
- package/dist/components/ui/overlay/index.esm.js +22 -2
- package/dist/components/ui/overlay/index.js +22 -2
- package/dist/components/ui/overlay/modal.esm.js +38 -34
- package/dist/components/ui/overlay/modal.js +38 -34
- package/dist/components/ui/overlay/overlay-manager.esm.js +25 -20
- package/dist/components/ui/overlay/overlay-manager.js +25 -20
- package/dist/components/ui/overlay/popover.esm.js +74 -58
- package/dist/components/ui/overlay/popover.js +74 -58
- package/dist/components/ui/overlay/portal.esm.js +7 -7
- package/dist/components/ui/overlay/portal.js +7 -7
- package/dist/components/ui/overlay/tooltip.esm.js +54 -39
- package/dist/components/ui/overlay/tooltip.js +54 -39
- package/dist/components/ui/overlay/types.esm.js +132 -131
- package/dist/components/ui/overlay/types.js +132 -131
- package/dist/components/ui/performance-demo.esm.js +135 -88
- package/dist/components/ui/performance-demo.js +135 -88
- package/dist/components/ui/semantic-input-system-demo.esm.js +117 -80
- package/dist/components/ui/semantic-input-system-demo.js +117 -80
- package/dist/components/ui/theme-customizer.esm.js +84 -52
- package/dist/components/ui/theme-customizer.js +84 -52
- package/dist/components/ui/theme-preview.esm.js +95 -43
- package/dist/components/ui/theme-preview.js +95 -43
- package/dist/components/ui/theme-switcher.esm.js +70 -44
- package/dist/components/ui/theme-switcher.js +70 -44
- package/dist/components/ui/theme-toggle.esm.js +3 -3
- package/dist/components/ui/theme-toggle.js +3 -3
- package/dist/components/ui/token-demo.esm.js +33 -21
- package/dist/components/ui/token-demo.js +33 -21
- package/dist/components/ui/touch-demo.esm.js +102 -73
- package/dist/components/ui/touch-demo.js +102 -73
- package/dist/components/ui/touch-friendly-interface-demo.esm.js +102 -64
- package/dist/components/ui/touch-friendly-interface-demo.js +102 -64
- package/dist/components/ui/touch-friendly-interface.esm.js +85 -61
- package/dist/components/ui/touch-friendly-interface.js +85 -61
- package/dist/hooks/use-accessibility-support.esm.js +115 -85
- package/dist/hooks/use-accessibility-support.js +115 -85
- package/dist/hooks/use-adaptive-layout.esm.js +56 -33
- package/dist/hooks/use-adaptive-layout.js +56 -33
- package/dist/hooks/use-advanced-patterns.esm.js +57 -42
- package/dist/hooks/use-advanced-patterns.js +57 -42
- package/dist/hooks/use-advanced-transition-system.esm.js +112 -71
- package/dist/hooks/use-advanced-transition-system.js +112 -71
- package/dist/hooks/use-animation-profile.esm.js +63 -34
- package/dist/hooks/use-animation-profile.js +63 -34
- package/dist/hooks/use-battery-animations.esm.js +80 -55
- package/dist/hooks/use-battery-animations.js +80 -55
- package/dist/hooks/use-battery-conscious-loading.esm.js +166 -123
- package/dist/hooks/use-battery-conscious-loading.js +166 -123
- package/dist/hooks/use-battery-optimization.esm.js +78 -55
- package/dist/hooks/use-battery-optimization.js +78 -55
- package/dist/hooks/use-battery-status.esm.js +73 -51
- package/dist/hooks/use-battery-status.js +73 -51
- package/dist/hooks/use-component-performance.esm.js +62 -47
- package/dist/hooks/use-component-performance.js +62 -47
- package/dist/hooks/use-device-loading-states.esm.js +152 -109
- package/dist/hooks/use-device-loading-states.js +152 -109
- package/dist/hooks/use-device.esm.js +25 -14
- package/dist/hooks/use-device.js +25 -14
- package/dist/hooks/use-enterprise-mobile-experience.esm.js +137 -88
- package/dist/hooks/use-enterprise-mobile-experience.js +137 -88
- package/dist/hooks/use-form-feedback.esm.js +124 -81
- package/dist/hooks/use-form-feedback.js +124 -81
- package/dist/hooks/use-form-performance.esm.js +127 -92
- package/dist/hooks/use-form-performance.js +127 -92
- package/dist/hooks/use-frame-rate.esm.js +56 -37
- package/dist/hooks/use-frame-rate.js +56 -37
- package/dist/hooks/use-gestures.esm.js +96 -72
- package/dist/hooks/use-gestures.js +96 -72
- package/dist/hooks/use-hardware-acceleration.esm.js +65 -37
- package/dist/hooks/use-hardware-acceleration.js +65 -37
- package/dist/hooks/use-input-accessibility.esm.js +157 -119
- package/dist/hooks/use-input-accessibility.js +157 -119
- package/dist/hooks/use-input-performance.esm.js +139 -104
- package/dist/hooks/use-input-performance.js +139 -104
- package/dist/hooks/use-layout-performance.esm.js +50 -29
- package/dist/hooks/use-layout-performance.js +50 -29
- package/dist/hooks/use-loading-accessibility.esm.js +209 -169
- package/dist/hooks/use-loading-accessibility.js +209 -169
- package/dist/hooks/use-loading-performance.esm.js +117 -93
- package/dist/hooks/use-loading-performance.js +117 -93
- package/dist/hooks/use-memory-usage.esm.js +57 -38
- package/dist/hooks/use-memory-usage.js +57 -38
- package/dist/hooks/use-mobile-form-layout.esm.js +111 -74
- package/dist/hooks/use-mobile-form-layout.js +111 -74
- package/dist/hooks/use-mobile-form-validation.esm.js +211 -144
- package/dist/hooks/use-mobile-form-validation.js +211 -144
- package/dist/hooks/use-mobile-keyboard-optimization.esm.js +154 -113
- package/dist/hooks/use-mobile-keyboard-optimization.js +154 -113
- package/dist/hooks/use-mobile-layout.esm.js +73 -51
- package/dist/hooks/use-mobile-layout.js +73 -51
- package/dist/hooks/use-mobile-optimization.esm.js +72 -44
- package/dist/hooks/use-mobile-optimization.js +72 -44
- package/dist/hooks/use-mobile-skeleton.esm.js +97 -64
- package/dist/hooks/use-mobile-skeleton.js +97 -64
- package/dist/hooks/use-mobile-touch.esm.js +128 -93
- package/dist/hooks/use-mobile-touch.js +128 -93
- package/dist/hooks/use-performance-throttling.esm.js +72 -48
- package/dist/hooks/use-performance-throttling.js +72 -48
- package/dist/hooks/use-performance.esm.js +90 -52
- package/dist/hooks/use-performance.js +90 -52
- package/dist/hooks/use-reusable-architecture.esm.js +94 -65
- package/dist/hooks/use-reusable-architecture.js +94 -65
- package/dist/hooks/use-semantic-input-types.esm.js +166 -124
- package/dist/hooks/use-semantic-input-types.js +166 -124
- package/dist/hooks/use-semantic-input.esm.js +178 -126
- package/dist/hooks/use-semantic-input.js +178 -126
- package/dist/hooks/use-tablet-layout.esm.js +67 -38
- package/dist/hooks/use-tablet-layout.js +67 -38
- package/dist/hooks/use-touch-friendly-input.esm.js +193 -149
- package/dist/hooks/use-touch-friendly-input.js +193 -149
- package/dist/hooks/use-touch-friendly-interface.esm.js +99 -67
- package/dist/hooks/use-touch-friendly-interface.js +99 -67
- package/dist/hooks/use-touch-optimization.esm.js +99 -72
- package/dist/hooks/use-touch-optimization.js +99 -72
- package/dist/index.esm.js +289 -280
- package/dist/index.js +289 -280
- package/dist/lib/utils.esm.js +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/plugins/theme-css-generator.esm.js +104 -55
- package/dist/plugins/theme-css-generator.js +104 -55
- package/dist/provider.esm.js +4 -4
- package/dist/provider.js +4 -4
- package/dist/styles.css +1 -1
- package/dist/theme.esm.js +633 -468
- package/dist/theme.js +633 -468
- package/dist/themes/ThemeContext.esm.js +15 -15
- package/dist/themes/ThemeContext.js +15 -15
- package/dist/themes/ThemeProvider.esm.js +25 -22
- package/dist/themes/ThemeProvider.js +25 -22
- package/dist/themes/accessibility.esm.js +147 -108
- package/dist/themes/accessibility.js +147 -108
- package/dist/themes/aria-patterns.esm.js +198 -162
- package/dist/themes/aria-patterns.js +198 -162
- package/dist/themes/base-themes.esm.js +14 -11
- package/dist/themes/base-themes.js +14 -11
- package/dist/themes/colorManager.esm.js +101 -83
- package/dist/themes/colorManager.js +101 -83
- package/dist/themes/examples/dark-theme.esm.js +133 -103
- package/dist/themes/examples/dark-theme.js +133 -103
- package/dist/themes/examples/minimal-theme.esm.js +83 -61
- package/dist/themes/examples/minimal-theme.js +83 -61
- package/dist/themes/focus-management.esm.js +202 -143
- package/dist/themes/focus-management.js +202 -143
- package/dist/themes/fontLoader.esm.js +28 -19
- package/dist/themes/fontLoader.js +28 -19
- package/dist/themes/high-contrast.esm.js +152 -104
- package/dist/themes/high-contrast.js +152 -104
- package/dist/themes/inheritance.esm.js +35 -27
- package/dist/themes/inheritance.js +35 -27
- package/dist/themes/keyboard-navigation.esm.js +152 -123
- package/dist/themes/keyboard-navigation.js +152 -123
- package/dist/themes/motion-reduction.esm.js +193 -133
- package/dist/themes/motion-reduction.js +193 -133
- package/dist/themes/navigation.esm.js +146 -146
- package/dist/themes/navigation.js +146 -146
- package/dist/themes/screen-reader.esm.js +159 -94
- package/dist/themes/screen-reader.js +159 -94
- package/dist/themes/systemThemeDetector.esm.js +42 -34
- package/dist/themes/systemThemeDetector.js +42 -34
- package/dist/themes/themeCSSUpdater.esm.js +21 -9
- package/dist/themes/themeCSSUpdater.js +21 -9
- package/dist/themes/themePersistence.esm.js +68 -47
- package/dist/themes/themePersistence.js +68 -47
- package/dist/themes/themes/stan-design.esm.js +633 -468
- package/dist/themes/themes/stan-design.js +633 -468
- package/dist/themes/types.esm.js +301 -287
- package/dist/themes/types.js +301 -287
- package/dist/themes/useSystemTheme.esm.js +4 -4
- package/dist/themes/useSystemTheme.js +4 -4
- package/dist/themes/useTheme.esm.js +4 -4
- package/dist/themes/useTheme.js +4 -4
- package/dist/themes/validation.esm.js +128 -77
- package/dist/themes/validation.js +128 -77
- package/dist/tokens/index.esm.js +15 -4
- package/dist/tokens/index.js +15 -4
- package/dist/tokens/tokenExporter.esm.js +87 -61
- package/dist/tokens/tokenExporter.js +87 -61
- package/dist/tokens/tokenGenerator.esm.js +86 -77
- package/dist/tokens/tokenGenerator.js +86 -77
- package/dist/tokens/tokenManager.esm.js +64 -51
- package/dist/tokens/tokenManager.js +64 -51
- package/dist/tokens/tokenValidator.esm.js +193 -147
- package/dist/tokens/tokenValidator.js +193 -147
- package/dist/tokens/types.esm.js +49 -35
- package/dist/tokens/types.js +49 -35
- package/dist/utils/bundle-analyzer.esm.js +83 -65
- package/dist/utils/bundle-analyzer.js +83 -65
- package/dist/utils/bundle-splitting.esm.js +142 -117
- package/dist/utils/bundle-splitting.js +142 -117
- package/dist/utils/lazy-loading.esm.js +132 -106
- package/dist/utils/lazy-loading.js +132 -106
- package/dist/utils/performance-monitor.esm.js +170 -129
- package/dist/utils/performance-monitor.js +170 -129
- package/dist/utils/tree-shaking.esm.js +69 -61
- package/dist/utils/tree-shaking.js +69 -61
- package/package.json +1 -1
- package/src/index.ts +146 -146
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { CompleteThemeConfig } from '../themes/types';
|
|
2
|
+
import type { ThemeTokens, TokenGroup, ColorToken, FontToken, SpacingToken, ShadowToken, TransitionToken } from './types';
|
|
3
3
|
|
|
4
4
|
export class TokenGenerator {
|
|
5
5
|
/**
|
|
6
6
|
* Generates design tokens from a complete theme configuration
|
|
7
7
|
*/
|
|
8
|
-
static generateTokens(themeConfig)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
static generateTokens(themeConfig: CompleteThemeConfig): ThemeTokens {
|
|
9
|
+
return {
|
|
10
|
+
theme: themeConfig.meta.name,
|
|
11
|
+
version: themeConfig.meta.version || '1.0.0',
|
|
12
|
+
tokens: {
|
|
13
|
+
color: this.generateColorTokens(themeConfig.colors),
|
|
14
|
+
font: this.generateFontTokens(themeConfig.fonts),
|
|
15
|
+
spacing: this.generateSpacingTokens(themeConfig.spacing),
|
|
16
|
+
shadow: this.generateShadowTokens(themeConfig.shadows),
|
|
17
|
+
transition: this.generateTransitionTokens(themeConfig.transitions)
|
|
15
18
|
}
|
|
16
19
|
};
|
|
17
20
|
}
|
|
@@ -19,7 +22,8 @@ export class TokenGenerator {
|
|
|
19
22
|
/**
|
|
20
23
|
* Generates color tokens from theme colors
|
|
21
24
|
*/
|
|
22
|
-
private static generateColorTokens(colors])
|
|
25
|
+
private static generateColorTokens(colors: CompleteThemeConfig['colors']): TokenGroup {
|
|
26
|
+
const colorTokens: TokenGroup = {};
|
|
23
27
|
|
|
24
28
|
// Primary colors
|
|
25
29
|
if (colors.primary) {
|
|
@@ -62,17 +66,18 @@ export class TokenGenerator {
|
|
|
62
66
|
/**
|
|
63
67
|
* Creates a color group from a color scale
|
|
64
68
|
*/
|
|
65
|
-
private static createColorGroup(colorScale, semantic])
|
|
69
|
+
private static createColorGroup(colorScale: any, semantic: ColorToken['semantic']): TokenGroup {
|
|
70
|
+
const group: TokenGroup = {};
|
|
66
71
|
|
|
67
72
|
Object.entries(colorScale).forEach(([shade, value]) => {
|
|
68
73
|
if (typeof value === 'string') {
|
|
69
74
|
group[shade] = {
|
|
70
75
|
value,
|
|
71
|
-
type,
|
|
76
|
+
type: 'color',
|
|
72
77
|
semantic,
|
|
73
|
-
description} color - ${shade} shade`,
|
|
74
|
-
category,
|
|
75
|
-
tags, shade]
|
|
78
|
+
description: `${semantic} color - ${shade} shade`,
|
|
79
|
+
category: 'color',
|
|
80
|
+
tags: [semantic, shade]
|
|
76
81
|
} as ColorToken;
|
|
77
82
|
}
|
|
78
83
|
});
|
|
@@ -83,56 +88,57 @@ export class TokenGenerator {
|
|
|
83
88
|
/**
|
|
84
89
|
* Generates font tokens from theme fonts
|
|
85
90
|
*/
|
|
86
|
-
private static generateFontTokens(fonts])
|
|
91
|
+
private static generateFontTokens(fonts: CompleteThemeConfig['fonts']): TokenGroup {
|
|
92
|
+
const fontTokens: TokenGroup = {};
|
|
87
93
|
|
|
88
94
|
// Font families
|
|
89
95
|
if (fonts.primary) {
|
|
90
96
|
fontTokens.primary = {
|
|
91
|
-
value,
|
|
92
|
-
type,
|
|
93
|
-
description,
|
|
94
|
-
category,
|
|
95
|
-
tags, 'font']
|
|
97
|
+
value: fonts.primary.family,
|
|
98
|
+
type: 'fontFamily',
|
|
99
|
+
description: 'Primary font family',
|
|
100
|
+
category: 'typography',
|
|
101
|
+
tags: ['primary', 'font']
|
|
96
102
|
} as FontToken;
|
|
97
103
|
}
|
|
98
104
|
|
|
99
105
|
if (fonts.secondary) {
|
|
100
106
|
fontTokens.secondary = {
|
|
101
|
-
value,
|
|
102
|
-
type,
|
|
103
|
-
description,
|
|
104
|
-
category,
|
|
105
|
-
tags, 'font']
|
|
107
|
+
value: fonts.secondary.family,
|
|
108
|
+
type: 'fontFamily',
|
|
109
|
+
description: 'Secondary font family',
|
|
110
|
+
category: 'typography',
|
|
111
|
+
tags: ['secondary', 'font']
|
|
106
112
|
} as FontToken;
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
if (fonts.display) {
|
|
110
116
|
fontTokens.display = {
|
|
111
|
-
value,
|
|
112
|
-
type,
|
|
113
|
-
description,
|
|
114
|
-
category,
|
|
115
|
-
tags, 'font']
|
|
117
|
+
value: fonts.display.family,
|
|
118
|
+
type: 'fontFamily',
|
|
119
|
+
description: 'Display font family',
|
|
120
|
+
category: 'typography',
|
|
121
|
+
tags: ['display', 'font']
|
|
116
122
|
} as FontToken;
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
if (fonts.body) {
|
|
120
126
|
fontTokens.body = {
|
|
121
|
-
value,
|
|
122
|
-
type,
|
|
123
|
-
description,
|
|
124
|
-
category,
|
|
125
|
-
tags, 'font']
|
|
127
|
+
value: fonts.body.family,
|
|
128
|
+
type: 'fontFamily',
|
|
129
|
+
description: 'Body font family',
|
|
130
|
+
category: 'typography',
|
|
131
|
+
tags: ['body', 'font']
|
|
126
132
|
} as FontToken;
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
if (fonts.mono) {
|
|
130
136
|
fontTokens.mono = {
|
|
131
|
-
value,
|
|
132
|
-
type,
|
|
133
|
-
description,
|
|
134
|
-
category,
|
|
135
|
-
tags, 'font']
|
|
137
|
+
value: fonts.mono.family,
|
|
138
|
+
type: 'fontFamily',
|
|
139
|
+
description: 'Monospace font family',
|
|
140
|
+
category: 'typography',
|
|
141
|
+
tags: ['mono', 'font']
|
|
136
142
|
} as FontToken;
|
|
137
143
|
}
|
|
138
144
|
|
|
@@ -141,10 +147,10 @@ export class TokenGenerator {
|
|
|
141
147
|
Object.entries(fonts.primary.sizes).forEach(([size, value]) => {
|
|
142
148
|
fontTokens[`size-${size}`] = {
|
|
143
149
|
value,
|
|
144
|
-
type,
|
|
145
|
-
description}`,
|
|
146
|
-
category,
|
|
147
|
-
tags, 'size', size]
|
|
150
|
+
type: 'fontSize',
|
|
151
|
+
description: `Font size - ${size}`,
|
|
152
|
+
category: 'typography',
|
|
153
|
+
tags: ['font', 'size', size]
|
|
148
154
|
} as FontToken;
|
|
149
155
|
});
|
|
150
156
|
}
|
|
@@ -153,11 +159,11 @@ export class TokenGenerator {
|
|
|
153
159
|
if (fonts.primary?.weights) {
|
|
154
160
|
fonts.primary.weights.forEach((weight, index) => {
|
|
155
161
|
fontTokens[`weight-${index}`] = {
|
|
156
|
-
value,
|
|
157
|
-
type,
|
|
158
|
-
description}`,
|
|
159
|
-
category,
|
|
160
|
-
tags, 'weight', weight.toString()]
|
|
162
|
+
value: weight,
|
|
163
|
+
type: 'fontWeight',
|
|
164
|
+
description: `Font weight - ${weight}`,
|
|
165
|
+
category: 'typography',
|
|
166
|
+
tags: ['font', 'weight', weight.toString()]
|
|
161
167
|
} as FontToken;
|
|
162
168
|
});
|
|
163
169
|
}
|
|
@@ -167,10 +173,10 @@ export class TokenGenerator {
|
|
|
167
173
|
Object.entries(fonts.primary.lineHeights).forEach(([height, value]) => {
|
|
168
174
|
fontTokens[`line-height-${height}`] = {
|
|
169
175
|
value,
|
|
170
|
-
type,
|
|
171
|
-
description}`,
|
|
172
|
-
category,
|
|
173
|
-
tags, 'line-height', height]
|
|
176
|
+
type: 'lineHeight',
|
|
177
|
+
description: `Line height - ${height}`,
|
|
178
|
+
category: 'typography',
|
|
179
|
+
tags: ['font', 'line-height', height]
|
|
174
180
|
} as FontToken;
|
|
175
181
|
});
|
|
176
182
|
}
|
|
@@ -180,10 +186,10 @@ export class TokenGenerator {
|
|
|
180
186
|
Object.entries(fonts.primary.letterSpacing).forEach(([spacing, value]) => {
|
|
181
187
|
fontTokens[`letter-spacing-${spacing}`] = {
|
|
182
188
|
value,
|
|
183
|
-
type,
|
|
184
|
-
description}`,
|
|
185
|
-
category,
|
|
186
|
-
tags, 'letter-spacing', spacing]
|
|
189
|
+
type: 'letterSpacing',
|
|
190
|
+
description: `Letter spacing - ${spacing}`,
|
|
191
|
+
category: 'typography',
|
|
192
|
+
tags: ['font', 'letter-spacing', spacing]
|
|
187
193
|
} as FontToken;
|
|
188
194
|
});
|
|
189
195
|
}
|
|
@@ -194,17 +200,18 @@ export class TokenGenerator {
|
|
|
194
200
|
/**
|
|
195
201
|
* Generates spacing tokens from theme spacing
|
|
196
202
|
*/
|
|
197
|
-
private static generateSpacingTokens(spacing])
|
|
203
|
+
private static generateSpacingTokens(spacing: CompleteThemeConfig['spacing']): TokenGroup {
|
|
204
|
+
const spacingTokens: TokenGroup = {};
|
|
198
205
|
|
|
199
206
|
if (spacing) {
|
|
200
207
|
Object.entries(spacing).forEach(([scale, value]) => {
|
|
201
208
|
spacingTokens[scale] = {
|
|
202
209
|
value,
|
|
203
|
-
type,
|
|
204
|
-
unit,
|
|
205
|
-
description}`,
|
|
206
|
-
category,
|
|
207
|
-
tags, 'layout', scale]
|
|
210
|
+
type: 'spacing',
|
|
211
|
+
unit: 'px',
|
|
212
|
+
description: `Spacing scale - ${scale}`,
|
|
213
|
+
category: 'layout',
|
|
214
|
+
tags: ['spacing', 'layout', scale]
|
|
208
215
|
} as SpacingToken;
|
|
209
216
|
});
|
|
210
217
|
}
|
|
@@ -215,17 +222,18 @@ export class TokenGenerator {
|
|
|
215
222
|
/**
|
|
216
223
|
* Generates shadow tokens from theme shadows
|
|
217
224
|
*/
|
|
218
|
-
private static generateShadowTokens(shadows])
|
|
225
|
+
private static generateShadowTokens(shadows: CompleteThemeConfig['shadows']): TokenGroup {
|
|
226
|
+
const shadowTokens: TokenGroup = {};
|
|
219
227
|
|
|
220
228
|
if (shadows) {
|
|
221
229
|
Object.entries(shadows).forEach(([elevation, value]) => {
|
|
222
230
|
shadowTokens[elevation] = {
|
|
223
231
|
value,
|
|
224
|
-
type,
|
|
225
|
-
elevation,
|
|
226
|
-
description} elevation`,
|
|
227
|
-
category,
|
|
228
|
-
tags, 'elevation', elevation]
|
|
232
|
+
type: 'shadow',
|
|
233
|
+
elevation: elevation as 'low' | 'medium' | 'high',
|
|
234
|
+
description: `Shadow - ${elevation} elevation`,
|
|
235
|
+
category: 'effects',
|
|
236
|
+
tags: ['shadow', 'elevation', elevation]
|
|
229
237
|
} as ShadowToken;
|
|
230
238
|
});
|
|
231
239
|
}
|
|
@@ -236,17 +244,18 @@ export class TokenGenerator {
|
|
|
236
244
|
/**
|
|
237
245
|
* Generates transition tokens from theme transitions
|
|
238
246
|
*/
|
|
239
|
-
private static generateTransitionTokens(transitions])
|
|
247
|
+
private static generateTransitionTokens(transitions: CompleteThemeConfig['transitions']): TokenGroup {
|
|
248
|
+
const transitionTokens: TokenGroup = {};
|
|
240
249
|
|
|
241
250
|
if (transitions) {
|
|
242
251
|
Object.entries(transitions).forEach(([name, value]) => {
|
|
243
252
|
transitionTokens[name] = {
|
|
244
253
|
value,
|
|
245
|
-
type,
|
|
246
|
-
easing),
|
|
247
|
-
description}`,
|
|
248
|
-
category,
|
|
249
|
-
tags, 'animation', name]
|
|
254
|
+
type: 'transition',
|
|
255
|
+
easing: this.detectEasing(value),
|
|
256
|
+
description: `Transition - ${name}`,
|
|
257
|
+
category: 'animation',
|
|
258
|
+
tags: ['transition', 'animation', name]
|
|
250
259
|
} as TransitionToken;
|
|
251
260
|
});
|
|
252
261
|
}
|
|
@@ -257,7 +266,7 @@ export class TokenGenerator {
|
|
|
257
266
|
/**
|
|
258
267
|
* Detects easing function from transition value
|
|
259
268
|
*/
|
|
260
|
-
private static detectEasing(transition)] {
|
|
269
|
+
private static detectEasing(transition: string): TransitionToken['easing'] {
|
|
261
270
|
if (transition.includes('ease-in-out')) return 'ease-in-out';
|
|
262
271
|
if (transition.includes('ease-in')) return 'ease-in';
|
|
263
272
|
if (transition.includes('ease-out')) return 'ease-out';
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import type { CompleteThemeConfig } from '../themes/types';
|
|
2
|
+
import type { ThemeTokens, TokenExportOptions } from './types';
|
|
3
3
|
import { TokenGenerator } from './tokenGenerator';
|
|
4
4
|
import { TokenExporter } from './tokenExporter';
|
|
5
5
|
import { TokenValidator, ValidationResult } from './tokenValidator';
|
|
6
6
|
|
|
7
7
|
export interface TokenManagerOptions {
|
|
8
|
-
autoValidate
|
|
9
|
-
autoGenerate
|
|
10
|
-
defaultExportFormat
|
|
11
|
-
includeMetadata
|
|
12
|
-
includeComments
|
|
8
|
+
autoValidate?: boolean;
|
|
9
|
+
autoGenerate?: boolean;
|
|
10
|
+
defaultExportFormat?: TokenExportOptions['format'];
|
|
11
|
+
includeMetadata?: boolean;
|
|
12
|
+
includeComments?: boolean;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export class TokenManager {
|
|
16
|
-
private options;
|
|
17
|
-
private generatedTokens, ThemeTokens> = new Map();
|
|
16
|
+
private options: TokenManagerOptions;
|
|
17
|
+
private generatedTokens: Map<string, ThemeTokens> = new Map();
|
|
18
18
|
|
|
19
|
-
constructor(options= {}) {
|
|
19
|
+
constructor(options: TokenManagerOptions = {}) {
|
|
20
20
|
this.options = {
|
|
21
|
-
autoValidate,
|
|
22
|
-
autoGenerate,
|
|
23
|
-
defaultExportFormat,
|
|
24
|
-
includeMetadata,
|
|
25
|
-
includeComments,
|
|
21
|
+
autoValidate: true,
|
|
22
|
+
autoGenerate: true,
|
|
23
|
+
defaultExportFormat: 'json',
|
|
24
|
+
includeMetadata: true,
|
|
25
|
+
includeComments: true,
|
|
26
26
|
...options
|
|
27
27
|
};
|
|
28
28
|
}
|
|
@@ -30,12 +30,13 @@ export class TokenManager {
|
|
|
30
30
|
/**
|
|
31
31
|
* Generates tokens for a theme configuration
|
|
32
32
|
*/
|
|
33
|
-
generateTokens(themeConfig)
|
|
33
|
+
generateTokens(themeConfig: CompleteThemeConfig): ThemeTokens {
|
|
34
|
+
const tokens = TokenGenerator.generateTokens(themeConfig);
|
|
34
35
|
|
|
35
36
|
if (this.options.autoValidate) {
|
|
36
37
|
const validation = this.validateTokens(tokens);
|
|
37
38
|
if (!validation.isValid) {
|
|
38
|
-
console.warn('Token validation failed, validation.errors);
|
|
39
|
+
console.warn('Token validation failed:', validation.errors);
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
|
|
@@ -46,7 +47,7 @@ export class TokenManager {
|
|
|
46
47
|
/**
|
|
47
48
|
* Generates tokens for multiple themes
|
|
48
49
|
*/
|
|
49
|
-
generateTokensForThemes(themes]), ThemeTokens> {
|
|
50
|
+
generateTokensForThemes(themes: CompleteThemeConfig[]): Map<string, ThemeTokens> {
|
|
50
51
|
themes.forEach(theme => {
|
|
51
52
|
this.generateTokens(theme);
|
|
52
53
|
});
|
|
@@ -57,21 +58,24 @@ export class TokenManager {
|
|
|
57
58
|
/**
|
|
58
59
|
* Validates tokens
|
|
59
60
|
*/
|
|
60
|
-
validateTokens(tokens)
|
|
61
|
+
validateTokens(tokens: ThemeTokens): ValidationResult {
|
|
62
|
+
return TokenValidator.validateTokens(tokens);
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
/**
|
|
64
66
|
* Exports tokens in the specified format
|
|
65
67
|
*/
|
|
66
68
|
exportTokens(
|
|
67
|
-
tokens,
|
|
68
|
-
format
|
|
69
|
-
platform
|
|
70
|
-
)
|
|
71
|
-
|
|
69
|
+
tokens: ThemeTokens,
|
|
70
|
+
format?: TokenExportOptions['format'],
|
|
71
|
+
platform?: TokenExportOptions['platform']
|
|
72
|
+
): string {
|
|
73
|
+
const options: TokenExportOptions = {
|
|
74
|
+
format: format || this.options.defaultExportFormat!,
|
|
72
75
|
platform,
|
|
73
|
-
includeMetadata,
|
|
74
|
-
includeComments
|
|
76
|
+
includeMetadata: this.options.includeMetadata,
|
|
77
|
+
includeComments: this.options.includeComments
|
|
78
|
+
};
|
|
75
79
|
|
|
76
80
|
return TokenExporter.exportTokens(tokens, options);
|
|
77
81
|
}
|
|
@@ -79,7 +83,7 @@ export class TokenManager {
|
|
|
79
83
|
/**
|
|
80
84
|
* Exports all generated tokens
|
|
81
85
|
*/
|
|
82
|
-
exportAllTokens(format
|
|
86
|
+
exportAllTokens(format?: TokenExportOptions['format']): Map<string, string> {
|
|
83
87
|
const exports = new Map<string, string>();
|
|
84
88
|
|
|
85
89
|
this.generatedTokens.forEach((tokens, themeName) => {
|
|
@@ -93,9 +97,10 @@ export class TokenManager {
|
|
|
93
97
|
/**
|
|
94
98
|
* Exports tokens for a specific theme
|
|
95
99
|
*/
|
|
96
|
-
exportThemeTokens(themeName, format
|
|
100
|
+
exportThemeTokens(themeName: string, format?: TokenExportOptions['format']): string | null {
|
|
101
|
+
const tokens = this.generatedTokens.get(themeName);
|
|
97
102
|
if (!tokens) {
|
|
98
|
-
console.warn(`No tokens found for theme}`);
|
|
103
|
+
console.warn(`No tokens found for theme: ${themeName}`);
|
|
99
104
|
return null;
|
|
100
105
|
}
|
|
101
106
|
|
|
@@ -105,38 +110,42 @@ export class TokenManager {
|
|
|
105
110
|
/**
|
|
106
111
|
* Gets generated tokens for a theme
|
|
107
112
|
*/
|
|
108
|
-
getTokens(themeName)
|
|
113
|
+
getTokens(themeName: string): ThemeTokens | undefined {
|
|
114
|
+
return this.generatedTokens.get(themeName);
|
|
109
115
|
}
|
|
110
116
|
|
|
111
117
|
/**
|
|
112
118
|
* Gets all generated tokens
|
|
113
119
|
*/
|
|
114
|
-
getAllTokens(), ThemeTokens> {
|
|
120
|
+
getAllTokens(): Map<string, ThemeTokens> {
|
|
115
121
|
return new Map(this.generatedTokens);
|
|
116
122
|
}
|
|
117
123
|
|
|
118
124
|
/**
|
|
119
125
|
* Clears all generated tokens
|
|
120
126
|
*/
|
|
121
|
-
clearTokens()
|
|
127
|
+
clearTokens(): void {
|
|
128
|
+
this.generatedTokens.clear();
|
|
122
129
|
}
|
|
123
130
|
|
|
124
131
|
/**
|
|
125
132
|
* Removes tokens for a specific theme
|
|
126
133
|
*/
|
|
127
|
-
removeTokens(themeName)
|
|
134
|
+
removeTokens(themeName: string): boolean {
|
|
135
|
+
return this.generatedTokens.delete(themeName);
|
|
128
136
|
}
|
|
129
137
|
|
|
130
138
|
/**
|
|
131
139
|
* Gets token statistics
|
|
132
140
|
*/
|
|
133
|
-
getTokenStats()
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
getTokenStats(): {
|
|
142
|
+
totalThemes: number;
|
|
143
|
+
totalTokens: number;
|
|
144
|
+
tokenBreakdown: Record<string, number>;
|
|
136
145
|
} {
|
|
137
146
|
const totalThemes = this.generatedTokens.size;
|
|
138
147
|
let totalTokens = 0;
|
|
139
|
-
const tokenBreakdown, number> = {};
|
|
148
|
+
const tokenBreakdown: Record<string, number> = {};
|
|
140
149
|
|
|
141
150
|
this.generatedTokens.forEach(tokens => {
|
|
142
151
|
Object.entries(tokens.tokens).forEach(([category, categoryTokens]) => {
|
|
@@ -158,7 +167,8 @@ export class TokenManager {
|
|
|
158
167
|
/**
|
|
159
168
|
* Counts tokens in a token group recursively
|
|
160
169
|
*/
|
|
161
|
-
private countTokensInGroup(group)
|
|
170
|
+
private countTokensInGroup(group: any): number {
|
|
171
|
+
let count = 0;
|
|
162
172
|
|
|
163
173
|
Object.values(group).forEach(value => {
|
|
164
174
|
if (value && typeof value === 'object') {
|
|
@@ -178,25 +188,28 @@ export class TokenManager {
|
|
|
178
188
|
/**
|
|
179
189
|
* Updates manager options
|
|
180
190
|
*/
|
|
181
|
-
updateOptions(newOptions)
|
|
191
|
+
updateOptions(newOptions: Partial<TokenManagerOptions>): void {
|
|
192
|
+
this.options = { ...this.options, ...newOptions };
|
|
182
193
|
}
|
|
183
194
|
|
|
184
195
|
/**
|
|
185
196
|
* Gets current manager options
|
|
186
197
|
*/
|
|
187
|
-
getOptions()
|
|
198
|
+
getOptions(): TokenManagerOptions {
|
|
199
|
+
return { ...this.options };
|
|
188
200
|
}
|
|
189
201
|
|
|
190
202
|
/**
|
|
191
203
|
* Exports tokens to file (simulated - in real implementation would write to filesystem)
|
|
192
204
|
*/
|
|
193
205
|
exportToFile(
|
|
194
|
-
themeName,
|
|
195
|
-
format] = 'json',
|
|
196
|
-
filename
|
|
206
|
+
themeName: string,
|
|
207
|
+
format: TokenExportOptions['format'] = 'json',
|
|
208
|
+
filename?: string
|
|
209
|
+
): { success: boolean; filename: string; content: string } {
|
|
197
210
|
const tokens = this.generatedTokens.get(themeName);
|
|
198
211
|
if (!tokens) {
|
|
199
|
-
throw new Error(`No tokens found for theme}`);
|
|
212
|
+
throw new Error(`No tokens found for theme: ${themeName}`);
|
|
200
213
|
}
|
|
201
214
|
|
|
202
215
|
const content = this.exportTokens(tokens, format);
|
|
@@ -205,8 +218,8 @@ export class TokenManager {
|
|
|
205
218
|
// In a real implementation, this would write to the filesystem
|
|
206
219
|
// For now, we'll just return the content and filename
|
|
207
220
|
return {
|
|
208
|
-
success,
|
|
209
|
-
filename,
|
|
221
|
+
success: true,
|
|
222
|
+
filename: finalFilename,
|
|
210
223
|
content
|
|
211
224
|
};
|
|
212
225
|
}
|
|
@@ -214,8 +227,8 @@ export class TokenManager {
|
|
|
214
227
|
/**
|
|
215
228
|
* Exports all themes to files
|
|
216
229
|
*/
|
|
217
|
-
exportAllToFiles(format
|
|
218
|
-
const exports = new Map<string, { success; filename; content}>();
|
|
230
|
+
exportAllToFiles(format?: TokenExportOptions['format']): Map<string, { success: boolean; filename: string; content: string }> {
|
|
231
|
+
const exports = new Map<string, { success: boolean; filename: string; content: string }>();
|
|
219
232
|
|
|
220
233
|
this.generatedTokens.forEach((_tokens, themeName) => {
|
|
221
234
|
try {
|
|
@@ -223,9 +236,9 @@ export class TokenManager {
|
|
|
223
236
|
exports.set(themeName, result);
|
|
224
237
|
} catch (error) {
|
|
225
238
|
exports.set(themeName, {
|
|
226
|
-
success,
|
|
227
|
-
filename}-tokens.${format}`,
|
|
228
|
-
content}`
|
|
239
|
+
success: false,
|
|
240
|
+
filename: `${themeName}-tokens.${format}`,
|
|
241
|
+
content: `Error: ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
229
242
|
});
|
|
230
243
|
}
|
|
231
244
|
});
|