@idealyst/theme 1.0.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.
@@ -0,0 +1,238 @@
1
+ import {
2
+ createTheme,
3
+ generateColorPalette,
4
+ createLightResolvedIntents,
5
+ createDarkResolvedIntents,
6
+ createLightResolvedColors,
7
+ createDarkResolvedColors,
8
+ type ThemeConfig
9
+ } from './themeBuilder';
10
+ import { commonThemeProperties } from './common';
11
+
12
+ // =============================================================================
13
+ // DEFAULT PALETTES
14
+ // =============================================================================
15
+
16
+ /**
17
+ * Helper function to create standard color palettes
18
+ */
19
+ export function createStandardPalettes(): ThemeConfig['palettes'] {
20
+ return {
21
+ red: generateColorPalette('#ef4444'),
22
+ orange: generateColorPalette('#f97316'),
23
+ yellow: generateColorPalette('#eab308'),
24
+ green: generateColorPalette('#22c55e'),
25
+ blue: generateColorPalette('#3b82f6'),
26
+ purple: generateColorPalette('#a855f7'),
27
+ black: generateColorPalette('#000000'),
28
+ gray: generateColorPalette('#6b7280'),
29
+ white: generateColorPalette('#ffffff'),
30
+ };
31
+ }
32
+
33
+ /**
34
+ * Helper function to create dark theme palettes with proper dark mode colors
35
+ */
36
+ export function createDarkPalettes(): ThemeConfig['palettes'] {
37
+ const basePalettes = createStandardPalettes();
38
+
39
+ return {
40
+ ...basePalettes,
41
+ // Adjusted gray palette for dark theme
42
+ gray: {
43
+ 50: '#18181b', // Very dark background
44
+ 100: '#27272a', // Dark surface
45
+ 200: '#3f3f46', // Medium dark
46
+ 300: '#52525b', // Medium
47
+ 400: '#71717a', // Medium light
48
+ 500: '#a1a1aa', // Light gray
49
+ 600: '#d4d4d8', // Lighter gray
50
+ 700: '#e4e4e7', // Very light gray
51
+ 800: '#f4f4f5', // Nearly white
52
+ 900: '#fafafa', // White
53
+ },
54
+ // Adjusted black palette for dark theme
55
+ black: {
56
+ 50: '#000000', // Pure black
57
+ 100: '#0a0a0a', // Very dark
58
+ 200: '#141414', // Dark
59
+ 300: '#1f1f1f', // Medium dark
60
+ 400: '#2a2a2a', // Medium
61
+ 500: '#3c3c3c', // Medium light
62
+ 600: '#525252', // Light
63
+ 700: '#737373', // Lighter
64
+ 800: '#a3a3a3', // Very light
65
+ 900: '#d4d4d4', // Nearly white
66
+ },
67
+ // Adjusted white palette for dark theme
68
+ white: {
69
+ 50: '#0c0c0c', // Very dark (inverted)
70
+ 100: '#171717', // Dark
71
+ 200: '#262626', // Medium dark
72
+ 300: '#404040', // Medium
73
+ 400: '#525252', // Medium light
74
+ 500: '#737373', // Light
75
+ 600: '#a3a3a3', // Lighter
76
+ 700: '#d4d4d4', // Very light
77
+ 800: '#f5f5f5', // Nearly white
78
+ 900: '#ffffff', // Pure white
79
+ },
80
+ };
81
+ }
82
+
83
+ // Convenience functions for complete theme creation
84
+ export function createLightIntentMappings(): ThemeConfig['intents'] {
85
+ const palettes = createStandardPalettes();
86
+ return createLightResolvedIntents(palettes);
87
+ }
88
+
89
+ export function createDarkIntentMappings(): ThemeConfig['intents'] {
90
+ const palettes = createDarkPalettes();
91
+ return createDarkResolvedIntents(palettes);
92
+ }
93
+
94
+ export function createLightColorMappings(): ThemeConfig['colors'] {
95
+ const palettes = createStandardPalettes();
96
+ return createLightResolvedColors(palettes);
97
+ }
98
+
99
+ export function createDarkColorMappings(): ThemeConfig['colors'] {
100
+ const palettes = createDarkPalettes();
101
+ return createDarkResolvedColors(palettes);
102
+ }
103
+
104
+ // Create default light theme using the explicit theme builder
105
+ export function createDefaultLightTheme() {
106
+ return createTheme({
107
+ name: 'DefaultLight',
108
+ mode: 'light',
109
+ palettes: createStandardPalettes(),
110
+ intents: createLightIntentMappings(),
111
+ colors: createLightColorMappings(),
112
+
113
+ typography: {
114
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
115
+ },
116
+
117
+ borderRadius: {
118
+ sm: 4,
119
+ md: 8,
120
+ lg: 12,
121
+ xl: 16,
122
+ xxl: 20,
123
+ },
124
+
125
+ spacing: {
126
+ xs: 4,
127
+ sm: 8,
128
+ md: 16,
129
+ lg: 24,
130
+ xl: 32,
131
+ xxl: 40,
132
+ xxxl: 48,
133
+ },
134
+
135
+ shadows: {
136
+ sm: {
137
+ shadowColor: '#000',
138
+ shadowOffset: { width: 0, height: 1 },
139
+ shadowOpacity: 0.05,
140
+ shadowRadius: 2,
141
+ elevation: 1,
142
+ },
143
+ md: {
144
+ shadowColor: '#000',
145
+ shadowOffset: { width: 0, height: 4 },
146
+ shadowOpacity: 0.1,
147
+ shadowRadius: 8,
148
+ elevation: 4,
149
+ },
150
+ lg: {
151
+ shadowColor: '#000',
152
+ shadowOffset: { width: 0, height: 8 },
153
+ shadowOpacity: 0.15,
154
+ shadowRadius: 16,
155
+ elevation: 8,
156
+ },
157
+ },
158
+
159
+ transitions: {
160
+ fast: '0.15s ease',
161
+ base: '0.2s ease',
162
+ slow: '0.3s ease',
163
+ button: 'all 0.2s ease',
164
+ fade: 'opacity 0.2s ease',
165
+ slide: 'transform 0.3s ease',
166
+ },
167
+ });
168
+ }
169
+
170
+ // Create default dark theme using the explicit theme builder
171
+ export function createDefaultDarkTheme() {
172
+ return createTheme({
173
+ name: 'DefaultDark',
174
+ mode: 'dark',
175
+ palettes: createDarkPalettes(),
176
+ intents: createDarkIntentMappings(),
177
+ colors: createDarkColorMappings(),
178
+
179
+ typography: {
180
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
181
+ },
182
+
183
+ borderRadius: {
184
+ sm: 4,
185
+ md: 8,
186
+ lg: 12,
187
+ xl: 16,
188
+ xxl: 20,
189
+ },
190
+
191
+ spacing: {
192
+ xs: 4,
193
+ sm: 8,
194
+ md: 16,
195
+ lg: 24,
196
+ xl: 32,
197
+ xxl: 40,
198
+ xxxl: 48,
199
+ },
200
+
201
+ shadows: {
202
+ sm: {
203
+ shadowColor: '#000',
204
+ shadowOffset: { width: 0, height: 1 },
205
+ shadowOpacity: 0.2,
206
+ shadowRadius: 2,
207
+ elevation: 1,
208
+ },
209
+ md: {
210
+ shadowColor: '#000',
211
+ shadowOffset: { width: 0, height: 4 },
212
+ shadowOpacity: 0.3,
213
+ shadowRadius: 8,
214
+ elevation: 4,
215
+ },
216
+ lg: {
217
+ shadowColor: '#000',
218
+ shadowOffset: { width: 0, height: 8 },
219
+ shadowOpacity: 0.4,
220
+ shadowRadius: 16,
221
+ elevation: 8,
222
+ },
223
+ },
224
+
225
+ transitions: {
226
+ fast: '0.15s ease',
227
+ base: '0.2s ease',
228
+ slow: '0.3s ease',
229
+ button: 'all 0.2s ease',
230
+ fade: 'opacity 0.2s ease',
231
+ slide: 'transform 0.3s ease',
232
+ },
233
+ });
234
+ }
235
+
236
+ // Export the created themes
237
+ export const defaultLightTheme = createDefaultLightTheme();
238
+ export const defaultDarkTheme = createDefaultDarkTheme();
package/src/index.ts ADDED
@@ -0,0 +1,166 @@
1
+ // =============================================================================
2
+ // THEME PACKAGE - Complete theming solution
3
+ // =============================================================================
4
+
5
+ // Import everything we need first
6
+ import {
7
+ generateColorPalette,
8
+ lighten,
9
+ darken,
10
+ createLightResolvedIntents,
11
+ createDarkResolvedIntents,
12
+ createLightResolvedColors,
13
+ createDarkResolvedColors,
14
+ extendTheme,
15
+ type ThemeConfig,
16
+ type ThemeColorPalette,
17
+ type ResolvedIntent,
18
+ type ThemeColorSystem,
19
+ createTheme,
20
+ } from './themeBuilder';
21
+
22
+ import {
23
+ createDefaultLightTheme,
24
+ createDefaultDarkTheme,
25
+ createStandardPalettes,
26
+ createDarkPalettes,
27
+ createLightIntentMappings,
28
+ createDarkIntentMappings,
29
+ createLightColorMappings,
30
+ createDarkColorMappings,
31
+ defaultLightTheme,
32
+ defaultDarkTheme,
33
+ } from './defaultThemes';
34
+
35
+ import { commonThemeProperties } from './common';
36
+
37
+ import { breakpoints } from './breakpoints';
38
+ // Note: Removed import from ../unistyles to prevent circular dependency
39
+ // when navigation package imports from this theme index
40
+
41
+ // Re-export everything for external use
42
+ export {
43
+ // Primary theme creation functions - exported directly
44
+ createTheme,
45
+ extendTheme,
46
+
47
+ // Core theme building functionality
48
+ generateColorPalette,
49
+ lighten,
50
+ darken,
51
+ createLightResolvedIntents,
52
+ createDarkResolvedIntents,
53
+ createLightResolvedColors,
54
+ createDarkResolvedColors,
55
+
56
+ // Type definitions
57
+ type ThemeConfig,
58
+ type ThemeColorPalette,
59
+ type ResolvedIntent,
60
+ type ThemeColorSystem,
61
+
62
+ // Default themes and palettes
63
+ createDefaultLightTheme,
64
+ createDefaultDarkTheme,
65
+ createStandardPalettes,
66
+ createDarkPalettes,
67
+ createLightIntentMappings,
68
+ createDarkIntentMappings,
69
+ createLightColorMappings,
70
+ createDarkColorMappings,
71
+ defaultLightTheme,
72
+ defaultDarkTheme,
73
+ commonThemeProperties,
74
+
75
+ // Breakpoints for responsive design
76
+ breakpoints,
77
+ };
78
+
79
+ // Individual theme exports for backward compatibility
80
+ export const lightTheme = defaultLightTheme;
81
+ export const darkTheme = defaultDarkTheme;
82
+
83
+ // =============================================================================
84
+ // THEME PRESETS - Ready-to-use theme configurations
85
+ // =============================================================================
86
+
87
+ /**
88
+ * Complete theme presets ready for immediate use
89
+ */
90
+ export const themePresets = {
91
+ // Standard themes
92
+ light: defaultLightTheme,
93
+ dark: defaultDarkTheme,
94
+ } as const;
95
+
96
+ /**
97
+ * Theme creation utilities
98
+ */
99
+ export const themeUtils = {
100
+ // Color palette generation
101
+ generateColorPalette,
102
+ lighten,
103
+ darken,
104
+
105
+ // Palette creators
106
+ createStandardPalettes,
107
+ createDarkPalettes,
108
+
109
+ // Intent creators
110
+ createLightIntentMappings,
111
+ createDarkIntentMappings,
112
+
113
+ // Color system creators
114
+ createLightColorMappings,
115
+ createDarkColorMappings,
116
+ } as const;
117
+
118
+ /**
119
+ * Type definitions for theme-related interfaces
120
+ */
121
+ export type ThemePreset = keyof typeof themePresets;
122
+ export type ThemeMode = 'light' | 'dark';
123
+ export type AppTheme = typeof defaultLightTheme; // Define AppTheme to avoid circular dependency
124
+
125
+ // =============================================================================
126
+ // CONVENIENCE EXPORTS - For common use cases
127
+ // =============================================================================
128
+
129
+ /**
130
+ * Quick access to commonly used themes
131
+ */
132
+ export const quickThemes = {
133
+ light: defaultLightTheme,
134
+ dark: defaultDarkTheme,
135
+ } as const;
136
+
137
+ /**
138
+ * All available color palettes (standard + extended)
139
+ */
140
+ export const allColorPalettes = {
141
+ ...createStandardPalettes(),
142
+ ...createDarkPalettes(),
143
+ } as const;
144
+
145
+ // =============================================================================
146
+ // DOCUMENTATION HELPERS
147
+ // =============================================================================
148
+
149
+ /**
150
+ * Theme documentation and examples
151
+ */
152
+ export const themeDocumentation = {
153
+ description: 'Complete theming system for cross-platform React components',
154
+ availableThemes: Object.keys(themePresets),
155
+ availablePalettes: Object.keys(allColorPalettes),
156
+ themeStructure: {
157
+ palettes: 'Color palettes with 50-900 shades',
158
+ intents: 'Semantic color mappings (primary, success, error, etc.)',
159
+ colors: 'Component color system (text, surface, border, interactive)',
160
+ typography: 'Font families, sizes, weights, and line heights',
161
+ spacing: 'Consistent spacing scale',
162
+ borderRadius: 'Border radius scale',
163
+ shadows: 'Shadow definitions for elevation',
164
+ transitions: 'Animation timing definitions',
165
+ },
166
+ } as const;