@metacells/mcellui-core 0.1.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.
- package/package.json +50 -0
- package/src/components/ErrorBoundary.tsx +188 -0
- package/src/components/index.ts +6 -0
- package/src/config/ConfigProvider.tsx +117 -0
- package/src/config/defineConfig.ts +75 -0
- package/src/config/index.ts +42 -0
- package/src/config/types.ts +185 -0
- package/src/constants.ts +203 -0
- package/src/index.ts +144 -0
- package/src/primitives/Portal.tsx +185 -0
- package/src/primitives/Pressable.tsx +114 -0
- package/src/primitives/Slot.tsx +177 -0
- package/src/primitives/index.ts +19 -0
- package/src/theme/ThemeProvider.tsx +475 -0
- package/src/theme/animations.ts +379 -0
- package/src/theme/colors.ts +266 -0
- package/src/theme/components.ts +267 -0
- package/src/theme/index.ts +130 -0
- package/src/theme/presets.ts +341 -0
- package/src/theme/radius.ts +175 -0
- package/src/theme/shadows.ts +166 -0
- package/src/theme/spacing.ts +41 -0
- package/src/theme/typography.ts +389 -0
- package/src/tokens/colors.ts +67 -0
- package/src/tokens/index.ts +29 -0
- package/src/tokens/radius.ts +18 -0
- package/src/tokens/shadows.ts +38 -0
- package/src/tokens/spacing.ts +45 -0
- package/src/tokens/typography.ts +70 -0
- package/src/utils/accessibility.ts +112 -0
- package/src/utils/cn.ts +58 -0
- package/src/utils/haptics.ts +125 -0
- package/src/utils/index.ts +28 -0
- package/src/utils/platform.ts +66 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Component Tokens
|
|
3
|
+
*
|
|
4
|
+
* Size and proportion tokens for all components.
|
|
5
|
+
* Change these to globally adjust component dimensions.
|
|
6
|
+
*
|
|
7
|
+
* Each component has sm/md/lg size variants with consistent
|
|
8
|
+
* heights, padding, and typography.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { spacing } from './spacing';
|
|
12
|
+
import { fontSize, fontWeight } from './typography';
|
|
13
|
+
|
|
14
|
+
// =============================================================================
|
|
15
|
+
// Component Heights
|
|
16
|
+
// =============================================================================
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Standard heights for interactive components.
|
|
20
|
+
* Based on touch target guidelines (minimum 44px).
|
|
21
|
+
*/
|
|
22
|
+
export const componentHeight = {
|
|
23
|
+
/** Small: 32px */
|
|
24
|
+
sm: 32,
|
|
25
|
+
/** Medium: 44px (iOS recommended minimum) */
|
|
26
|
+
md: 44,
|
|
27
|
+
/** Large: 52px */
|
|
28
|
+
lg: 52,
|
|
29
|
+
} as const;
|
|
30
|
+
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// Icon Sizes
|
|
33
|
+
// =============================================================================
|
|
34
|
+
|
|
35
|
+
export const iconSize = {
|
|
36
|
+
/** Extra small: 12px */
|
|
37
|
+
xs: 12,
|
|
38
|
+
/** Small: 16px */
|
|
39
|
+
sm: 16,
|
|
40
|
+
/** Medium: 20px */
|
|
41
|
+
md: 20,
|
|
42
|
+
/** Large: 24px */
|
|
43
|
+
lg: 24,
|
|
44
|
+
/** Extra large: 32px */
|
|
45
|
+
xl: 32,
|
|
46
|
+
} as const;
|
|
47
|
+
|
|
48
|
+
// =============================================================================
|
|
49
|
+
// Button Component Tokens
|
|
50
|
+
// =============================================================================
|
|
51
|
+
|
|
52
|
+
export const buttonTokens = {
|
|
53
|
+
sm: {
|
|
54
|
+
height: componentHeight.sm,
|
|
55
|
+
paddingHorizontal: spacing[3],
|
|
56
|
+
paddingVertical: spacing[1.5],
|
|
57
|
+
fontSize: fontSize.base,
|
|
58
|
+
fontWeight: fontWeight.semibold,
|
|
59
|
+
iconSize: iconSize.sm,
|
|
60
|
+
gap: spacing[1.5],
|
|
61
|
+
},
|
|
62
|
+
md: {
|
|
63
|
+
height: componentHeight.md,
|
|
64
|
+
paddingHorizontal: spacing[4],
|
|
65
|
+
paddingVertical: spacing[2.5],
|
|
66
|
+
fontSize: fontSize.md,
|
|
67
|
+
fontWeight: fontWeight.semibold,
|
|
68
|
+
iconSize: iconSize.md,
|
|
69
|
+
gap: spacing[2],
|
|
70
|
+
},
|
|
71
|
+
lg: {
|
|
72
|
+
height: componentHeight.lg,
|
|
73
|
+
paddingHorizontal: spacing[6],
|
|
74
|
+
paddingVertical: spacing[3.5],
|
|
75
|
+
fontSize: fontSize.lg,
|
|
76
|
+
fontWeight: fontWeight.semibold,
|
|
77
|
+
iconSize: iconSize.lg,
|
|
78
|
+
gap: spacing[2.5],
|
|
79
|
+
},
|
|
80
|
+
} as const;
|
|
81
|
+
|
|
82
|
+
// =============================================================================
|
|
83
|
+
// Input Component Tokens
|
|
84
|
+
// =============================================================================
|
|
85
|
+
|
|
86
|
+
export const inputTokens = {
|
|
87
|
+
sm: {
|
|
88
|
+
height: componentHeight.sm,
|
|
89
|
+
paddingHorizontal: spacing[3],
|
|
90
|
+
paddingVertical: spacing[1.5],
|
|
91
|
+
borderWidth: 1,
|
|
92
|
+
fontSize: fontSize.base,
|
|
93
|
+
labelFontSize: fontSize.sm,
|
|
94
|
+
helperFontSize: fontSize.xs,
|
|
95
|
+
iconSize: iconSize.sm,
|
|
96
|
+
},
|
|
97
|
+
md: {
|
|
98
|
+
height: componentHeight.md,
|
|
99
|
+
paddingHorizontal: spacing[3],
|
|
100
|
+
paddingVertical: spacing[2.5],
|
|
101
|
+
borderWidth: 1,
|
|
102
|
+
fontSize: fontSize.md,
|
|
103
|
+
labelFontSize: fontSize.base,
|
|
104
|
+
helperFontSize: fontSize.sm,
|
|
105
|
+
iconSize: iconSize.md,
|
|
106
|
+
},
|
|
107
|
+
lg: {
|
|
108
|
+
height: componentHeight.lg,
|
|
109
|
+
paddingHorizontal: spacing[4],
|
|
110
|
+
paddingVertical: spacing[3],
|
|
111
|
+
borderWidth: 1,
|
|
112
|
+
fontSize: fontSize.lg,
|
|
113
|
+
labelFontSize: fontSize.md,
|
|
114
|
+
helperFontSize: fontSize.base,
|
|
115
|
+
iconSize: iconSize.lg,
|
|
116
|
+
},
|
|
117
|
+
} as const;
|
|
118
|
+
|
|
119
|
+
// =============================================================================
|
|
120
|
+
// Checkbox Component Tokens
|
|
121
|
+
// =============================================================================
|
|
122
|
+
|
|
123
|
+
export const checkboxTokens = {
|
|
124
|
+
sm: {
|
|
125
|
+
size: 18,
|
|
126
|
+
borderWidth: 2,
|
|
127
|
+
iconSize: 12,
|
|
128
|
+
labelFontSize: fontSize.base,
|
|
129
|
+
gap: spacing[2],
|
|
130
|
+
},
|
|
131
|
+
md: {
|
|
132
|
+
size: 22,
|
|
133
|
+
borderWidth: 2,
|
|
134
|
+
iconSize: 14,
|
|
135
|
+
labelFontSize: fontSize.md,
|
|
136
|
+
gap: spacing[2.5],
|
|
137
|
+
},
|
|
138
|
+
lg: {
|
|
139
|
+
size: 26,
|
|
140
|
+
borderWidth: 2,
|
|
141
|
+
iconSize: 18,
|
|
142
|
+
labelFontSize: fontSize.lg,
|
|
143
|
+
gap: spacing[3],
|
|
144
|
+
},
|
|
145
|
+
} as const;
|
|
146
|
+
|
|
147
|
+
// =============================================================================
|
|
148
|
+
// Switch Component Tokens
|
|
149
|
+
// =============================================================================
|
|
150
|
+
|
|
151
|
+
export const switchTokens = {
|
|
152
|
+
sm: {
|
|
153
|
+
trackWidth: 40,
|
|
154
|
+
trackHeight: 24,
|
|
155
|
+
thumbSize: 20,
|
|
156
|
+
thumbOffset: 2,
|
|
157
|
+
labelFontSize: fontSize.base,
|
|
158
|
+
gap: spacing[3],
|
|
159
|
+
},
|
|
160
|
+
md: {
|
|
161
|
+
trackWidth: 50,
|
|
162
|
+
trackHeight: 30,
|
|
163
|
+
thumbSize: 26,
|
|
164
|
+
thumbOffset: 2,
|
|
165
|
+
labelFontSize: fontSize.md,
|
|
166
|
+
gap: spacing[3],
|
|
167
|
+
},
|
|
168
|
+
lg: {
|
|
169
|
+
trackWidth: 60,
|
|
170
|
+
trackHeight: 36,
|
|
171
|
+
thumbSize: 32,
|
|
172
|
+
thumbOffset: 2,
|
|
173
|
+
labelFontSize: fontSize.lg,
|
|
174
|
+
gap: spacing[4],
|
|
175
|
+
},
|
|
176
|
+
} as const;
|
|
177
|
+
|
|
178
|
+
// =============================================================================
|
|
179
|
+
// Badge Component Tokens
|
|
180
|
+
// =============================================================================
|
|
181
|
+
|
|
182
|
+
export const badgeTokens = {
|
|
183
|
+
sm: {
|
|
184
|
+
paddingHorizontal: spacing[1.5],
|
|
185
|
+
paddingVertical: spacing[0.5],
|
|
186
|
+
fontSize: fontSize.xs,
|
|
187
|
+
fontWeight: fontWeight.medium,
|
|
188
|
+
},
|
|
189
|
+
md: {
|
|
190
|
+
paddingHorizontal: spacing[2.5],
|
|
191
|
+
paddingVertical: spacing[0.5],
|
|
192
|
+
fontSize: fontSize.sm,
|
|
193
|
+
fontWeight: fontWeight.medium,
|
|
194
|
+
},
|
|
195
|
+
lg: {
|
|
196
|
+
paddingHorizontal: spacing[3],
|
|
197
|
+
paddingVertical: spacing[1],
|
|
198
|
+
fontSize: fontSize.base,
|
|
199
|
+
fontWeight: fontWeight.medium,
|
|
200
|
+
},
|
|
201
|
+
} as const;
|
|
202
|
+
|
|
203
|
+
// =============================================================================
|
|
204
|
+
// Avatar Component Tokens
|
|
205
|
+
// =============================================================================
|
|
206
|
+
|
|
207
|
+
export const avatarTokens = {
|
|
208
|
+
xs: {
|
|
209
|
+
size: 24,
|
|
210
|
+
fontSize: fontSize['2xs'],
|
|
211
|
+
fontWeight: fontWeight.semibold,
|
|
212
|
+
},
|
|
213
|
+
sm: {
|
|
214
|
+
size: 32,
|
|
215
|
+
fontSize: fontSize.xs,
|
|
216
|
+
fontWeight: fontWeight.semibold,
|
|
217
|
+
},
|
|
218
|
+
md: {
|
|
219
|
+
size: 40,
|
|
220
|
+
fontSize: fontSize.base,
|
|
221
|
+
fontWeight: fontWeight.semibold,
|
|
222
|
+
},
|
|
223
|
+
lg: {
|
|
224
|
+
size: 56,
|
|
225
|
+
fontSize: fontSize.xl,
|
|
226
|
+
fontWeight: fontWeight.semibold,
|
|
227
|
+
},
|
|
228
|
+
xl: {
|
|
229
|
+
size: 80,
|
|
230
|
+
fontSize: fontSize['2xl'],
|
|
231
|
+
fontWeight: fontWeight.semibold,
|
|
232
|
+
},
|
|
233
|
+
} as const;
|
|
234
|
+
|
|
235
|
+
// =============================================================================
|
|
236
|
+
// Card Component Tokens
|
|
237
|
+
// =============================================================================
|
|
238
|
+
|
|
239
|
+
export const cardTokens = {
|
|
240
|
+
borderWidth: 1,
|
|
241
|
+
padding: spacing[4],
|
|
242
|
+
headerPadding: spacing[4],
|
|
243
|
+
contentPadding: spacing[4],
|
|
244
|
+
footerPadding: spacing[4],
|
|
245
|
+
gap: spacing[2],
|
|
246
|
+
titleFontSize: fontSize.lg,
|
|
247
|
+
titleFontWeight: fontWeight.semibold,
|
|
248
|
+
descriptionFontSize: fontSize.base,
|
|
249
|
+
} as const;
|
|
250
|
+
|
|
251
|
+
// =============================================================================
|
|
252
|
+
// Export all component tokens
|
|
253
|
+
// =============================================================================
|
|
254
|
+
|
|
255
|
+
export const components = {
|
|
256
|
+
button: buttonTokens,
|
|
257
|
+
input: inputTokens,
|
|
258
|
+
checkbox: checkboxTokens,
|
|
259
|
+
switch: switchTokens,
|
|
260
|
+
badge: badgeTokens,
|
|
261
|
+
avatar: avatarTokens,
|
|
262
|
+
card: cardTokens,
|
|
263
|
+
height: componentHeight,
|
|
264
|
+
icon: iconSize,
|
|
265
|
+
} as const;
|
|
266
|
+
|
|
267
|
+
export type ComponentSize = 'sm' | 'md' | 'lg';
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme System
|
|
3
|
+
*
|
|
4
|
+
* Complete design token system for nativeui components.
|
|
5
|
+
* Inspired by shadcn/ui - change a few tokens to transform the entire UI.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// Colors
|
|
9
|
+
export {
|
|
10
|
+
palette,
|
|
11
|
+
lightColors,
|
|
12
|
+
darkColors,
|
|
13
|
+
type ThemeColors,
|
|
14
|
+
type ColorKey,
|
|
15
|
+
} from './colors';
|
|
16
|
+
|
|
17
|
+
// Spacing
|
|
18
|
+
export {
|
|
19
|
+
spacing,
|
|
20
|
+
type SpacingKey,
|
|
21
|
+
type SpacingValue,
|
|
22
|
+
} from './spacing';
|
|
23
|
+
|
|
24
|
+
// Border Radius
|
|
25
|
+
export {
|
|
26
|
+
radius,
|
|
27
|
+
componentRadius,
|
|
28
|
+
createRadius,
|
|
29
|
+
createComponentRadius,
|
|
30
|
+
radiusPresetBase,
|
|
31
|
+
defaultRadiusPreset,
|
|
32
|
+
type RadiusKey,
|
|
33
|
+
type RadiusValue,
|
|
34
|
+
type RadiusTokens,
|
|
35
|
+
type RadiusPreset,
|
|
36
|
+
type ComponentRadiusKey,
|
|
37
|
+
type ComponentRadiusTokens,
|
|
38
|
+
} from './radius';
|
|
39
|
+
|
|
40
|
+
// Typography
|
|
41
|
+
export {
|
|
42
|
+
fontSize,
|
|
43
|
+
fontWeight,
|
|
44
|
+
lineHeight,
|
|
45
|
+
letterSpacing,
|
|
46
|
+
fontFamily,
|
|
47
|
+
geistFontFamily,
|
|
48
|
+
typography,
|
|
49
|
+
systemFonts,
|
|
50
|
+
defaultFonts,
|
|
51
|
+
createTypography,
|
|
52
|
+
type Fonts,
|
|
53
|
+
type Typography,
|
|
54
|
+
type FontSizeKey,
|
|
55
|
+
type FontWeightKey,
|
|
56
|
+
type LineHeightKey,
|
|
57
|
+
type LetterSpacingKey,
|
|
58
|
+
type FontFamilyKey,
|
|
59
|
+
type GeistFontFamilyKey,
|
|
60
|
+
type TypographyKey,
|
|
61
|
+
} from './typography';
|
|
62
|
+
|
|
63
|
+
// Shadows
|
|
64
|
+
export {
|
|
65
|
+
getShadow,
|
|
66
|
+
getPlatformShadow,
|
|
67
|
+
shadows,
|
|
68
|
+
type ShadowStyle,
|
|
69
|
+
type ShadowSize,
|
|
70
|
+
} from './shadows';
|
|
71
|
+
|
|
72
|
+
// Animations
|
|
73
|
+
export {
|
|
74
|
+
springs,
|
|
75
|
+
timing,
|
|
76
|
+
pressScale,
|
|
77
|
+
durations,
|
|
78
|
+
subtleAnimations,
|
|
79
|
+
playfulAnimations,
|
|
80
|
+
getAnimationPreset,
|
|
81
|
+
defaultAnimationPreset,
|
|
82
|
+
type SpringConfig,
|
|
83
|
+
type TimingConfig,
|
|
84
|
+
type SpringTokens,
|
|
85
|
+
type TimingTokens,
|
|
86
|
+
type PressScaleTokens,
|
|
87
|
+
type DurationTokens,
|
|
88
|
+
type AnimationTokens,
|
|
89
|
+
type SpringPreset,
|
|
90
|
+
type TimingPreset,
|
|
91
|
+
type PressScalePreset,
|
|
92
|
+
type AnimationPreset,
|
|
93
|
+
} from './animations';
|
|
94
|
+
|
|
95
|
+
// Component Tokens
|
|
96
|
+
export {
|
|
97
|
+
components,
|
|
98
|
+
componentHeight,
|
|
99
|
+
iconSize,
|
|
100
|
+
buttonTokens,
|
|
101
|
+
inputTokens,
|
|
102
|
+
checkboxTokens,
|
|
103
|
+
switchTokens,
|
|
104
|
+
badgeTokens,
|
|
105
|
+
avatarTokens,
|
|
106
|
+
cardTokens,
|
|
107
|
+
type ComponentSize,
|
|
108
|
+
} from './components';
|
|
109
|
+
|
|
110
|
+
// Theme Presets
|
|
111
|
+
export {
|
|
112
|
+
themePresets,
|
|
113
|
+
defaultThemePreset,
|
|
114
|
+
getPresetColors,
|
|
115
|
+
getPresetColorsForMode,
|
|
116
|
+
type ThemePreset,
|
|
117
|
+
type PresetColors,
|
|
118
|
+
} from './presets';
|
|
119
|
+
|
|
120
|
+
// Provider & Hooks
|
|
121
|
+
export {
|
|
122
|
+
ThemeProvider,
|
|
123
|
+
useTheme,
|
|
124
|
+
useColorSchemeValue,
|
|
125
|
+
useIsDark,
|
|
126
|
+
type Theme,
|
|
127
|
+
type ThemeProviderProps,
|
|
128
|
+
type ColorScheme,
|
|
129
|
+
type ColorSchemePreference,
|
|
130
|
+
} from './ThemeProvider';
|