@idealyst/components 1.0.23 → 1.0.25
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/README.md +567 -567
- package/package.json +2 -6
- package/plugin/web.js +319 -185
- package/src/Avatar/Avatar.native.tsx +43 -43
- package/src/Avatar/Avatar.styles.tsx +66 -66
- package/src/Avatar/Avatar.web.tsx +50 -50
- package/src/Avatar/index.native.ts +1 -1
- package/src/Avatar/index.ts +1 -1
- package/src/Avatar/index.web.ts +1 -1
- package/src/Avatar/types.ts +42 -42
- package/src/Badge/Badge.native.tsx +42 -42
- package/src/Badge/Badge.styles.tsx +153 -153
- package/src/Badge/Badge.web.tsx +44 -44
- package/src/Badge/index.native.ts +1 -1
- package/src/Badge/index.ts +1 -1
- package/src/Badge/index.web.ts +1 -1
- package/src/Badge/types.ts +33 -33
- package/src/Button/Button.native.tsx +38 -38
- package/src/Button/Button.styles.tsx +214 -214
- package/src/Button/Button.types.ts +11 -11
- package/src/Button/Button.web.tsx +55 -55
- package/src/Button/index.native.ts +2 -2
- package/src/Button/index.ts +4 -4
- package/src/Button/index.web.ts +2 -2
- package/src/Button/types.ts +48 -48
- package/src/Card/Card.native.tsx +51 -51
- package/src/Card/Card.styles.tsx +239 -239
- package/src/Card/Card.web.tsx +61 -61
- package/src/Card/index.native.ts +2 -2
- package/src/Card/index.ts +4 -4
- package/src/Card/index.web.ts +2 -2
- package/src/Card/types.ts +58 -58
- package/src/Checkbox/Checkbox.native.tsx +98 -98
- package/src/Checkbox/Checkbox.styles.tsx +291 -291
- package/src/Checkbox/Checkbox.web.tsx +130 -130
- package/src/Checkbox/index.native.ts +2 -2
- package/src/Checkbox/index.ts +4 -4
- package/src/Checkbox/index.web.ts +2 -2
- package/src/Checkbox/types.ts +78 -78
- package/src/Divider/Divider.native.tsx +144 -144
- package/src/Divider/Divider.styles.tsx +601 -601
- package/src/Divider/Divider.web.tsx +72 -72
- package/src/Divider/index.native.ts +2 -2
- package/src/Divider/index.ts +4 -4
- package/src/Divider/index.web.ts +2 -2
- package/src/Divider/types.ts +53 -53
- package/src/Icon/Icon.native.tsx +38 -38
- package/src/Icon/Icon.styles.tsx +49 -49
- package/src/Icon/Icon.web.tsx +46 -46
- package/src/Icon/icon-types.ts +7452 -7452
- package/src/Icon/index.native.ts +2 -2
- package/src/Icon/index.ts +4 -4
- package/src/Icon/index.web.ts +2 -2
- package/src/Icon/types.ts +35 -35
- package/src/Input/Input.native.tsx +74 -74
- package/src/Input/Input.styles.tsx +176 -176
- package/src/Input/Input.web.tsx +70 -70
- package/src/Input/index.native.ts +2 -2
- package/src/Input/index.ts +4 -4
- package/src/Input/index.web.ts +2 -2
- package/src/Input/types.ts +68 -68
- package/src/Screen/Screen.native.tsx +40 -40
- package/src/Screen/Screen.styles.tsx +59 -59
- package/src/Screen/Screen.web.tsx +32 -32
- package/src/Screen/index.native.ts +1 -1
- package/src/Screen/index.ts +1 -1
- package/src/Screen/index.web.ts +1 -1
- package/src/Screen/types.ts +37 -37
- package/src/Text/Text.native.tsx +35 -35
- package/src/Text/Text.styles.tsx +66 -66
- package/src/Text/Text.web.tsx +40 -40
- package/src/Text/index.native.ts +2 -2
- package/src/Text/index.ts +4 -4
- package/src/Text/index.web.ts +2 -2
- package/src/Text/types.ts +38 -38
- package/src/View/View.native.tsx +55 -55
- package/src/View/View.styles.tsx +102 -102
- package/src/View/View.web.tsx +59 -59
- package/src/View/index.native.ts +2 -2
- package/src/View/index.ts +4 -4
- package/src/View/index.web.ts +2 -2
- package/src/View/types.ts +72 -72
- package/src/examples/AllExamples.tsx +71 -71
- package/src/examples/AvatarExamples.tsx +96 -96
- package/src/examples/BadgeExamples.tsx +199 -199
- package/src/examples/ButtonExamples.tsx +149 -149
- package/src/examples/CardExamples.tsx +175 -175
- package/src/examples/CheckboxExamples.tsx +216 -216
- package/src/examples/DividerExamples.tsx +217 -217
- package/src/examples/IconExamples.tsx +341 -341
- package/src/examples/InputExamples.tsx +133 -133
- package/src/examples/README.md +135 -135
- package/src/examples/ScreenExamples.tsx +153 -153
- package/src/examples/TextExamples.tsx +88 -88
- package/src/examples/ThemeExtensionExamples.tsx +90 -90
- package/src/examples/ValidationExamples.tsx +94 -94
- package/src/examples/ViewExamples.tsx +128 -128
- package/src/examples/extendedTheme.ts +328 -328
- package/src/examples/index.ts +14 -14
- package/src/index.native.ts +48 -48
- package/src/index.ts +47 -47
- package/src/theme/breakpoints.ts +8 -8
- package/src/theme/colorResolver.ts +217 -217
- package/src/theme/colors.ts +314 -314
- package/src/theme/defaultThemes.ts +325 -325
- package/src/theme/index.ts +187 -187
- package/src/theme/themeBuilder.ts +601 -601
- package/src/theme/unistyles.d.ts +5 -5
- package/src/theme/variantHelpers.ts +583 -583
- package/src/theme/variants.ts +55 -55
|
@@ -1,215 +1,215 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { generateIntentVariants, generateButtonCompoundVariants } from '../theme/variantHelpers';
|
|
3
|
-
|
|
4
|
-
export const buttonStyles = StyleSheet.create((theme) => ({
|
|
5
|
-
button: {
|
|
6
|
-
// Base styles - no borders defined here
|
|
7
|
-
alignItems: 'center',
|
|
8
|
-
justifyContent: 'center',
|
|
9
|
-
borderRadius: theme.borderRadius?.md || 8,
|
|
10
|
-
fontWeight: '600',
|
|
11
|
-
textAlign: 'center',
|
|
12
|
-
transition: 'all 0.2s ease',
|
|
13
|
-
// Set default color to prevent fallback to theme.colors.text.placeholder
|
|
14
|
-
color: theme.intents?.primary?.on || '#ffffff',
|
|
15
|
-
|
|
16
|
-
// All variants defined here
|
|
17
|
-
variants: {
|
|
18
|
-
size: {
|
|
19
|
-
small: {
|
|
20
|
-
paddingHorizontal: theme.spacing?.sm || 8,
|
|
21
|
-
paddingVertical: theme.spacing?.xs || 4,
|
|
22
|
-
minHeight: 24,
|
|
23
|
-
},
|
|
24
|
-
medium: {
|
|
25
|
-
paddingHorizontal: theme.spacing?.md || 12,
|
|
26
|
-
paddingVertical: theme.spacing?.sm || 8,
|
|
27
|
-
minHeight: 32,
|
|
28
|
-
},
|
|
29
|
-
large: {
|
|
30
|
-
paddingHorizontal: theme.spacing?.lg || 16,
|
|
31
|
-
paddingVertical: theme.spacing?.md || 12,
|
|
32
|
-
minHeight: 40,
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
// Dynamically generated intent variants
|
|
36
|
-
intent: generateIntentVariants(theme),
|
|
37
|
-
variant: {
|
|
38
|
-
contained: {
|
|
39
|
-
// Contained buttons have no border
|
|
40
|
-
border: 'none',
|
|
41
|
-
},
|
|
42
|
-
outlined: {
|
|
43
|
-
backgroundColor: 'transparent',
|
|
44
|
-
// Border is defined in compound variants
|
|
45
|
-
},
|
|
46
|
-
text: {
|
|
47
|
-
backgroundColor: 'transparent',
|
|
48
|
-
border: 'none',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
disabled: {
|
|
52
|
-
true: {
|
|
53
|
-
opacity: 0.6,
|
|
54
|
-
},
|
|
55
|
-
false: {
|
|
56
|
-
opacity: 1,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
// Dynamically generated compound variants for outlined and text variants
|
|
62
|
-
compoundVariants: generateButtonCompoundVariants(theme),
|
|
63
|
-
|
|
64
|
-
// Web-specific styles
|
|
65
|
-
_web: {
|
|
66
|
-
cursor: 'pointer',
|
|
67
|
-
outline: 'none',
|
|
68
|
-
display: 'flex',
|
|
69
|
-
boxSizing: 'border-box',
|
|
70
|
-
userSelect: 'none',
|
|
71
|
-
// Fix for Chromium-based browsers (Brave, Chrome) border rendering
|
|
72
|
-
WebkitAppearance: 'none',
|
|
73
|
-
MozAppearance: 'none',
|
|
74
|
-
appearance: 'none',
|
|
75
|
-
backfaceVisibility: 'hidden',
|
|
76
|
-
WebkitBackfaceVisibility: 'hidden',
|
|
77
|
-
transform: 'translateZ(0)', // Force hardware acceleration
|
|
78
|
-
_hover: {
|
|
79
|
-
opacity: 0.9,
|
|
80
|
-
},
|
|
81
|
-
_active: {
|
|
82
|
-
transform: 'scale(0.98) translateZ(0)', // Maintain hardware acceleration
|
|
83
|
-
},
|
|
84
|
-
_focus: {
|
|
85
|
-
outlineOffset: '2px',
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
// Separate text style for React Native (no borders, just text properties)
|
|
91
|
-
text: {
|
|
92
|
-
fontWeight: '600',
|
|
93
|
-
textAlign: 'center',
|
|
94
|
-
|
|
95
|
-
variants: {
|
|
96
|
-
size: {
|
|
97
|
-
small: {
|
|
98
|
-
fontSize: 14,
|
|
99
|
-
},
|
|
100
|
-
medium: {
|
|
101
|
-
fontSize: 16,
|
|
102
|
-
},
|
|
103
|
-
large: {
|
|
104
|
-
fontSize: 18,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
intent: {
|
|
108
|
-
primary: {
|
|
109
|
-
color: theme.intents?.primary?.on || '#ffffff',
|
|
110
|
-
},
|
|
111
|
-
success: {
|
|
112
|
-
color: theme.intents?.success?.on || '#ffffff',
|
|
113
|
-
},
|
|
114
|
-
error: {
|
|
115
|
-
color: theme.intents?.error?.on || '#ffffff',
|
|
116
|
-
},
|
|
117
|
-
warning: {
|
|
118
|
-
color: theme.intents?.warning?.on || '#ffffff',
|
|
119
|
-
},
|
|
120
|
-
neutral: {
|
|
121
|
-
color: theme.intents?.neutral?.on || '#ffffff',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
variant: {
|
|
125
|
-
contained: {},
|
|
126
|
-
outlined: {},
|
|
127
|
-
text: {},
|
|
128
|
-
},
|
|
129
|
-
disabled: {
|
|
130
|
-
true: {
|
|
131
|
-
opacity: 0.6,
|
|
132
|
-
},
|
|
133
|
-
false: {
|
|
134
|
-
opacity: 1,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
// Compound variants for text colors in different variants
|
|
140
|
-
compoundVariants: [
|
|
141
|
-
// Outlined variant text colors
|
|
142
|
-
{
|
|
143
|
-
variant: 'outlined',
|
|
144
|
-
intent: 'primary',
|
|
145
|
-
styles: {
|
|
146
|
-
color: theme.intents?.primary?.main || '#3b82f6',
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
variant: 'outlined',
|
|
151
|
-
intent: 'success',
|
|
152
|
-
styles: {
|
|
153
|
-
color: theme.intents?.success?.main || '#22c55e',
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
{
|
|
157
|
-
variant: 'outlined',
|
|
158
|
-
intent: 'error',
|
|
159
|
-
styles: {
|
|
160
|
-
color: theme.intents?.error?.main || '#ef4444',
|
|
161
|
-
},
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
variant: 'outlined',
|
|
165
|
-
intent: 'warning',
|
|
166
|
-
styles: {
|
|
167
|
-
color: theme.intents?.warning?.main || '#f59e0b',
|
|
168
|
-
},
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
variant: 'outlined',
|
|
172
|
-
intent: 'neutral',
|
|
173
|
-
styles: {
|
|
174
|
-
color: theme.intents?.neutral?.main || '#6b7280',
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
// Text variant text colors
|
|
178
|
-
{
|
|
179
|
-
variant: 'text',
|
|
180
|
-
intent: 'primary',
|
|
181
|
-
styles: {
|
|
182
|
-
color: theme.intents?.primary?.main || '#3b82f6',
|
|
183
|
-
},
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
variant: 'text',
|
|
187
|
-
intent: 'success',
|
|
188
|
-
styles: {
|
|
189
|
-
color: theme.intents?.success?.main || '#22c55e',
|
|
190
|
-
},
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
variant: 'text',
|
|
194
|
-
intent: 'error',
|
|
195
|
-
styles: {
|
|
196
|
-
color: theme.intents?.error?.main || '#ef4444',
|
|
197
|
-
},
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
variant: 'text',
|
|
201
|
-
intent: 'warning',
|
|
202
|
-
styles: {
|
|
203
|
-
color: theme.intents?.warning?.main || '#f59e0b',
|
|
204
|
-
},
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
variant: 'text',
|
|
208
|
-
intent: 'neutral',
|
|
209
|
-
styles: {
|
|
210
|
-
color: theme.intents?.neutral?.main || '#6b7280',
|
|
211
|
-
},
|
|
212
|
-
},
|
|
213
|
-
],
|
|
214
|
-
},
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import { generateIntentVariants, generateButtonCompoundVariants } from '../theme/variantHelpers';
|
|
3
|
+
|
|
4
|
+
export const buttonStyles = StyleSheet.create((theme) => ({
|
|
5
|
+
button: {
|
|
6
|
+
// Base styles - no borders defined here
|
|
7
|
+
alignItems: 'center',
|
|
8
|
+
justifyContent: 'center',
|
|
9
|
+
borderRadius: theme.borderRadius?.md || 8,
|
|
10
|
+
fontWeight: '600',
|
|
11
|
+
textAlign: 'center',
|
|
12
|
+
transition: 'all 0.2s ease',
|
|
13
|
+
// Set default color to prevent fallback to theme.colors.text.placeholder
|
|
14
|
+
color: theme.intents?.primary?.on || '#ffffff',
|
|
15
|
+
|
|
16
|
+
// All variants defined here
|
|
17
|
+
variants: {
|
|
18
|
+
size: {
|
|
19
|
+
small: {
|
|
20
|
+
paddingHorizontal: theme.spacing?.sm || 8,
|
|
21
|
+
paddingVertical: theme.spacing?.xs || 4,
|
|
22
|
+
minHeight: 24,
|
|
23
|
+
},
|
|
24
|
+
medium: {
|
|
25
|
+
paddingHorizontal: theme.spacing?.md || 12,
|
|
26
|
+
paddingVertical: theme.spacing?.sm || 8,
|
|
27
|
+
minHeight: 32,
|
|
28
|
+
},
|
|
29
|
+
large: {
|
|
30
|
+
paddingHorizontal: theme.spacing?.lg || 16,
|
|
31
|
+
paddingVertical: theme.spacing?.md || 12,
|
|
32
|
+
minHeight: 40,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
// Dynamically generated intent variants
|
|
36
|
+
intent: generateIntentVariants(theme),
|
|
37
|
+
variant: {
|
|
38
|
+
contained: {
|
|
39
|
+
// Contained buttons have no border
|
|
40
|
+
border: 'none',
|
|
41
|
+
},
|
|
42
|
+
outlined: {
|
|
43
|
+
backgroundColor: 'transparent',
|
|
44
|
+
// Border is defined in compound variants
|
|
45
|
+
},
|
|
46
|
+
text: {
|
|
47
|
+
backgroundColor: 'transparent',
|
|
48
|
+
border: 'none',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
disabled: {
|
|
52
|
+
true: {
|
|
53
|
+
opacity: 0.6,
|
|
54
|
+
},
|
|
55
|
+
false: {
|
|
56
|
+
opacity: 1,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
|
|
61
|
+
// Dynamically generated compound variants for outlined and text variants
|
|
62
|
+
compoundVariants: generateButtonCompoundVariants(theme),
|
|
63
|
+
|
|
64
|
+
// Web-specific styles
|
|
65
|
+
_web: {
|
|
66
|
+
cursor: 'pointer',
|
|
67
|
+
outline: 'none',
|
|
68
|
+
display: 'flex',
|
|
69
|
+
boxSizing: 'border-box',
|
|
70
|
+
userSelect: 'none',
|
|
71
|
+
// Fix for Chromium-based browsers (Brave, Chrome) border rendering
|
|
72
|
+
WebkitAppearance: 'none',
|
|
73
|
+
MozAppearance: 'none',
|
|
74
|
+
appearance: 'none',
|
|
75
|
+
backfaceVisibility: 'hidden',
|
|
76
|
+
WebkitBackfaceVisibility: 'hidden',
|
|
77
|
+
transform: 'translateZ(0)', // Force hardware acceleration
|
|
78
|
+
_hover: {
|
|
79
|
+
opacity: 0.9,
|
|
80
|
+
},
|
|
81
|
+
_active: {
|
|
82
|
+
transform: 'scale(0.98) translateZ(0)', // Maintain hardware acceleration
|
|
83
|
+
},
|
|
84
|
+
_focus: {
|
|
85
|
+
outlineOffset: '2px',
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// Separate text style for React Native (no borders, just text properties)
|
|
91
|
+
text: {
|
|
92
|
+
fontWeight: '600',
|
|
93
|
+
textAlign: 'center',
|
|
94
|
+
|
|
95
|
+
variants: {
|
|
96
|
+
size: {
|
|
97
|
+
small: {
|
|
98
|
+
fontSize: 14,
|
|
99
|
+
},
|
|
100
|
+
medium: {
|
|
101
|
+
fontSize: 16,
|
|
102
|
+
},
|
|
103
|
+
large: {
|
|
104
|
+
fontSize: 18,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
intent: {
|
|
108
|
+
primary: {
|
|
109
|
+
color: theme.intents?.primary?.on || '#ffffff',
|
|
110
|
+
},
|
|
111
|
+
success: {
|
|
112
|
+
color: theme.intents?.success?.on || '#ffffff',
|
|
113
|
+
},
|
|
114
|
+
error: {
|
|
115
|
+
color: theme.intents?.error?.on || '#ffffff',
|
|
116
|
+
},
|
|
117
|
+
warning: {
|
|
118
|
+
color: theme.intents?.warning?.on || '#ffffff',
|
|
119
|
+
},
|
|
120
|
+
neutral: {
|
|
121
|
+
color: theme.intents?.neutral?.on || '#ffffff',
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
variant: {
|
|
125
|
+
contained: {},
|
|
126
|
+
outlined: {},
|
|
127
|
+
text: {},
|
|
128
|
+
},
|
|
129
|
+
disabled: {
|
|
130
|
+
true: {
|
|
131
|
+
opacity: 0.6,
|
|
132
|
+
},
|
|
133
|
+
false: {
|
|
134
|
+
opacity: 1,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
|
|
139
|
+
// Compound variants for text colors in different variants
|
|
140
|
+
compoundVariants: [
|
|
141
|
+
// Outlined variant text colors
|
|
142
|
+
{
|
|
143
|
+
variant: 'outlined',
|
|
144
|
+
intent: 'primary',
|
|
145
|
+
styles: {
|
|
146
|
+
color: theme.intents?.primary?.main || '#3b82f6',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
variant: 'outlined',
|
|
151
|
+
intent: 'success',
|
|
152
|
+
styles: {
|
|
153
|
+
color: theme.intents?.success?.main || '#22c55e',
|
|
154
|
+
},
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
variant: 'outlined',
|
|
158
|
+
intent: 'error',
|
|
159
|
+
styles: {
|
|
160
|
+
color: theme.intents?.error?.main || '#ef4444',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
variant: 'outlined',
|
|
165
|
+
intent: 'warning',
|
|
166
|
+
styles: {
|
|
167
|
+
color: theme.intents?.warning?.main || '#f59e0b',
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
variant: 'outlined',
|
|
172
|
+
intent: 'neutral',
|
|
173
|
+
styles: {
|
|
174
|
+
color: theme.intents?.neutral?.main || '#6b7280',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
// Text variant text colors
|
|
178
|
+
{
|
|
179
|
+
variant: 'text',
|
|
180
|
+
intent: 'primary',
|
|
181
|
+
styles: {
|
|
182
|
+
color: theme.intents?.primary?.main || '#3b82f6',
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
variant: 'text',
|
|
187
|
+
intent: 'success',
|
|
188
|
+
styles: {
|
|
189
|
+
color: theme.intents?.success?.main || '#22c55e',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
variant: 'text',
|
|
194
|
+
intent: 'error',
|
|
195
|
+
styles: {
|
|
196
|
+
color: theme.intents?.error?.main || '#ef4444',
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
variant: 'text',
|
|
201
|
+
intent: 'warning',
|
|
202
|
+
styles: {
|
|
203
|
+
color: theme.intents?.warning?.main || '#f59e0b',
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
variant: 'text',
|
|
208
|
+
intent: 'neutral',
|
|
209
|
+
styles: {
|
|
210
|
+
color: theme.intents?.neutral?.main || '#6b7280',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
215
|
}));
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { TouchableOpacityProps } from 'react-native';
|
|
2
|
-
import { IntentNames } from '../theme';
|
|
3
|
-
|
|
4
|
-
export interface ButtonProps extends Omit<TouchableOpacityProps, 'disabled'> {
|
|
5
|
-
title: string;
|
|
6
|
-
onPress: () => void;
|
|
7
|
-
variant?: 'contained' | 'outlined' | 'text';
|
|
8
|
-
intent?: IntentNames;
|
|
9
|
-
size?: 'small' | 'medium' | 'large';
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
loading?: boolean;
|
|
1
|
+
import { TouchableOpacityProps } from 'react-native';
|
|
2
|
+
import { IntentNames } from '../theme';
|
|
3
|
+
|
|
4
|
+
export interface ButtonProps extends Omit<TouchableOpacityProps, 'disabled'> {
|
|
5
|
+
title: string;
|
|
6
|
+
onPress: () => void;
|
|
7
|
+
variant?: 'contained' | 'outlined' | 'text';
|
|
8
|
+
intent?: IntentNames;
|
|
9
|
+
size?: 'small' | 'medium' | 'large';
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
loading?: boolean;
|
|
12
12
|
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { getWebProps } from 'react-native-unistyles/web';
|
|
3
|
-
import { ButtonProps } from './types';
|
|
4
|
-
import { buttonStyles } from './Button.styles';
|
|
5
|
-
|
|
6
|
-
const Button: React.FC<ButtonProps> = ({
|
|
7
|
-
title,
|
|
8
|
-
children,
|
|
9
|
-
onPress,
|
|
10
|
-
disabled = false,
|
|
11
|
-
variant = 'contained',
|
|
12
|
-
intent = 'primary',
|
|
13
|
-
size = 'medium',
|
|
14
|
-
style,
|
|
15
|
-
testID,
|
|
16
|
-
}) => {
|
|
17
|
-
const handleClick = () => {
|
|
18
|
-
if (!disabled && onPress) {
|
|
19
|
-
onPress();
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// Apply variants using the correct Unistyles 3.0 pattern
|
|
24
|
-
buttonStyles.useVariants({
|
|
25
|
-
size: size as 'small' | 'medium' | 'large',
|
|
26
|
-
intent: intent as 'primary' | 'success' | 'error' | 'warning' | 'neutral',
|
|
27
|
-
variant: variant as 'contained' | 'outlined' | 'text',
|
|
28
|
-
disabled: disabled as boolean,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
// Create the style array following the official documentation pattern
|
|
32
|
-
const buttonStyleArray = [
|
|
33
|
-
buttonStyles.button,
|
|
34
|
-
buttonStyles.text, // Include text styles for font sizing
|
|
35
|
-
style,
|
|
36
|
-
];
|
|
37
|
-
|
|
38
|
-
// Use getWebProps to generate className and ref for web
|
|
39
|
-
const webProps = getWebProps(buttonStyleArray);
|
|
40
|
-
|
|
41
|
-
// Use children if available, otherwise use title
|
|
42
|
-
const buttonContent = children || title;
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<button
|
|
46
|
-
{...webProps}
|
|
47
|
-
onClick={handleClick}
|
|
48
|
-
disabled={disabled}
|
|
49
|
-
data-testid={testID}
|
|
50
|
-
>
|
|
51
|
-
{buttonContent}
|
|
52
|
-
</button>
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getWebProps } from 'react-native-unistyles/web';
|
|
3
|
+
import { ButtonProps } from './types';
|
|
4
|
+
import { buttonStyles } from './Button.styles';
|
|
5
|
+
|
|
6
|
+
const Button: React.FC<ButtonProps> = ({
|
|
7
|
+
title,
|
|
8
|
+
children,
|
|
9
|
+
onPress,
|
|
10
|
+
disabled = false,
|
|
11
|
+
variant = 'contained',
|
|
12
|
+
intent = 'primary',
|
|
13
|
+
size = 'medium',
|
|
14
|
+
style,
|
|
15
|
+
testID,
|
|
16
|
+
}) => {
|
|
17
|
+
const handleClick = () => {
|
|
18
|
+
if (!disabled && onPress) {
|
|
19
|
+
onPress();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// Apply variants using the correct Unistyles 3.0 pattern
|
|
24
|
+
buttonStyles.useVariants({
|
|
25
|
+
size: size as 'small' | 'medium' | 'large',
|
|
26
|
+
intent: intent as 'primary' | 'success' | 'error' | 'warning' | 'neutral',
|
|
27
|
+
variant: variant as 'contained' | 'outlined' | 'text',
|
|
28
|
+
disabled: disabled as boolean,
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Create the style array following the official documentation pattern
|
|
32
|
+
const buttonStyleArray = [
|
|
33
|
+
buttonStyles.button,
|
|
34
|
+
buttonStyles.text, // Include text styles for font sizing
|
|
35
|
+
style,
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
// Use getWebProps to generate className and ref for web
|
|
39
|
+
const webProps = getWebProps(buttonStyleArray);
|
|
40
|
+
|
|
41
|
+
// Use children if available, otherwise use title
|
|
42
|
+
const buttonContent = children || title;
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<button
|
|
46
|
+
{...webProps}
|
|
47
|
+
onClick={handleClick}
|
|
48
|
+
disabled={disabled}
|
|
49
|
+
data-testid={testID}
|
|
50
|
+
>
|
|
51
|
+
{buttonContent}
|
|
52
|
+
</button>
|
|
53
|
+
);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
56
|
export default Button;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
// React Native-specific Button export
|
|
2
|
-
export { default } from './Button.native';
|
|
1
|
+
// React Native-specific Button export
|
|
2
|
+
export { default } from './Button.native';
|
|
3
3
|
export * from './types';
|
package/src/Button/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Platform-agnostic Button export
|
|
2
|
-
// Metro will resolve to index.native.ts for React Native
|
|
3
|
-
// This file serves as fallback for web environments
|
|
4
|
-
export { default } from './Button.web';
|
|
1
|
+
// Platform-agnostic Button export
|
|
2
|
+
// Metro will resolve to index.native.ts for React Native
|
|
3
|
+
// This file serves as fallback for web environments
|
|
4
|
+
export { default } from './Button.web';
|
|
5
5
|
export * from './types';
|
package/src/Button/index.web.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
// Web-specific Button export
|
|
2
|
-
export { default } from './Button.web';
|
|
1
|
+
// Web-specific Button export
|
|
2
|
+
export { default } from './Button.web';
|
|
3
3
|
export * from './types';
|