@idealyst/theme 1.0.82 → 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.
Files changed (68) hide show
  1. package/package.json +3 -2
  2. package/src/components/CLAUDE.md +468 -0
  3. package/src/components/accordion.ts +34 -0
  4. package/src/components/activity-indicator.ts +28 -0
  5. package/src/components/alert.ts +32 -0
  6. package/src/components/avatar.ts +27 -0
  7. package/src/components/badge.ts +28 -0
  8. package/src/components/breadcrumb.ts +36 -0
  9. package/src/components/button.ts +32 -0
  10. package/src/components/card.ts +31 -0
  11. package/src/components/checkbox.ts +37 -0
  12. package/src/components/chip.ts +34 -0
  13. package/src/components/dialog.ts +31 -0
  14. package/src/components/divider.ts +36 -0
  15. package/src/components/icon.ts +26 -0
  16. package/src/components/image.ts +22 -0
  17. package/src/components/index.ts +37 -0
  18. package/src/components/input.ts +35 -0
  19. package/src/components/list.ts +40 -0
  20. package/src/components/menu-item.ts +29 -0
  21. package/src/components/menu.ts +32 -0
  22. package/src/components/popover.ts +25 -0
  23. package/src/components/pressable.ts +20 -0
  24. package/src/components/progress.ts +35 -0
  25. package/src/components/radio-button.ts +38 -0
  26. package/src/components/screen.ts +25 -0
  27. package/src/components/select.ts +62 -0
  28. package/src/components/skeleton.ts +26 -0
  29. package/src/components/slider.ts +62 -0
  30. package/src/components/svg-image.ts +24 -0
  31. package/src/components/switch.ts +54 -0
  32. package/src/components/tab-bar.ts +54 -0
  33. package/src/components/table.ts +57 -0
  34. package/src/components/text.ts +29 -0
  35. package/src/components/textarea.ts +53 -0
  36. package/src/components/tooltip.ts +29 -0
  37. package/src/components/video.ts +18 -0
  38. package/src/components/view.ts +31 -0
  39. package/src/darkTheme.ts +890 -0
  40. package/src/index.ts +7 -166
  41. package/src/lightTheme.ts +873 -0
  42. package/src/styles.ts +14 -0
  43. package/src/theme/color.ts +15 -0
  44. package/src/theme/index.ts +16 -0
  45. package/src/theme/intent.ts +8 -0
  46. package/src/theme/shadow.ts +18 -0
  47. package/src/theme/size.ts +182 -0
  48. package/src/theme/surface.ts +3 -0
  49. package/src/unistyles.ts +6 -14
  50. package/src/variants/color.ts +9 -0
  51. package/src/variants/index.ts +2 -0
  52. package/src/variants/intent.ts +16 -0
  53. package/src/variants/size.ts +0 -0
  54. package/CLAUDE.md +0 -447
  55. package/LLM-ACCESS-GUIDE.md +0 -208
  56. package/README.md +0 -633
  57. package/src/README.md +0 -138
  58. package/src/breakpoints.ts +0 -8
  59. package/src/colorResolver.ts +0 -218
  60. package/src/colors.md +0 -353
  61. package/src/colors.ts +0 -315
  62. package/src/common.ts +0 -92
  63. package/src/defaultThemes.md +0 -407
  64. package/src/defaultThemes.ts +0 -238
  65. package/src/themeBuilder.md +0 -400
  66. package/src/themeBuilder.ts +0 -602
  67. package/src/variantHelpers.ts +0 -584
  68. package/src/variants.ts +0 -56
package/src/README.md DELETED
@@ -1,138 +0,0 @@
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
@@ -1,8 +0,0 @@
1
- export const breakpoints = {
2
- xs: 0,
3
- sm: 400,
4
- md: 768,
5
- lg: 1024,
6
- xl: 1280,
7
- } as const;
8
-
@@ -1,218 +0,0 @@
1
- import {
2
- colorPalettes,
3
- intentMappings,
4
- colorMappings,
5
- darkThemeOverrides,
6
- type ColorPalette,
7
- type ColorShade,
8
- type IntentName,
9
- type ColorName
10
- } from './colors';
11
-
12
- // Type for color references
13
- export type ColorReference =
14
- | string // Direct hex color like '#ffffff'
15
- | `${ColorPalette}.${ColorShade}` // Palette reference like 'blue.500'
16
- | IntentName // Intent reference like 'primary'
17
- | `intent.${IntentName}.${keyof typeof intentMappings.primary}` // Intent property like 'intent.primary.main'
18
- | `color.${ColorName}` // Color mapping like 'color.text.primary'
19
- | keyof typeof colorMappings; // Direct color mapping like 'primary'
20
-
21
- // Theme context for color resolution
22
- export interface ThemeContext {
23
- isDark: boolean;
24
- colorPalettes: typeof colorPalettes;
25
- intentMappings: any; // Use any to allow theme overrides
26
- colorMappings: any; // Use any to allow theme overrides
27
- }
28
-
29
- // Create theme context
30
- export function createThemeContext(isDark: boolean = false): ThemeContext {
31
- const baseIntentMappings = isDark
32
- ? { ...intentMappings, ...darkThemeOverrides.intentMappings }
33
- : intentMappings;
34
-
35
- const baseColorMappings = isDark
36
- ? { ...colorMappings, ...darkThemeOverrides.colorMappings }
37
- : colorMappings;
38
-
39
- return {
40
- isDark,
41
- colorPalettes,
42
- intentMappings: baseIntentMappings,
43
- colorMappings: baseColorMappings,
44
- };
45
- }
46
-
47
- // Resolve a color reference to a hex color
48
- export function resolveColor(
49
- colorRef: ColorReference,
50
- context: ThemeContext
51
- ): string {
52
- // If it's already a hex color, return as is
53
- if (typeof colorRef === 'string' && colorRef.startsWith('#')) {
54
- return colorRef;
55
- }
56
-
57
- // Handle palette references like 'blue.500'
58
- if (typeof colorRef === 'string' && colorRef.includes('.')) {
59
- const [paletteOrCategory, property] = colorRef.split('.');
60
-
61
- // Handle palette references
62
- if (paletteOrCategory in context.colorPalettes) {
63
- const palette = context.colorPalettes[paletteOrCategory as ColorPalette];
64
- if (property in palette) {
65
- return palette[property as unknown as ColorShade];
66
- }
67
- }
68
-
69
- // Handle color mappings like 'text.primary'
70
- if (paletteOrCategory in context.colorMappings) {
71
- const colorCategory = context.colorMappings[paletteOrCategory as keyof typeof context.colorMappings];
72
- if (typeof colorCategory === 'object' && property in colorCategory) {
73
- const nestedRef = colorCategory[property as keyof typeof colorCategory];
74
- return resolveColor(nestedRef as ColorReference, context);
75
- }
76
- }
77
- }
78
-
79
- // Handle intent references like 'intent.primary.main'
80
- if (typeof colorRef === 'string' && colorRef.startsWith('intent.')) {
81
- const parts = colorRef.split('.');
82
- if (parts.length === 3) {
83
- const [, intentName, property] = parts;
84
- return resolveIntentColor(
85
- intentName as IntentName,
86
- property as keyof typeof intentMappings.primary,
87
- context
88
- );
89
- }
90
- }
91
-
92
- // Handle color mappings like 'color.text.primary'
93
- if (typeof colorRef === 'string' && colorRef.startsWith('color.')) {
94
- const path = colorRef.substring(6); // Remove 'color.' prefix
95
- const [category, property] = path.split('.');
96
-
97
- if (category in context.colorMappings) {
98
- const colorCategory = context.colorMappings[category as keyof typeof context.colorMappings];
99
- if (typeof colorCategory === 'object' && property in colorCategory) {
100
- const nestedRef = colorCategory[property as keyof typeof colorCategory];
101
- return resolveColor(nestedRef as ColorReference, context);
102
- }
103
- }
104
- }
105
-
106
- // Handle direct intent references like 'primary'
107
- if (typeof colorRef === 'string' && colorRef in context.intentMappings) {
108
- return resolveIntentColor(colorRef as IntentName, 'main', context);
109
- }
110
-
111
- // Handle direct color mappings like 'primary' (when it's in colorMappings)
112
- if (typeof colorRef === 'string' && colorRef in context.colorMappings) {
113
- const mapping = context.colorMappings[colorRef as keyof typeof context.colorMappings];
114
- return resolveColor(mapping as ColorReference, context);
115
- }
116
-
117
- // If we can't resolve it, return it as is (might be a CSS variable or other valid color)
118
- console.warn(`Could not resolve color reference: ${colorRef}`);
119
- return colorRef as string;
120
- }
121
-
122
- // Resolve a specific intent color property
123
- export function resolveIntentColor(
124
- intentName: IntentName,
125
- property: keyof typeof intentMappings.primary,
126
- context: ThemeContext
127
- ): string {
128
- const intent = context.intentMappings[intentName];
129
- if (!intent) {
130
- console.warn(`Intent ${intentName} not found`);
131
- return '#000000'; // Fallback color
132
- }
133
-
134
- const value = intent[property];
135
-
136
- // Handle palette references
137
- if (typeof value === 'number') {
138
- const palette = context.colorPalettes[intent.palette];
139
- const shade = value as ColorShade;
140
- if (shade in palette) {
141
- return palette[shade];
142
- }
143
- }
144
-
145
- // Handle string references (like 'gray.900')
146
- if (typeof value === 'string') {
147
- return resolveColor(value, context);
148
- }
149
-
150
- // If we can't resolve it, return it as is
151
- return value as string;
152
- }
153
-
154
- // Helper function to get all colors for an intent
155
- export function getIntentColors(intentName: IntentName, context: ThemeContext) {
156
- const intent = context.intentMappings[intentName];
157
- if (!intent) {
158
- return {};
159
- }
160
-
161
- const colors: Record<string, string> = {};
162
-
163
- // Resolve all properties of the intent
164
- for (const [key, value] of Object.entries(intent)) {
165
- if (key === 'palette') continue; // Skip the palette reference
166
-
167
- colors[key] = resolveIntentColor(
168
- intentName,
169
- key as keyof typeof intentMappings.primary,
170
- context
171
- );
172
- }
173
-
174
- return colors;
175
- }
176
-
177
- // Helper function to get all colors for a palette
178
- export function getPaletteColors(paletteName: ColorPalette, context: ThemeContext) {
179
- const palette = context.colorPalettes[paletteName];
180
- if (!palette) {
181
- return {};
182
- }
183
-
184
- return { ...palette };
185
- }
186
-
187
- // Helper function to validate color references
188
- export function isValidColorReference(colorRef: string, context: ThemeContext): boolean {
189
- try {
190
- const resolved = resolveColor(colorRef as ColorReference, context);
191
- return resolved !== colorRef || colorRef.startsWith('#');
192
- } catch {
193
- return false;
194
- }
195
- }
196
-
197
- // Helper function to get color with opacity
198
- export function getColorWithOpacity(colorRef: ColorReference, opacity: number, context: ThemeContext): string {
199
- const resolvedColor = resolveColor(colorRef, context);
200
-
201
- // Convert hex to rgba
202
- if (resolvedColor.startsWith('#')) {
203
- const hex = resolvedColor.slice(1);
204
- const r = parseInt(hex.slice(0, 2), 16);
205
- const g = parseInt(hex.slice(2, 4), 16);
206
- const b = parseInt(hex.slice(4, 6), 16);
207
-
208
- return `rgba(${r}, ${g}, ${b}, ${opacity})`;
209
- }
210
-
211
- // For non-hex colors, return as is with opacity warning
212
- console.warn(`Cannot add opacity to non-hex color: ${resolvedColor}`);
213
- return resolvedColor;
214
- }
215
-
216
- // Export commonly used theme contexts
217
- export const lightThemeContext = createThemeContext(false);
218
- export const darkThemeContext = createThemeContext(true);