@idealyst/components 1.2.13 → 1.2.14
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 +3 -3
- package/src/ActivityIndicator/ActivityIndicator.native.tsx +3 -3
- package/src/ActivityIndicator/ActivityIndicator.web.tsx +3 -3
- package/src/Avatar/Avatar.native.tsx +1 -1
- package/src/Breadcrumb/Breadcrumb.native.tsx +20 -21
- package/src/Dialog/Dialog.native.tsx +2 -2
- package/src/Icon/types.ts +3 -0
- package/src/Skeleton/Skeleton.native.tsx +3 -3
- package/src/Skeleton/Skeleton.web.tsx +3 -3
- package/src/Slider/Slider.native.tsx +2 -2
- package/src/TabBar/TabBar.native.tsx +2 -2
- package/src/index.native.ts +1 -1
- package/src/index.ts +1 -1
- package/src/Accordion/Accordion.styles.old.tsx +0 -298
- package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +0 -94
- package/src/Alert/Alert.styles.old.tsx +0 -209
- package/src/Avatar/Avatar.styles.old.tsx +0 -99
- package/src/Badge/Badge.styles.old.tsx +0 -157
- package/src/Breadcrumb/Breadcrumb.styles.old.tsx +0 -231
- package/src/Card/Card.styles.old.tsx +0 -160
- package/src/Checkbox/Checkbox.styles.old.tsx +0 -271
- package/src/Chip/Chip.styles.old.tsx +0 -184
- package/src/Dialog/Dialog.styles.old.tsx +0 -202
- package/src/Divider/Divider.styles.old.tsx +0 -172
- package/src/Icon/Icon.styles.old.tsx +0 -81
- package/src/Image/Image.styles.old.tsx +0 -69
- package/src/Input/Input.styles.old.tsx +0 -289
- package/src/List/List.styles.old.tsx +0 -242
- package/src/Menu/Menu.styles.old.tsx +0 -197
- package/src/Menu/MenuItem.styles.old.tsx +0 -114
- package/src/Popover/Popover.styles.old.tsx +0 -135
- package/src/Pressable/Pressable.styles.old.tsx +0 -27
- package/src/Progress/Progress.styles.old.tsx +0 -200
- package/src/RadioButton/RadioButton.styles.old.tsx +0 -175
- package/src/SVGImage/SVGImage.styles.old.tsx +0 -86
- package/src/Screen/Screen.styles.old.tsx +0 -87
- package/src/Select/Select.styles.old.tsx +0 -353
- package/src/Skeleton/Skeleton.styles.old.tsx +0 -67
- package/src/Slider/Slider.styles.old.tsx +0 -259
- package/src/Switch/Switch.styles.old.tsx +0 -203
- package/src/TabBar/TabBar.styles.old.tsx +0 -343
- package/src/Table/Table.styles.old.tsx +0 -311
- package/src/Text/Text.styles.old.tsx +0 -219
- package/src/TextArea/TextArea.styles.old.tsx +0 -213
- package/src/Tooltip/Tooltip.styles.old.tsx +0 -82
- package/src/Video/Video.styles.old.tsx +0 -51
- package/src/View/View.styles.old.tsx +0 -125
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, StylesheetStyles } from '@idealyst/theme';
|
|
3
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
4
|
-
|
|
5
|
-
type SkeletonShape = 'rectangle' | 'rounded' | 'circle';
|
|
6
|
-
type SkeletonAnimation = 'pulse' | 'wave' | 'none';
|
|
7
|
-
|
|
8
|
-
type SkeletonVariants = {
|
|
9
|
-
shape: SkeletonShape;
|
|
10
|
-
animation: SkeletonAnimation;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type ExpandedSkeletonStyles = StylesheetStyles<keyof SkeletonVariants>;
|
|
14
|
-
export type ExpandedSkeletonGroupStyles = StylesheetStyles<never>;
|
|
15
|
-
|
|
16
|
-
export type SkeletonStylesheet = {
|
|
17
|
-
skeleton: ExpandedSkeletonStyles;
|
|
18
|
-
group: ExpandedSkeletonGroupStyles;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Create shape variants for skeleton
|
|
23
|
-
*/
|
|
24
|
-
function createShapeVariants(theme: Theme) {
|
|
25
|
-
return {
|
|
26
|
-
rectangle: {
|
|
27
|
-
borderRadius: 0,
|
|
28
|
-
},
|
|
29
|
-
rounded: {
|
|
30
|
-
borderRadius: 8,
|
|
31
|
-
},
|
|
32
|
-
circle: {
|
|
33
|
-
borderRadius: 9999,
|
|
34
|
-
},
|
|
35
|
-
} as const;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Style creators for extension support
|
|
39
|
-
function createSkeletonStyles(theme: Theme) {
|
|
40
|
-
return () => ({
|
|
41
|
-
backgroundColor: theme.colors.surface.tertiary,
|
|
42
|
-
overflow: 'hidden' as const,
|
|
43
|
-
variants: {
|
|
44
|
-
shape: createShapeVariants(theme),
|
|
45
|
-
animation: {
|
|
46
|
-
pulse: {},
|
|
47
|
-
wave: {},
|
|
48
|
-
none: {},
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
55
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
56
|
-
// @ts-ignore - TS language server needs restart to pick up theme structure changes
|
|
57
|
-
export const skeletonStyles = StyleSheet.create((theme: Theme) => {
|
|
58
|
-
// Apply extensions to main visual elements
|
|
59
|
-
|
|
60
|
-
return applyExtensions('Skeleton', theme, {skeleton: createSkeletonStyles(theme),
|
|
61
|
-
// Additional styles (merged from return)
|
|
62
|
-
// Minor utility styles (not extended)
|
|
63
|
-
group: {
|
|
64
|
-
display: 'flex',
|
|
65
|
-
flexDirection: 'column',
|
|
66
|
-
}});
|
|
67
|
-
});
|
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, Size, Styles} from '@idealyst/theme';
|
|
3
|
-
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
-
import {
|
|
5
|
-
buildMarginVariants,
|
|
6
|
-
buildMarginVerticalVariants,
|
|
7
|
-
buildMarginHorizontalVariants,
|
|
8
|
-
} from '../utils/buildViewStyleVariants';
|
|
9
|
-
import { SliderIntentVariant } from './types';
|
|
10
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Create size variants for track
|
|
14
|
-
*/
|
|
15
|
-
function createTrackSizeVariants(theme: Theme) {
|
|
16
|
-
const variants = {} as Record<Size, Styles>;
|
|
17
|
-
for (const sizeKey in theme.sizes.slider) {
|
|
18
|
-
const size = sizeKey as Size;
|
|
19
|
-
variants[size] = {
|
|
20
|
-
height: theme.sizes.slider[size].trackHeight,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return variants;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Get filled track color based on intent
|
|
28
|
-
*/
|
|
29
|
-
function getFilledTrackColor(theme: Theme, intent: SliderIntentVariant) {
|
|
30
|
-
return theme.intents[intent].primary;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Create size variants for thumb
|
|
35
|
-
*/
|
|
36
|
-
function createThumbSizeVariants(theme: Theme) {
|
|
37
|
-
return buildSizeVariants(theme, 'slider', (size) => ({
|
|
38
|
-
width: size.thumbSize,
|
|
39
|
-
height: size.thumbSize,
|
|
40
|
-
}));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Get thumb border color based on intent
|
|
45
|
-
*/
|
|
46
|
-
function getThumbBorderColor(theme: Theme, intent: SliderIntentVariant) {
|
|
47
|
-
return theme.intents[intent].primary;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Create size variants for thumb icon
|
|
52
|
-
*/
|
|
53
|
-
function createThumbIconSizeVariants(theme: Theme) {
|
|
54
|
-
return buildSizeVariants(theme, 'slider', (size) => ({
|
|
55
|
-
width: size.thumbIconSize,
|
|
56
|
-
height: size.thumbIconSize,
|
|
57
|
-
minWidth: size.thumbIconSize,
|
|
58
|
-
maxWidth: size.thumbIconSize,
|
|
59
|
-
minHeight: size.thumbIconSize,
|
|
60
|
-
maxHeight: size.thumbIconSize,
|
|
61
|
-
}));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Get thumb icon color based on intent
|
|
66
|
-
*/
|
|
67
|
-
function getThumbIconColor(theme: Theme, intent: SliderIntentVariant){
|
|
68
|
-
return theme.intents[intent].primary;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Create size variants for mark
|
|
73
|
-
*/
|
|
74
|
-
function createMarkSizeVariants(theme: Theme) {
|
|
75
|
-
return buildSizeVariants(theme, 'slider', (size) => ({
|
|
76
|
-
height: size.markHeight,
|
|
77
|
-
}));
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const createFilledTrackStyles = (theme: Theme) => {
|
|
81
|
-
return ({ intent }: { intent: SliderIntentVariant }) => {
|
|
82
|
-
return {
|
|
83
|
-
position: 'absolute',
|
|
84
|
-
height: '100%',
|
|
85
|
-
borderRadius: 9999,
|
|
86
|
-
top: 0,
|
|
87
|
-
left: 0,
|
|
88
|
-
backgroundColor: getFilledTrackColor(theme, intent),
|
|
89
|
-
} as const;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const createThumbStyles = (theme: Theme) => {
|
|
94
|
-
return ({ intent, disabled }: { intent: SliderIntentVariant, disabled: boolean }) => {
|
|
95
|
-
return {
|
|
96
|
-
position: 'absolute',
|
|
97
|
-
backgroundColor: theme.colors.surface.primary,
|
|
98
|
-
borderRadius: 9999,
|
|
99
|
-
borderWidth: 2,
|
|
100
|
-
borderStyle: 'solid',
|
|
101
|
-
borderColor: getThumbBorderColor(theme, intent),
|
|
102
|
-
top: '50%',
|
|
103
|
-
display: 'flex',
|
|
104
|
-
alignItems: 'center',
|
|
105
|
-
justifyContent: 'center',
|
|
106
|
-
shadowColor: '#000',
|
|
107
|
-
shadowOffset: { width: 0, height: 2 },
|
|
108
|
-
shadowOpacity: 0.2,
|
|
109
|
-
shadowRadius: 4,
|
|
110
|
-
elevation: 2,
|
|
111
|
-
variants: {
|
|
112
|
-
size: createThumbSizeVariants(theme),
|
|
113
|
-
disabled: {
|
|
114
|
-
true: {
|
|
115
|
-
opacity: 0.6,
|
|
116
|
-
_web: {
|
|
117
|
-
cursor: 'not-allowed',
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
false: {
|
|
121
|
-
opacity: 1,
|
|
122
|
-
_web: {
|
|
123
|
-
cursor: 'grab',
|
|
124
|
-
_hover: {
|
|
125
|
-
transform: 'translate(-50%, -50%) scale(1.05)',
|
|
126
|
-
},
|
|
127
|
-
_active: {
|
|
128
|
-
cursor: 'grabbing',
|
|
129
|
-
transform: 'translate(-50%, -50%) scale(1.1)',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
_web: {
|
|
136
|
-
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.2)',
|
|
137
|
-
transform: 'translate(-50%, -50%)',
|
|
138
|
-
transition: 'transform 0.15s ease, box-shadow 0.2s ease',
|
|
139
|
-
},
|
|
140
|
-
} as const;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const createThumbIconStyles = (theme: Theme) => {
|
|
145
|
-
return ({ intent }: { intent: SliderIntentVariant }) => {
|
|
146
|
-
return {
|
|
147
|
-
display: 'flex',
|
|
148
|
-
alignItems: 'center',
|
|
149
|
-
justifyContent: 'center',
|
|
150
|
-
flexShrink: 0,
|
|
151
|
-
color: getThumbIconColor(theme, intent),
|
|
152
|
-
variants: {
|
|
153
|
-
size: createThumbIconSizeVariants(theme),
|
|
154
|
-
},
|
|
155
|
-
} as const;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Container style creator for extension support
|
|
160
|
-
function createContainerStyles(theme: Theme) {
|
|
161
|
-
return () => ({
|
|
162
|
-
gap: 4,
|
|
163
|
-
paddingVertical: 8,
|
|
164
|
-
variants: {
|
|
165
|
-
margin: buildMarginVariants(theme),
|
|
166
|
-
marginVertical: buildMarginVerticalVariants(theme),
|
|
167
|
-
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
168
|
-
},
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// Track style creator for extension support
|
|
173
|
-
function createTrackStyles(theme: Theme) {
|
|
174
|
-
return () => ({
|
|
175
|
-
backgroundColor: theme.colors.surface.tertiary,
|
|
176
|
-
borderRadius: 9999,
|
|
177
|
-
position: 'relative' as const,
|
|
178
|
-
variants: {
|
|
179
|
-
size: createTrackSizeVariants(theme),
|
|
180
|
-
disabled: {
|
|
181
|
-
true: {
|
|
182
|
-
opacity: 0.5,
|
|
183
|
-
_web: { cursor: 'not-allowed' },
|
|
184
|
-
},
|
|
185
|
-
false: {
|
|
186
|
-
opacity: 1,
|
|
187
|
-
_web: { cursor: 'pointer' },
|
|
188
|
-
},
|
|
189
|
-
},
|
|
190
|
-
} as const,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel transform on native cannot resolve function calls to extract variant structures.
|
|
195
|
-
export const sliderStyles = StyleSheet.create((theme: Theme) => {
|
|
196
|
-
// Apply extensions to main visual elements
|
|
197
|
-
|
|
198
|
-
return applyExtensions('Slider', theme, {container: createContainerStyles(theme),
|
|
199
|
-
track: createTrackStyles(theme),
|
|
200
|
-
filledTrack: createFilledTrackStyles(theme),
|
|
201
|
-
thumb: createThumbStyles(theme),
|
|
202
|
-
thumbIcon: createThumbIconStyles(theme),
|
|
203
|
-
// Additional styles (merged from return)
|
|
204
|
-
// Minor utility styles
|
|
205
|
-
sliderWrapper: {
|
|
206
|
-
position: 'relative',
|
|
207
|
-
paddingVertical: 4,
|
|
208
|
-
},
|
|
209
|
-
thumbActive: {
|
|
210
|
-
_web: {
|
|
211
|
-
transform: 'translate(-50%, -50%) scale(1.1)',
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
valueLabel: {
|
|
215
|
-
fontSize: 12,
|
|
216
|
-
fontWeight: '600',
|
|
217
|
-
color: theme.colors.text.primary,
|
|
218
|
-
textAlign: 'center',
|
|
219
|
-
},
|
|
220
|
-
minMaxLabels: {
|
|
221
|
-
flexDirection: 'row',
|
|
222
|
-
justifyContent: 'space-between',
|
|
223
|
-
marginTop: 4,
|
|
224
|
-
},
|
|
225
|
-
minMaxLabel: {
|
|
226
|
-
fontSize: 12,
|
|
227
|
-
color: theme.colors.text.secondary,
|
|
228
|
-
},
|
|
229
|
-
mark: {
|
|
230
|
-
position: 'absolute',
|
|
231
|
-
width: 2,
|
|
232
|
-
backgroundColor: theme.colors.border.secondary,
|
|
233
|
-
top: '50%',
|
|
234
|
-
variants: {
|
|
235
|
-
size: createMarkSizeVariants(theme),
|
|
236
|
-
},
|
|
237
|
-
_web: {
|
|
238
|
-
transform: 'translate(-50%, -50%)',
|
|
239
|
-
},
|
|
240
|
-
},
|
|
241
|
-
marks: {
|
|
242
|
-
position: 'absolute',
|
|
243
|
-
width: '100%',
|
|
244
|
-
height: '100%',
|
|
245
|
-
top: 0,
|
|
246
|
-
left: 0,
|
|
247
|
-
},
|
|
248
|
-
markLabel: {
|
|
249
|
-
position: 'absolute',
|
|
250
|
-
fontSize: 10,
|
|
251
|
-
color: theme.colors.text.secondary,
|
|
252
|
-
top: '100%',
|
|
253
|
-
marginTop: 4,
|
|
254
|
-
_web: {
|
|
255
|
-
transform: 'translateX(-50%)',
|
|
256
|
-
whiteSpace: 'nowrap',
|
|
257
|
-
},
|
|
258
|
-
}});
|
|
259
|
-
});
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, StylesheetStyles, Intent, Size } from '@idealyst/theme';
|
|
3
|
-
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
-
import {
|
|
5
|
-
buildMarginVariants,
|
|
6
|
-
buildMarginVerticalVariants,
|
|
7
|
-
buildMarginHorizontalVariants,
|
|
8
|
-
} from '../utils/buildViewStyleVariants';
|
|
9
|
-
import { SwitchIntentVariant, SwitchSizeVariant } from './types';
|
|
10
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
11
|
-
|
|
12
|
-
function createTrackSizeVariants(theme: Theme) {
|
|
13
|
-
return buildSizeVariants(theme, 'switch', (size) => ({
|
|
14
|
-
width: size.trackWidth,
|
|
15
|
-
height: size.trackHeight,
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function getTrackBackgroundColor(theme: Theme, checked: boolean, intent: SwitchIntentVariant) {
|
|
20
|
-
if (checked) {
|
|
21
|
-
return theme.intents[intent].primary;
|
|
22
|
-
}
|
|
23
|
-
return theme.colors.border.secondary;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function createThumbSizeVariants(theme: Theme) {
|
|
27
|
-
return buildSizeVariants(theme, 'switch', (size) => ({
|
|
28
|
-
width: size.thumbSize,
|
|
29
|
-
height: size.thumbSize,
|
|
30
|
-
left: 2,
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function getThumbTransform(theme: Theme, size: SwitchSizeVariant, checked: boolean) {
|
|
35
|
-
const sizeValue = theme.sizes.switch[size];
|
|
36
|
-
const translateX = checked ? sizeValue.translateX : 0;
|
|
37
|
-
return `translateY(-50%) translateX(${translateX}px)`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function createThumbIconSizeVariants(theme: Theme) {
|
|
41
|
-
return buildSizeVariants(theme, 'switch', (size) => ({
|
|
42
|
-
width: size.thumbIconSize,
|
|
43
|
-
height: size.thumbIconSize,
|
|
44
|
-
}));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function getThumbIconColor(theme: Theme, checked: boolean, intent: SwitchIntentVariant) {
|
|
48
|
-
if (checked) {
|
|
49
|
-
return theme.intents[intent].primary;
|
|
50
|
-
}
|
|
51
|
-
return theme.colors.border.secondary;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function createSwitchTrackStyles(theme: Theme) {
|
|
55
|
-
return ({ checked, intent }: { checked: boolean, intent: SwitchIntentVariant }) => {
|
|
56
|
-
return {
|
|
57
|
-
borderRadius: 9999,
|
|
58
|
-
position: 'relative',
|
|
59
|
-
backgroundColor: getTrackBackgroundColor(theme, checked, intent),
|
|
60
|
-
variants: {
|
|
61
|
-
size: createTrackSizeVariants(theme),
|
|
62
|
-
disabled: {
|
|
63
|
-
true: {
|
|
64
|
-
opacity: 0.5,
|
|
65
|
-
_web: {
|
|
66
|
-
cursor: 'not-allowed',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
false: {
|
|
70
|
-
opacity: 1,
|
|
71
|
-
_web: {
|
|
72
|
-
cursor: 'pointer',
|
|
73
|
-
_hover: {
|
|
74
|
-
opacity: 0.9,
|
|
75
|
-
},
|
|
76
|
-
_active: {
|
|
77
|
-
opacity: 0.8,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
} as const,
|
|
83
|
-
_web: {
|
|
84
|
-
transition: 'background-color 0.2s ease',
|
|
85
|
-
},
|
|
86
|
-
} as const;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
function createSwitchThumbStyles(theme: Theme) {
|
|
91
|
-
return ({ size, checked }: { size: SwitchSizeVariant, checked: boolean }) => {
|
|
92
|
-
return {
|
|
93
|
-
position: 'absolute',
|
|
94
|
-
backgroundColor: theme.colors.surface.primary,
|
|
95
|
-
borderRadius: 9999,
|
|
96
|
-
top: '50%',
|
|
97
|
-
display: 'flex',
|
|
98
|
-
alignItems: 'center',
|
|
99
|
-
justifyContent: 'center',
|
|
100
|
-
shadowColor: '#000',
|
|
101
|
-
shadowOffset: { width: 0, height: 1 },
|
|
102
|
-
shadowOpacity: 0.2,
|
|
103
|
-
shadowRadius: 3,
|
|
104
|
-
elevation: 2,
|
|
105
|
-
variants: {
|
|
106
|
-
size: createThumbSizeVariants(theme),
|
|
107
|
-
},
|
|
108
|
-
_web: {
|
|
109
|
-
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.2)',
|
|
110
|
-
transition: 'transform 0.2s ease',
|
|
111
|
-
transform: getThumbTransform(theme, size, checked),
|
|
112
|
-
},
|
|
113
|
-
} as const;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
function createThumbIconStyles(theme: Theme) {
|
|
118
|
-
return ({ checked, intent }: { checked: boolean, intent: SwitchIntentVariant }) => {
|
|
119
|
-
return {
|
|
120
|
-
display: 'flex',
|
|
121
|
-
alignItems: 'center',
|
|
122
|
-
justifyContent: 'center',
|
|
123
|
-
color: getThumbIconColor(theme, checked, intent),
|
|
124
|
-
variants: {
|
|
125
|
-
size: createThumbIconSizeVariants(theme),
|
|
126
|
-
},
|
|
127
|
-
} as const;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Create container styles
|
|
133
|
-
*/
|
|
134
|
-
function createContainerStyles(theme: Theme) {
|
|
135
|
-
return () => ({
|
|
136
|
-
flexDirection: 'row' as const,
|
|
137
|
-
alignItems: 'center' as const,
|
|
138
|
-
gap: 8,
|
|
139
|
-
variants: {
|
|
140
|
-
margin: buildMarginVariants(theme),
|
|
141
|
-
marginVertical: buildMarginVerticalVariants(theme),
|
|
142
|
-
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Create switch container styles
|
|
149
|
-
*/
|
|
150
|
-
function createSwitchContainerStyles() {
|
|
151
|
-
return () => ({
|
|
152
|
-
justifyContent: 'center' as const,
|
|
153
|
-
_web: {
|
|
154
|
-
border: 'none',
|
|
155
|
-
padding: 0,
|
|
156
|
-
backgroundColor: 'transparent',
|
|
157
|
-
width: 'fit-content',
|
|
158
|
-
},
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Create label styles
|
|
164
|
-
*/
|
|
165
|
-
function createLabelStyles(theme: Theme) {
|
|
166
|
-
return () => ({
|
|
167
|
-
fontSize: 14,
|
|
168
|
-
color: theme.colors.text.primary,
|
|
169
|
-
variants: {
|
|
170
|
-
disabled: {
|
|
171
|
-
true: {
|
|
172
|
-
opacity: 0.5,
|
|
173
|
-
},
|
|
174
|
-
false: {
|
|
175
|
-
opacity: 1,
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
position: {
|
|
179
|
-
left: {
|
|
180
|
-
marginRight: 8,
|
|
181
|
-
},
|
|
182
|
-
right: {
|
|
183
|
-
marginLeft: 8,
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
} as const,
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
191
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
192
|
-
export const switchStyles = StyleSheet.create((theme: Theme) => {
|
|
193
|
-
// Apply extensions to main visual elements
|
|
194
|
-
|
|
195
|
-
return applyExtensions('Switch', theme, {container: createContainerStyles(theme),
|
|
196
|
-
switchTrack: createSwitchTrackStyles(theme),
|
|
197
|
-
switchThumb: createSwitchThumbStyles(theme),
|
|
198
|
-
// Additional styles (merged from return)
|
|
199
|
-
// Minor utility styles (not extended)
|
|
200
|
-
switchContainer: createSwitchContainerStyles()(),
|
|
201
|
-
thumbIcon: createThumbIconStyles(theme),
|
|
202
|
-
label: createLabelStyles(theme)()});
|
|
203
|
-
});
|