@idealyst/theme 1.0.39 → 1.0.40

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/src/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # Theme System Components
2
+
3
+ This directory contains the core components of the @idealyst/theme system. Each file serves a specific purpose in the theming architecture.
4
+
5
+ ## File Overview
6
+
7
+ | File | Purpose | Key Exports |
8
+ |------|---------|-------------|
9
+ | **[themeBuilder.ts](themeBuilder.md)** | Core theme creation utilities | `createTheme`, `extendTheme`, `generateColorPalette` |
10
+ | **[defaultThemes.ts](defaultThemes.md)** | Pre-built light and dark themes | `defaultLightTheme`, `defaultDarkTheme` |
11
+ | **[colors.ts](colors.md)** | Base color palette definitions | `colorPalettes` (8 palettes × 10 shades) |
12
+ | **[colorResolver.ts](colorResolver.md)** | Color resolution and utilities | Color manipulation functions |
13
+ | **[variants.ts](variants.md)** | Type definitions for color variants | `ColorVariant`, `IntentVariant` types |
14
+ | **[variantHelpers.ts](variantHelpers.md)** | Variant utility functions | Helper functions for variants |
15
+ | **[breakpoints.ts](breakpoints.md)** | Responsive design breakpoints | `breakpoints` object |
16
+ | **[common.ts](common.md)** | Shared theme properties | Typography, spacing, shadows |
17
+ | **[unistyles.ts](unistyles.md)** | Unistyles integration | Theme registration utilities |
18
+
19
+ ## Architecture Overview
20
+
21
+ ### Core Theme Creation Flow
22
+
23
+ 1. **Color Palettes** (`colors.ts`) - Base color definitions
24
+ 2. **Color Resolution** (`colorResolver.ts`) - Color manipulation and generation
25
+ 3. **Theme Builder** (`themeBuilder.ts`) - Combines palettes into complete themes
26
+ 4. **Default Themes** (`defaultThemes.ts`) - Pre-configured light/dark themes
27
+ 5. **Unistyles Integration** (`unistyles.ts`) - Registration with styling system
28
+
29
+ ### Type System
30
+
31
+ 1. **Variants** (`variants.ts`) - Core type definitions
32
+ 2. **Variant Helpers** (`variantHelpers.ts`) - Utility functions for types
33
+ 3. **Common Properties** (`common.ts`) - Shared theme structure
34
+
35
+ ### Responsive System
36
+
37
+ 1. **Breakpoints** (`breakpoints.ts`) - Screen size definitions
38
+ 2. **Theme Builder** - Integrates breakpoints into themes
39
+
40
+ ## Usage Patterns
41
+
42
+ ### Creating a Custom Theme
43
+
44
+ ```tsx
45
+ import { createTheme, generateColorPalette } from './themeBuilder';
46
+
47
+ const customTheme = createTheme({
48
+ palettes: {
49
+ brand: generateColorPalette('#8b5cf6'),
50
+ // ... other palettes
51
+ },
52
+ intents: {
53
+ primary: 'brand',
54
+ // ... other intents
55
+ },
56
+ });
57
+ ```
58
+
59
+ ### Extending Existing Themes
60
+
61
+ ```tsx
62
+ import { extendTheme } from './themeBuilder';
63
+ import { defaultLightTheme } from './defaultThemes';
64
+
65
+ const brandedTheme = extendTheme(defaultLightTheme, {
66
+ palettes: {
67
+ brand: generateColorPalette('#8b5cf6'),
68
+ },
69
+ });
70
+ ```
71
+
72
+ ### Using Color Utilities
73
+
74
+ ```tsx
75
+ import { lighten, darken } from './colorResolver';
76
+
77
+ const lighterBlue = lighten('#3b82f6', 0.2);
78
+ const darkerBlue = darken('#3b82f6', 0.2);
79
+ ```
80
+
81
+ ## Key Concepts
82
+
83
+ ### Color Palettes
84
+ Each color palette contains 10 shades (50-900) with 500 being the base color.
85
+
86
+ ### Intent System
87
+ Semantic color mappings that provide consistent meaning across components:
88
+ - `primary` - Main brand actions
89
+ - `success` - Positive actions
90
+ - `error` - Destructive actions
91
+ - `warning` - Caution actions
92
+ - `neutral` - Secondary actions
93
+
94
+ ### Component Color System
95
+ Structured color mapping for UI components:
96
+ - `text` - Text colors for different contexts
97
+ - `surface` - Background colors for surfaces
98
+ - `border` - Border colors for different states
99
+ - `interactive` - Colors for interactive states
100
+
101
+ ### Theme Structure
102
+ ```tsx
103
+ interface AppTheme {
104
+ palettes: Record<string, ThemeColorPalette>;
105
+ intents: Record<string, ResolvedIntent>;
106
+ colors: ThemeColorSystem;
107
+ typography: TypographySystem;
108
+ spacing: SpacingSystem;
109
+ borderRadius: BorderRadiusSystem;
110
+ shadows: ShadowSystem;
111
+ transitions: TransitionSystem;
112
+ breakpoints: BreakpointSystem;
113
+ }
114
+ ```
115
+
116
+ ## Best Practices
117
+
118
+ 1. **Use Intent Colors**: Prefer intent-based colors over direct palette access
119
+ 2. **Leverage Color Generation**: Use `generateColorPalette` for consistent color scales
120
+ 3. **Extend Don't Replace**: Use `extendTheme` to modify existing themes
121
+ 4. **Type Safety**: Leverage TypeScript for theme validation
122
+ 5. **Responsive Design**: Use breakpoints for screen-size adaptations
123
+ 6. **Accessibility**: Ensure sufficient contrast ratios in custom themes
124
+
125
+ ## Performance Considerations
126
+
127
+ - Themes are computed once and cached
128
+ - Color generation is optimized for minimal computation
129
+ - Type checking happens at build time, not runtime
130
+ - Unistyles provides efficient style updates
131
+
132
+ ## Development Workflow
133
+
134
+ 1. **Theme Creation**: Start with `themeBuilder.ts` functions
135
+ 2. **Color Customization**: Modify palettes in `colors.ts` or use generators
136
+ 3. **Component Integration**: Use structured color system from themes
137
+ 4. **Responsive Design**: Leverage breakpoints for adaptive layouts
138
+ 5. **Testing**: Validate themes in both light and dark modes
package/src/colors.md ADDED
@@ -0,0 +1,353 @@
1
+ # Color Palettes
2
+
3
+ Base color palette definitions that serve as the foundation for the entire theme system.
4
+
5
+ ## Overview
6
+
7
+ The colors module defines 8 comprehensive color palettes, each with 10 carefully crafted shades (50-900). These palettes provide the raw material for creating consistent, accessible, and visually appealing themes.
8
+
9
+ ## Color Palette Structure
10
+
11
+ Each palette follows a consistent structure with 10 shades:
12
+
13
+ - **50-200**: Very light shades (backgrounds, subtle accents)
14
+ - **300-400**: Light shades (secondary elements, hover states)
15
+ - **500**: Base color (primary brand color, main actions)
16
+ - **600-700**: Medium shades (interactive states, emphasis)
17
+ - **800-900**: Dark shades (text, high contrast elements)
18
+
19
+ ## Available Palettes
20
+
21
+ ### Blue Palette (Primary Brand)
22
+ Perfect for primary actions, links, and brand elements.
23
+
24
+ ```tsx
25
+ blue: {
26
+ 50: '#eff6ff', // Very light blue background
27
+ 100: '#dbeafe', // Light blue background
28
+ 200: '#bfdbfe', // Subtle blue
29
+ 300: '#93c5fd', // Light interactive blue
30
+ 400: '#60a5fa', // Medium blue
31
+ 500: '#3b82f6', // Base blue (primary brand)
32
+ 600: '#2563eb', // Focused blue
33
+ 700: '#1d4ed8', // Pressed blue
34
+ 800: '#1e40af', // Dark blue
35
+ 900: '#1e3a8a', // Very dark blue (text)
36
+ }
37
+ ```
38
+
39
+ **Use Cases:**
40
+ - Primary buttons and CTAs
41
+ - Links and navigation
42
+ - Brand elements
43
+ - Focus indicators
44
+
45
+ ### Green Palette (Success)
46
+ Ideal for success states, confirmations, and positive actions.
47
+
48
+ ```tsx
49
+ green: {
50
+ 50: '#f0fdf4', // Success background
51
+ 100: '#dcfce7', // Light success
52
+ 200: '#bbf7d0', // Subtle success
53
+ 300: '#86efac', // Light success interactive
54
+ 400: '#4ade80', // Medium success
55
+ 500: '#22c55e', // Base success
56
+ 600: '#16a34a', // Focused success
57
+ 700: '#15803d', // Pressed success
58
+ 800: '#166534', // Dark success
59
+ 900: '#14532d', // Very dark success
60
+ }
61
+ ```
62
+
63
+ **Use Cases:**
64
+ - Success messages and notifications
65
+ - Confirmation buttons
66
+ - Valid form states
67
+ - Positive status indicators
68
+
69
+ ### Red Palette (Error)
70
+ Essential for error states, warnings, and destructive actions.
71
+
72
+ ```tsx
73
+ red: {
74
+ 50: '#fef2f2', // Error background
75
+ 100: '#fee2e2', // Light error
76
+ 200: '#fecaca', // Subtle error
77
+ 300: '#fca5a5', // Light error interactive
78
+ 400: '#f87171', // Medium error
79
+ 500: '#ef4444', // Base error
80
+ 600: '#dc2626', // Focused error
81
+ 700: '#b91c1c', // Pressed error
82
+ 800: '#991b1b', // Dark error
83
+ 900: '#7f1d1d', // Very dark error
84
+ }
85
+ ```
86
+
87
+ **Use Cases:**
88
+ - Error messages and alerts
89
+ - Delete and destructive actions
90
+ - Invalid form states
91
+ - Critical notifications
92
+
93
+ ### Amber Palette (Warning)
94
+ Perfect for warning states and caution indicators.
95
+
96
+ ```tsx
97
+ amber: {
98
+ 50: '#fffbeb', // Warning background
99
+ 100: '#fef3c7', // Light warning
100
+ 200: '#fde68a', // Subtle warning
101
+ 300: '#fcd34d', // Light warning interactive
102
+ 400: '#fbbf24', // Medium warning
103
+ 500: '#f59e0b', // Base warning
104
+ 600: '#d97706', // Focused warning
105
+ 700: '#b45309', // Pressed warning
106
+ 800: '#92400e', // Dark warning
107
+ 900: '#78350f', // Very dark warning
108
+ }
109
+ ```
110
+
111
+ **Use Cases:**
112
+ - Warning messages
113
+ - Caution alerts
114
+ - Pending states
115
+ - Important notices
116
+
117
+ ### Gray Palette (Neutral)
118
+ Fundamental for text, borders, and neutral interface elements.
119
+
120
+ ```tsx
121
+ gray: {
122
+ 50: '#f9fafb', // Very light background
123
+ 100: '#f3f4f6', // Light background
124
+ 200: '#e5e7eb', // Subtle borders
125
+ 300: '#d1d5db', // Light borders
126
+ 400: '#9ca3af', // Placeholder text
127
+ 500: '#6b7280', // Secondary text
128
+ 600: '#4b5563', // Primary text (light theme)
129
+ 700: '#374151', // Dark text
130
+ 800: '#1f2937', // Very dark text
131
+ 900: '#111827', // Darkest text
132
+ }
133
+ ```
134
+
135
+ **Use Cases:**
136
+ - Text colors (all hierarchies)
137
+ - Borders and dividers
138
+ - Neutral backgrounds
139
+ - Disabled states
140
+
141
+ ### Cyan Palette (Info)
142
+ Great for informational states and secondary accents.
143
+
144
+ ```tsx
145
+ cyan: {
146
+ 50: '#ecfeff', // Info background
147
+ 100: '#cffafe', // Light info
148
+ 200: '#a5f3fc', // Subtle info
149
+ 300: '#67e8f9', // Light info interactive
150
+ 400: '#22d3ee', // Medium info
151
+ 500: '#06b6d4', // Base info
152
+ 600: '#0891b2', // Focused info
153
+ 700: '#0e7490', // Pressed info
154
+ 800: '#155e75', // Dark info
155
+ 900: '#164e63', // Very dark info
156
+ }
157
+ ```
158
+
159
+ **Use Cases:**
160
+ - Info messages and tooltips
161
+ - Secondary brand colors
162
+ - Highlight elements
163
+ - Interactive accents
164
+
165
+ ### Purple Palette (Accent)
166
+ Excellent for premium features and creative accents.
167
+
168
+ ```tsx
169
+ purple: {
170
+ 50: '#faf5ff', // Purple background
171
+ 100: '#f3e8ff', // Light purple
172
+ 200: '#e9d5ff', // Subtle purple
173
+ 300: '#d8b4fe', // Light purple interactive
174
+ 400: '#c084fc', // Medium purple
175
+ 500: '#a855f7', // Base purple
176
+ 600: '#9333ea', // Focused purple
177
+ 700: '#7c3aed', // Pressed purple
178
+ 800: '#6b21b6', // Dark purple
179
+ 900: '#581c87', // Very dark purple
180
+ }
181
+ ```
182
+
183
+ **Use Cases:**
184
+ - Premium feature indicators
185
+ - Creative/artistic elements
186
+ - Secondary accent colors
187
+ - Special promotions
188
+
189
+ ### Pink Palette (Accent)
190
+ Perfect for creative applications and warm accents.
191
+
192
+ ```tsx
193
+ pink: {
194
+ 50: '#fdf2f8', // Pink background
195
+ 100: '#fce7f3', // Light pink
196
+ 200: '#fbcfe8', // Subtle pink
197
+ 300: '#f9a8d4', // Light pink interactive
198
+ 400: '#f472b6', // Medium pink
199
+ 500: '#ec4899', // Base pink
200
+ 600: '#db2777', // Focused pink
201
+ 700: '#be185d', // Pressed pink
202
+ 800: '#9d174d', // Dark pink
203
+ 900: '#831843', // Very dark pink
204
+ }
205
+ ```
206
+
207
+ **Use Cases:**
208
+ - Creative and playful elements
209
+ - Warm accent colors
210
+ - Fashion/lifestyle applications
211
+ - Special occasions
212
+
213
+ ## Color Usage Guidelines
214
+
215
+ ### Shade Selection
216
+
217
+ **Light Themes:**
218
+ - **Backgrounds**: Use shades 50-100
219
+ - **Subtle elements**: Use shades 100-200
220
+ - **Interactive elements**: Use shades 400-600
221
+ - **Text on light**: Use shades 600-900
222
+
223
+ **Dark Themes:**
224
+ - **Backgrounds**: Use shades 800-900
225
+ - **Subtle elements**: Use shades 700-800
226
+ - **Interactive elements**: Use shades 300-500
227
+ - **Text on dark**: Use shades 50-300
228
+
229
+ ### Accessibility Considerations
230
+
231
+ **Contrast Ratios:**
232
+ - **Normal text**: Minimum 4.5:1 contrast ratio
233
+ - **Large text**: Minimum 3:1 contrast ratio
234
+ - **UI elements**: Minimum 3:1 contrast ratio
235
+
236
+ **Recommended Combinations:**
237
+ ```tsx
238
+ // Light theme text on backgrounds
239
+ textOnLight: {
240
+ primary: gray[800], // 4.5:1+ contrast
241
+ secondary: gray[600], // 4.5:1+ contrast
242
+ disabled: gray[400], // 3:1+ contrast
243
+ }
244
+
245
+ // Dark theme text on backgrounds
246
+ textOnDark: {
247
+ primary: gray[100], // 4.5:1+ contrast
248
+ secondary: gray[300], // 4.5:1+ contrast
249
+ disabled: gray[500], // 3:1+ contrast
250
+ }
251
+ ```
252
+
253
+ ## Color Psychology
254
+
255
+ ### Blue
256
+ - **Emotion**: Trust, reliability, professionalism
257
+ - **Use Cases**: Corporate brands, finance, healthcare
258
+ - **Avoid**: Food brands (suppresses appetite)
259
+
260
+ ### Green
261
+ - **Emotion**: Growth, success, nature, harmony
262
+ - **Use Cases**: Environmental, finance, success states
263
+ - **Avoid**: Error states (conflicts with red)
264
+
265
+ ### Red
266
+ - **Emotion**: Urgency, passion, danger, power
267
+ - **Use Cases**: Alerts, errors, sales, urgency
268
+ - **Avoid**: Overuse (can create anxiety)
269
+
270
+ ### Amber/Yellow
271
+ - **Emotion**: Optimism, caution, energy
272
+ - **Use Cases**: Warnings, highlights, energy brands
273
+ - **Avoid**: Large areas (can strain eyes)
274
+
275
+ ### Purple
276
+ - **Emotion**: Luxury, creativity, mystery
277
+ - **Use Cases**: Premium brands, creative tools
278
+ - **Cultural Note**: Royal associations in Western cultures
279
+
280
+ ### Pink
281
+ - **Emotion**: Playfulness, romance, creativity
282
+ - **Use Cases**: Fashion, lifestyle, creative apps
283
+ - **Considerations**: Gender associations vary by culture
284
+
285
+ ## Implementation Examples
286
+
287
+ ### Using Palettes in Themes
288
+
289
+ ```tsx
290
+ import { colorPalettes } from './colors';
291
+
292
+ // Direct palette access
293
+ const brandColor = colorPalettes.blue[500];
294
+ const lightBackground = colorPalettes.gray[50];
295
+ const errorText = colorPalettes.red[700];
296
+
297
+ // Intent mapping
298
+ const lightThemeIntents = {
299
+ primary: {
300
+ main: colorPalettes.blue[500],
301
+ light: colorPalettes.blue[400],
302
+ dark: colorPalettes.blue[600],
303
+ container: colorPalettes.blue[100],
304
+ },
305
+ error: {
306
+ main: colorPalettes.red[500],
307
+ light: colorPalettes.red[400],
308
+ dark: colorPalettes.red[600],
309
+ container: colorPalettes.red[100],
310
+ },
311
+ };
312
+ ```
313
+
314
+ ### Generating Custom Palettes
315
+
316
+ ```tsx
317
+ import { generateColorPalette } from '../themeBuilder';
318
+
319
+ // Generate palette from brand color
320
+ const brandPalette = generateColorPalette('#ff6b6b');
321
+
322
+ // Combine with existing palettes
323
+ const customPalettes = {
324
+ ...colorPalettes,
325
+ brand: brandPalette,
326
+ };
327
+ ```
328
+
329
+ ## Best Practices
330
+
331
+ 1. **Consistency**: Use the same palette family for related elements
332
+ 2. **Contrast**: Always check contrast ratios for accessibility
333
+ 3. **Context**: Consider the emotional and cultural context of colors
334
+ 4. **Hierarchy**: Use color intensity to indicate importance
335
+ 5. **Testing**: Validate colors across different devices and conditions
336
+ 6. **Brand Alignment**: Ensure palette choices align with brand identity
337
+
338
+ ## Color Tools and Resources
339
+
340
+ **Contrast Checkers:**
341
+ - WebAIM Contrast Checker
342
+ - Colour Contrast Analyser
343
+ - Stark (Figma/Sketch plugin)
344
+
345
+ **Palette Generators:**
346
+ - Coolors.co
347
+ - Adobe Color
348
+ - Material Design Color Tool
349
+
350
+ **Accessibility Tools:**
351
+ - WAVE Web Accessibility Evaluator
352
+ - axe DevTools
353
+ - Color Oracle (colorblind simulator)