@idealyst/theme 1.0.83 → 1.0.84
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/package.json +2 -1
- package/src/components/CLAUDE.md +468 -0
- package/src/components/accordion.ts +34 -0
- package/src/components/activity-indicator.ts +28 -0
- package/src/components/alert.ts +32 -0
- package/src/components/avatar.ts +27 -0
- package/src/components/badge.ts +28 -0
- package/src/components/breadcrumb.ts +36 -0
- package/src/components/button.ts +32 -0
- package/src/components/card.ts +31 -0
- package/src/components/checkbox.ts +37 -0
- package/src/components/chip.ts +34 -0
- package/src/components/dialog.ts +31 -0
- package/src/components/divider.ts +36 -0
- package/src/components/icon.ts +26 -0
- package/src/components/image.ts +22 -0
- package/src/components/index.ts +37 -0
- package/src/components/input.ts +35 -0
- package/src/components/list.ts +40 -0
- package/src/components/menu-item.ts +29 -0
- package/src/components/menu.ts +32 -0
- package/src/components/popover.ts +25 -0
- package/src/components/pressable.ts +20 -0
- package/src/components/progress.ts +35 -0
- package/src/components/radio-button.ts +38 -0
- package/src/components/screen.ts +25 -0
- package/src/components/select.ts +62 -0
- package/src/components/skeleton.ts +26 -0
- package/src/components/slider.ts +62 -0
- package/src/components/svg-image.ts +24 -0
- package/src/components/switch.ts +54 -0
- package/src/components/tab-bar.ts +54 -0
- package/src/components/table.ts +57 -0
- package/src/components/text.ts +29 -0
- package/src/components/textarea.ts +53 -0
- package/src/components/tooltip.ts +29 -0
- package/src/components/video.ts +18 -0
- package/src/components/view.ts +31 -0
- package/src/darkTheme.ts +890 -0
- package/src/index.ts +7 -166
- package/src/lightTheme.ts +873 -0
- package/src/styles.ts +14 -0
- package/src/theme/color.ts +15 -0
- package/src/theme/index.ts +16 -0
- package/src/theme/intent.ts +8 -0
- package/src/theme/shadow.ts +18 -0
- package/src/theme/size.ts +182 -0
- package/src/theme/surface.ts +3 -0
- package/src/unistyles.ts +6 -14
- package/src/variants/color.ts +9 -0
- package/src/variants/index.ts +2 -0
- package/src/variants/intent.ts +16 -0
- package/src/variants/size.ts +0 -0
- package/CLAUDE.md +0 -447
- package/LLM-ACCESS-GUIDE.md +0 -208
- package/README.md +0 -633
- package/src/README.md +0 -138
- package/src/breakpoints.ts +0 -8
- package/src/colorResolver.ts +0 -218
- package/src/colors.md +0 -353
- package/src/colors.ts +0 -315
- package/src/common.ts +0 -92
- package/src/defaultThemes.md +0 -407
- package/src/defaultThemes.ts +0 -238
- package/src/themeBuilder.md +0 -400
- package/src/themeBuilder.ts +0 -602
- package/src/variantHelpers.ts +0 -584
- package/src/variants.ts +0 -56
package/README.md
DELETED
|
@@ -1,633 +0,0 @@
|
|
|
1
|
-
# @idealyst/theme
|
|
2
|
-
|
|
3
|
-
A comprehensive, cross-platform theming system for React and React Native applications. Built on top of [react-native-unistyles](https://github.com/jpudysz/react-native-unistyles) with a powerful color system, typography, spacing, and responsive design utilities.
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- 🎨 **Comprehensive Color System**: 8 color palettes with 10 shades each (50-900)
|
|
8
|
-
- 🌓 **Light & Dark Themes**: Built-in light and dark theme variants
|
|
9
|
-
- ♿ **High Contrast Support**: Accessibility-focused high contrast themes
|
|
10
|
-
- 🎯 **Intent-Based Colors**: Semantic color system (primary, success, error, warning)
|
|
11
|
-
- 📱 **Responsive Design**: Breakpoint system for all screen sizes
|
|
12
|
-
- 🎭 **Component Color System**: Structured color mapping for UI components
|
|
13
|
-
- 🔧 **TypeScript**: Full type safety with comprehensive definitions
|
|
14
|
-
- 🌐 **Cross-Platform**: Works seamlessly on React and React Native
|
|
15
|
-
- 🎪 **Extensible**: Easy to extend and customize for your brand
|
|
16
|
-
- 🚀 **Production Ready**: Optimized performance and developer experience
|
|
17
|
-
|
|
18
|
-
## Installation
|
|
19
|
-
|
|
20
|
-
```bash
|
|
21
|
-
# Using Yarn (recommended)
|
|
22
|
-
yarn add @idealyst/theme
|
|
23
|
-
|
|
24
|
-
# Using npm
|
|
25
|
-
npm install @idealyst/theme
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
### Peer Dependencies
|
|
29
|
-
|
|
30
|
-
This library requires the following peer dependency:
|
|
31
|
-
|
|
32
|
-
```bash
|
|
33
|
-
# For cross-platform styling
|
|
34
|
-
yarn add react-native-unistyles
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Quick Start
|
|
38
|
-
|
|
39
|
-
### Basic Theme Usage
|
|
40
|
-
|
|
41
|
-
```tsx
|
|
42
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
43
|
-
import { defaultLightTheme, defaultDarkTheme } from '@idealyst/theme';
|
|
44
|
-
|
|
45
|
-
// Register themes with Unistyles 3.0
|
|
46
|
-
StyleSheet.configure({
|
|
47
|
-
themes: {
|
|
48
|
-
light: defaultLightTheme,
|
|
49
|
-
dark: defaultDarkTheme,
|
|
50
|
-
},
|
|
51
|
-
settings: {
|
|
52
|
-
adaptiveThemes: true,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// Use in components
|
|
57
|
-
const styles = StyleSheet.create((theme) => ({
|
|
58
|
-
container: {
|
|
59
|
-
backgroundColor: theme.colors.surface.primary,
|
|
60
|
-
padding: theme.spacing.md,
|
|
61
|
-
borderRadius: theme.borderRadius.lg,
|
|
62
|
-
},
|
|
63
|
-
text: {
|
|
64
|
-
color: theme.colors.text.primary,
|
|
65
|
-
fontSize: theme.typography.fontSize.md,
|
|
66
|
-
fontWeight: theme.typography.fontWeight.medium,
|
|
67
|
-
},
|
|
68
|
-
}));
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
### Theme Switching
|
|
72
|
-
|
|
73
|
-
```tsx
|
|
74
|
-
import { UnistylesRuntime } from 'react-native-unistyles';
|
|
75
|
-
|
|
76
|
-
// Switch themes programmatically
|
|
77
|
-
UnistylesRuntime.setTheme('dark');
|
|
78
|
-
UnistylesRuntime.setTheme('light');
|
|
79
|
-
|
|
80
|
-
// Get current theme
|
|
81
|
-
const currentTheme = UnistylesRuntime.themeName; // 'light' | 'dark'
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## Theme Structure
|
|
85
|
-
|
|
86
|
-
### Color Palettes
|
|
87
|
-
|
|
88
|
-
The theme system includes 8 comprehensive color palettes, each with 10 carefully crafted shades:
|
|
89
|
-
|
|
90
|
-
```tsx
|
|
91
|
-
const palettes = {
|
|
92
|
-
blue: { // Primary brand colors
|
|
93
|
-
50: '#eff6ff', // Lightest
|
|
94
|
-
100: '#dbeafe',
|
|
95
|
-
200: '#bfdbfe',
|
|
96
|
-
300: '#93c5fd',
|
|
97
|
-
400: '#60a5fa',
|
|
98
|
-
500: '#3b82f6', // Base color
|
|
99
|
-
600: '#2563eb',
|
|
100
|
-
700: '#1d4ed8',
|
|
101
|
-
800: '#1e40af',
|
|
102
|
-
900: '#1e3a8a', // Darkest
|
|
103
|
-
},
|
|
104
|
-
green: { /* Success colors */ },
|
|
105
|
-
red: { /* Error colors */ },
|
|
106
|
-
amber: { /* Warning colors */ },
|
|
107
|
-
gray: { /* Neutral colors */ },
|
|
108
|
-
cyan: { /* Info colors */ },
|
|
109
|
-
purple: { /* Accent colors */ },
|
|
110
|
-
pink: { /* Accent colors */ },
|
|
111
|
-
};
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### Intent System
|
|
115
|
-
|
|
116
|
-
Semantic color mappings for consistent UX:
|
|
117
|
-
|
|
118
|
-
```tsx
|
|
119
|
-
const intents = {
|
|
120
|
-
primary: {
|
|
121
|
-
main: '#3b82f6', // Primary action color
|
|
122
|
-
on: '#ffffff', // Text on primary
|
|
123
|
-
container: '#dbeafe', // Primary container
|
|
124
|
-
onContainer: '#1e40af', // Text on container
|
|
125
|
-
light: '#93c5fd', // Light variant
|
|
126
|
-
dark: '#1d4ed8', // Dark variant
|
|
127
|
-
border: '#2563eb', // Border color
|
|
128
|
-
},
|
|
129
|
-
success: { /* Green palette mapping */ },
|
|
130
|
-
error: { /* Red palette mapping */ },
|
|
131
|
-
warning: { /* Amber palette mapping */ },
|
|
132
|
-
neutral: { /* Gray palette mapping */ },
|
|
133
|
-
};
|
|
134
|
-
```
|
|
135
|
-
|
|
136
|
-
### Component Color System
|
|
137
|
-
|
|
138
|
-
Structured color mapping for UI components:
|
|
139
|
-
|
|
140
|
-
```tsx
|
|
141
|
-
const colors = {
|
|
142
|
-
text: {
|
|
143
|
-
primary: '#1f2937', // Main text
|
|
144
|
-
secondary: '#6b7280', // Secondary text
|
|
145
|
-
disabled: '#9ca3af', // Disabled text
|
|
146
|
-
inverse: '#ffffff', // Text on dark backgrounds
|
|
147
|
-
muted: '#d1d5db', // Muted text
|
|
148
|
-
placeholder: '#9ca3af', // Placeholder text
|
|
149
|
-
},
|
|
150
|
-
surface: {
|
|
151
|
-
primary: '#ffffff', // Main surface
|
|
152
|
-
secondary: '#f9fafb', // Secondary surface
|
|
153
|
-
tertiary: '#f3f4f6', // Tertiary surface
|
|
154
|
-
elevated: '#ffffff', // Elevated surface
|
|
155
|
-
overlay: '#000000cc', // Modal/overlay background
|
|
156
|
-
inverse: '#1f2937', // Inverse surface
|
|
157
|
-
},
|
|
158
|
-
border: {
|
|
159
|
-
primary: '#d1d5db', // Main borders
|
|
160
|
-
secondary: '#e5e7eb', // Subtle borders
|
|
161
|
-
focus: '#3b82f6', // Focus indicators
|
|
162
|
-
error: '#ef4444', // Error borders
|
|
163
|
-
disabled: '#f3f4f6', // Disabled borders
|
|
164
|
-
},
|
|
165
|
-
interactive: {
|
|
166
|
-
hover: '#f3f4f6', // Hover states
|
|
167
|
-
pressed: '#e5e7eb', // Pressed states
|
|
168
|
-
focus: '#dbeafe', // Focus states
|
|
169
|
-
disabled: '#f9fafb', // Disabled states
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
### Typography System
|
|
175
|
-
|
|
176
|
-
Comprehensive typography scale:
|
|
177
|
-
|
|
178
|
-
```tsx
|
|
179
|
-
const typography = {
|
|
180
|
-
fontFamily: {
|
|
181
|
-
sans: 'system font, -apple-system, sans-serif',
|
|
182
|
-
mono: 'SF Mono, Monaco, monospace',
|
|
183
|
-
},
|
|
184
|
-
fontSize: {
|
|
185
|
-
xs: 12, // Extra small
|
|
186
|
-
sm: 14, // Small
|
|
187
|
-
md: 16, // Medium (base)
|
|
188
|
-
lg: 18, // Large
|
|
189
|
-
xl: 20, // Extra large
|
|
190
|
-
xxl: 24, // Extra extra large
|
|
191
|
-
},
|
|
192
|
-
fontWeight: {
|
|
193
|
-
light: '300',
|
|
194
|
-
regular: '400',
|
|
195
|
-
medium: '500',
|
|
196
|
-
semibold: '600',
|
|
197
|
-
bold: '700',
|
|
198
|
-
},
|
|
199
|
-
lineHeight: {
|
|
200
|
-
tight: 1.2,
|
|
201
|
-
normal: 1.5,
|
|
202
|
-
relaxed: 1.75,
|
|
203
|
-
},
|
|
204
|
-
};
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
### Spacing System
|
|
208
|
-
|
|
209
|
-
Consistent spacing scale based on 4px grid:
|
|
210
|
-
|
|
211
|
-
```tsx
|
|
212
|
-
const spacing = {
|
|
213
|
-
xs: 4, // 0.25rem
|
|
214
|
-
sm: 8, // 0.5rem
|
|
215
|
-
md: 16, // 1rem
|
|
216
|
-
lg: 24, // 1.5rem
|
|
217
|
-
xl: 32, // 2rem
|
|
218
|
-
xxl: 48, // 3rem
|
|
219
|
-
};
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
### Border Radius
|
|
223
|
-
|
|
224
|
-
Rounded corner scale:
|
|
225
|
-
|
|
226
|
-
```tsx
|
|
227
|
-
const borderRadius = {
|
|
228
|
-
none: 0,
|
|
229
|
-
sm: 4,
|
|
230
|
-
md: 8,
|
|
231
|
-
lg: 12,
|
|
232
|
-
xl: 16,
|
|
233
|
-
full: 9999,
|
|
234
|
-
};
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Responsive Breakpoints
|
|
238
|
-
|
|
239
|
-
Mobile-first breakpoint system:
|
|
240
|
-
|
|
241
|
-
```tsx
|
|
242
|
-
const breakpoints = {
|
|
243
|
-
xs: 0, // Mobile
|
|
244
|
-
sm: 576, // Mobile landscape
|
|
245
|
-
md: 768, // Tablet
|
|
246
|
-
lg: 992, // Desktop
|
|
247
|
-
xl: 1200, // Large desktop
|
|
248
|
-
xxl: 1400, // Extra large desktop
|
|
249
|
-
};
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
## Available Themes
|
|
253
|
-
|
|
254
|
-
### Default Themes
|
|
255
|
-
|
|
256
|
-
```tsx
|
|
257
|
-
import {
|
|
258
|
-
defaultLightTheme,
|
|
259
|
-
defaultDarkTheme,
|
|
260
|
-
themePresets
|
|
261
|
-
} from '@idealyst/theme';
|
|
262
|
-
|
|
263
|
-
// Individual themes
|
|
264
|
-
const lightTheme = defaultLightTheme;
|
|
265
|
-
const darkTheme = defaultDarkTheme;
|
|
266
|
-
|
|
267
|
-
// Theme presets collection
|
|
268
|
-
const themes = themePresets; // { light, dark }
|
|
269
|
-
```
|
|
270
|
-
|
|
271
|
-
### High Contrast Themes
|
|
272
|
-
|
|
273
|
-
For accessibility compliance and users with visual impairments:
|
|
274
|
-
|
|
275
|
-
```tsx
|
|
276
|
-
// High contrast variants (created via theme extension)
|
|
277
|
-
import { extendTheme } from '@idealyst/theme';
|
|
278
|
-
|
|
279
|
-
const lightHighContrast = extendTheme(defaultLightTheme, {
|
|
280
|
-
colors: {
|
|
281
|
-
text: {
|
|
282
|
-
primary: '#000000', // Pure black text
|
|
283
|
-
secondary: '#1f2937', // Very dark secondary
|
|
284
|
-
},
|
|
285
|
-
surface: {
|
|
286
|
-
primary: '#ffffff', // Pure white surface
|
|
287
|
-
},
|
|
288
|
-
border: {
|
|
289
|
-
primary: '#000000', // Black borders
|
|
290
|
-
},
|
|
291
|
-
},
|
|
292
|
-
});
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
## Creating Custom Themes
|
|
296
|
-
|
|
297
|
-
### Extending Existing Themes
|
|
298
|
-
|
|
299
|
-
```tsx
|
|
300
|
-
import { extendTheme, defaultLightTheme } from '@idealyst/theme';
|
|
301
|
-
|
|
302
|
-
const customTheme = extendTheme(defaultLightTheme, {
|
|
303
|
-
palettes: {
|
|
304
|
-
// Add your brand color
|
|
305
|
-
brand: generateColorPalette('#8b5cf6'), // Purple brand
|
|
306
|
-
},
|
|
307
|
-
intents: {
|
|
308
|
-
// Override primary intent with brand color
|
|
309
|
-
primary: {
|
|
310
|
-
main: '#8b5cf6',
|
|
311
|
-
on: '#ffffff',
|
|
312
|
-
container: '#f3e8ff',
|
|
313
|
-
onContainer: '#581c87',
|
|
314
|
-
light: '#c4b5fd',
|
|
315
|
-
dark: '#7c3aed',
|
|
316
|
-
border: '#a855f7',
|
|
317
|
-
},
|
|
318
|
-
},
|
|
319
|
-
typography: {
|
|
320
|
-
fontFamily: {
|
|
321
|
-
sans: 'Helvetica, Arial, sans-serif', // Custom font
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
});
|
|
325
|
-
```
|
|
326
|
-
|
|
327
|
-
### Building Themes from Scratch
|
|
328
|
-
|
|
329
|
-
```tsx
|
|
330
|
-
import { createTheme, generateColorPalette } from '@idealyst/theme';
|
|
331
|
-
|
|
332
|
-
const brandTheme = createTheme({
|
|
333
|
-
palettes: {
|
|
334
|
-
brand: generateColorPalette('#ff6b6b'), // Coral brand color
|
|
335
|
-
neutral: generateColorPalette('#64748b'), // Slate neutral
|
|
336
|
-
// ... other palettes
|
|
337
|
-
},
|
|
338
|
-
intents: {
|
|
339
|
-
primary: 'brand', // Use brand palette for primary
|
|
340
|
-
neutral: 'neutral', // Use neutral palette for neutral
|
|
341
|
-
success: 'green',
|
|
342
|
-
error: 'red',
|
|
343
|
-
warning: 'amber',
|
|
344
|
-
},
|
|
345
|
-
// Custom spacing, typography, etc.
|
|
346
|
-
spacing: {
|
|
347
|
-
xs: 2,
|
|
348
|
-
sm: 4,
|
|
349
|
-
md: 8,
|
|
350
|
-
lg: 16,
|
|
351
|
-
xl: 24,
|
|
352
|
-
xxl: 32,
|
|
353
|
-
},
|
|
354
|
-
});
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
### Color Palette Generation
|
|
358
|
-
|
|
359
|
-
Generate complete color palettes from a single base color:
|
|
360
|
-
|
|
361
|
-
```tsx
|
|
362
|
-
import { generateColorPalette } from '@idealyst/theme';
|
|
363
|
-
|
|
364
|
-
// Generate palette from brand color
|
|
365
|
-
const brandPalette = generateColorPalette('#8b5cf6');
|
|
366
|
-
// Returns: { 50: '#f7f3ff', 100: '#ede9fe', ..., 900: '#581c87' }
|
|
367
|
-
|
|
368
|
-
// Use in theme
|
|
369
|
-
const theme = createTheme({
|
|
370
|
-
palettes: {
|
|
371
|
-
brand: brandPalette,
|
|
372
|
-
secondary: generateColorPalette('#06b6d4'), // Cyan
|
|
373
|
-
},
|
|
374
|
-
});
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
## Advanced Usage
|
|
378
|
-
|
|
379
|
-
### Theme-Aware Components
|
|
380
|
-
|
|
381
|
-
```tsx
|
|
382
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
383
|
-
|
|
384
|
-
const ComponentStyles = StyleSheet.create((theme) => ({
|
|
385
|
-
container: {
|
|
386
|
-
backgroundColor: theme.colors.surface.primary,
|
|
387
|
-
padding: theme.spacing.lg,
|
|
388
|
-
borderRadius: theme.borderRadius.md,
|
|
389
|
-
// Responsive styling
|
|
390
|
-
variants: {
|
|
391
|
-
size: {
|
|
392
|
-
small: { padding: theme.spacing.sm },
|
|
393
|
-
large: { padding: theme.spacing.xl },
|
|
394
|
-
},
|
|
395
|
-
},
|
|
396
|
-
},
|
|
397
|
-
text: {
|
|
398
|
-
color: theme.colors.text.primary,
|
|
399
|
-
fontSize: theme.typography.fontSize.md,
|
|
400
|
-
variants: {
|
|
401
|
-
intent: {
|
|
402
|
-
primary: { color: theme.intents.primary.main },
|
|
403
|
-
success: { color: theme.intents.success.main },
|
|
404
|
-
error: { color: theme.intents.error.main },
|
|
405
|
-
},
|
|
406
|
-
},
|
|
407
|
-
},
|
|
408
|
-
}));
|
|
409
|
-
|
|
410
|
-
const MyComponent = ({ size, intent }) => {
|
|
411
|
-
return (
|
|
412
|
-
<View style={ComponentStyles.container({ size })}>
|
|
413
|
-
<Text style={ComponentStyles.text({ intent })}>Themed Component</Text>
|
|
414
|
-
</View>
|
|
415
|
-
);
|
|
416
|
-
};
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
### Responsive Design
|
|
420
|
-
|
|
421
|
-
```tsx
|
|
422
|
-
const responsiveStyles = StyleSheet.create((theme, rt) => ({
|
|
423
|
-
container: {
|
|
424
|
-
padding: theme.spacing.md,
|
|
425
|
-
// Responsive breakpoints
|
|
426
|
-
[rt.breakpoint]: {
|
|
427
|
-
xs: { padding: theme.spacing.sm },
|
|
428
|
-
md: { padding: theme.spacing.lg },
|
|
429
|
-
xl: { padding: theme.spacing.xl },
|
|
430
|
-
},
|
|
431
|
-
},
|
|
432
|
-
}));
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
### Dynamic Theme Switching
|
|
436
|
-
|
|
437
|
-
```tsx
|
|
438
|
-
import React, { useState } from 'react';
|
|
439
|
-
import { UnistylesRuntime } from 'react-native-unistyles';
|
|
440
|
-
|
|
441
|
-
const ThemeToggle = () => {
|
|
442
|
-
const [isDark, setIsDark] = useState(false);
|
|
443
|
-
|
|
444
|
-
const toggleTheme = () => {
|
|
445
|
-
const newTheme = isDark ? 'light' : 'dark';
|
|
446
|
-
UnistylesRuntime.setTheme(newTheme);
|
|
447
|
-
setIsDark(!isDark);
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
return (
|
|
451
|
-
<Button onPress={toggleTheme}>
|
|
452
|
-
Switch to {isDark ? 'Light' : 'Dark'} Theme
|
|
453
|
-
</Button>
|
|
454
|
-
);
|
|
455
|
-
};
|
|
456
|
-
```
|
|
457
|
-
|
|
458
|
-
## Theme Integration with Components
|
|
459
|
-
|
|
460
|
-
### Using Intent Colors
|
|
461
|
-
|
|
462
|
-
```tsx
|
|
463
|
-
// Component automatically uses theme intents
|
|
464
|
-
<Button intent="primary">Primary Action</Button>
|
|
465
|
-
<Button intent="success">Save Changes</Button>
|
|
466
|
-
<Button intent="error">Delete Item</Button>
|
|
467
|
-
<Button intent="warning">Proceed with Caution</Button>
|
|
468
|
-
```
|
|
469
|
-
|
|
470
|
-
### Using Component Color System
|
|
471
|
-
|
|
472
|
-
```tsx
|
|
473
|
-
const styles = StyleSheet.create((theme) => ({
|
|
474
|
-
card: {
|
|
475
|
-
backgroundColor: theme.colors.surface.elevated,
|
|
476
|
-
borderWidth: 1,
|
|
477
|
-
borderColor: theme.colors.border.primary,
|
|
478
|
-
},
|
|
479
|
-
cardText: {
|
|
480
|
-
color: theme.colors.text.primary,
|
|
481
|
-
},
|
|
482
|
-
mutedText: {
|
|
483
|
-
color: theme.colors.text.secondary,
|
|
484
|
-
},
|
|
485
|
-
}));
|
|
486
|
-
```
|
|
487
|
-
|
|
488
|
-
## TypeScript Support
|
|
489
|
-
|
|
490
|
-
Full type safety throughout the theme system:
|
|
491
|
-
|
|
492
|
-
```tsx
|
|
493
|
-
import type {
|
|
494
|
-
AppTheme,
|
|
495
|
-
ThemeConfig,
|
|
496
|
-
ThemeColorPalette,
|
|
497
|
-
ResolvedIntent,
|
|
498
|
-
ThemeColorSystem
|
|
499
|
-
} from '@idealyst/theme';
|
|
500
|
-
|
|
501
|
-
// Theme creation is fully typed
|
|
502
|
-
const myTheme: AppTheme = createTheme({
|
|
503
|
-
palettes: {
|
|
504
|
-
brand: generateColorPalette('#8b5cf6'), // TypeScript validates structure
|
|
505
|
-
},
|
|
506
|
-
// All theme properties are type-checked
|
|
507
|
-
});
|
|
508
|
-
|
|
509
|
-
// Style functions receive typed theme
|
|
510
|
-
const styles = StyleSheet.create((theme: AppTheme) => ({
|
|
511
|
-
container: {
|
|
512
|
-
backgroundColor: theme.colors.surface.primary, // Autocomplete and validation
|
|
513
|
-
color: theme.intents.primary.main,
|
|
514
|
-
},
|
|
515
|
-
}));
|
|
516
|
-
```
|
|
517
|
-
|
|
518
|
-
## Accessibility
|
|
519
|
-
|
|
520
|
-
### High Contrast Support
|
|
521
|
-
|
|
522
|
-
```tsx
|
|
523
|
-
// High contrast themes for accessibility
|
|
524
|
-
const highContrastLight = extendTheme(defaultLightTheme, {
|
|
525
|
-
colors: {
|
|
526
|
-
text: {
|
|
527
|
-
primary: '#000000', // Pure black for maximum contrast
|
|
528
|
-
secondary: '#1f2937',
|
|
529
|
-
},
|
|
530
|
-
border: {
|
|
531
|
-
primary: '#000000', // Black borders
|
|
532
|
-
focus: '#0066cc', // High contrast focus
|
|
533
|
-
},
|
|
534
|
-
},
|
|
535
|
-
});
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
### WCAG Compliance
|
|
539
|
-
|
|
540
|
-
All default themes meet WCAG AA contrast requirements:
|
|
541
|
-
- Text contrast ratios ≥ 4.5:1
|
|
542
|
-
- Large text contrast ratios ≥ 3:1
|
|
543
|
-
- Focus indicators clearly visible
|
|
544
|
-
- Color not used as sole information source
|
|
545
|
-
|
|
546
|
-
## Performance
|
|
547
|
-
|
|
548
|
-
### Optimizations
|
|
549
|
-
|
|
550
|
-
- **Theme Caching**: Themes are computed once and cached
|
|
551
|
-
- **Minimal Re-renders**: Only style-dependent components re-render on theme change
|
|
552
|
-
- **Tree Shaking**: Import only the utilities you need
|
|
553
|
-
- **Efficient Color Generation**: Optimized color palette algorithms
|
|
554
|
-
|
|
555
|
-
### Bundle Size
|
|
556
|
-
|
|
557
|
-
- Core theme: ~8KB gzipped
|
|
558
|
-
- Color utilities: ~2KB gzipped
|
|
559
|
-
- Full theme with all utilities: ~12KB gzipped
|
|
560
|
-
|
|
561
|
-
## API Reference
|
|
562
|
-
|
|
563
|
-
### Theme Creation
|
|
564
|
-
|
|
565
|
-
| Function | Description | Parameters |
|
|
566
|
-
|----------|-------------|------------|
|
|
567
|
-
| `createTheme(config)` | Create a complete theme from configuration | `ThemeConfig` |
|
|
568
|
-
| `extendTheme(base, overrides)` | Extend an existing theme | `AppTheme`, `Partial<ThemeConfig>` |
|
|
569
|
-
| `generateColorPalette(color)` | Generate 10-shade palette from base color | `string` (hex color) |
|
|
570
|
-
|
|
571
|
-
### Theme Utilities
|
|
572
|
-
|
|
573
|
-
| Function | Description | Returns |
|
|
574
|
-
|----------|-------------|---------|
|
|
575
|
-
| `createStandardPalettes()` | Create default color palettes | `ThemeConfig['palettes']` |
|
|
576
|
-
| `createDarkPalettes()` | Create dark-optimized palettes | `ThemeConfig['palettes']` |
|
|
577
|
-
| `createLightIntentMappings()` | Create light theme intent mappings | Intent mappings |
|
|
578
|
-
| `createDarkIntentMappings()` | Create dark theme intent mappings | Intent mappings |
|
|
579
|
-
|
|
580
|
-
### Color Utilities
|
|
581
|
-
|
|
582
|
-
| Function | Description | Parameters |
|
|
583
|
-
|----------|-------------|------------|
|
|
584
|
-
| `lighten(color, amount)` | Lighten a color by percentage | `string`, `number` |
|
|
585
|
-
| `darken(color, amount)` | Darken a color by percentage | `string`, `number` |
|
|
586
|
-
|
|
587
|
-
## Development
|
|
588
|
-
|
|
589
|
-
### Building the Theme
|
|
590
|
-
|
|
591
|
-
```bash
|
|
592
|
-
# Build the library
|
|
593
|
-
yarn build
|
|
594
|
-
|
|
595
|
-
# Watch for changes during development
|
|
596
|
-
yarn dev
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
### Project Structure
|
|
600
|
-
|
|
601
|
-
```
|
|
602
|
-
packages/theme/
|
|
603
|
-
├── src/
|
|
604
|
-
│ ├── index.ts # Main exports
|
|
605
|
-
│ ├── themeBuilder.ts # Core theme creation utilities
|
|
606
|
-
│ ├── defaultThemes.ts # Default light and dark themes
|
|
607
|
-
│ ├── colors.ts # Color palette definitions
|
|
608
|
-
│ ├── colorResolver.ts # Color resolution utilities
|
|
609
|
-
│ ├── variants.ts # Color variant types
|
|
610
|
-
│ ├── variantHelpers.ts # Variant utility functions
|
|
611
|
-
│ ├── breakpoints.ts # Responsive breakpoints
|
|
612
|
-
│ ├── common.ts # Common theme properties
|
|
613
|
-
│ └── unistyles.ts # Unistyles integration
|
|
614
|
-
├── package.json
|
|
615
|
-
└── README.md
|
|
616
|
-
```
|
|
617
|
-
|
|
618
|
-
## Contributing
|
|
619
|
-
|
|
620
|
-
1. Fork the repository
|
|
621
|
-
2. Create a feature branch
|
|
622
|
-
3. Follow the existing patterns and TypeScript conventions
|
|
623
|
-
4. Test theme changes across light and dark modes
|
|
624
|
-
5. Ensure accessibility compliance
|
|
625
|
-
6. Submit a pull request
|
|
626
|
-
|
|
627
|
-
## License
|
|
628
|
-
|
|
629
|
-
MIT License - see LICENSE file for details.
|
|
630
|
-
|
|
631
|
-
## Support
|
|
632
|
-
|
|
633
|
-
For issues, questions, or contributions, please visit our [GitHub repository](https://github.com/your-org/idealyst-framework).
|