@idealyst/components 1.1.6 → 1.1.8
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 +8 -3
- package/src/Accordion/Accordion.native.tsx +22 -14
- package/src/Accordion/Accordion.styles.old.tsx +298 -0
- package/src/Accordion/Accordion.styles.tsx +139 -248
- package/src/Accordion/Accordion.web.tsx +12 -7
- package/src/ActivityIndicator/ActivityIndicator.native.tsx +3 -2
- package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
- package/src/ActivityIndicator/ActivityIndicator.styles.tsx +43 -62
- package/src/ActivityIndicator/ActivityIndicator.web.tsx +2 -2
- package/src/Alert/Alert.native.tsx +26 -15
- package/src/Alert/Alert.styles.old.tsx +209 -0
- package/src/Alert/Alert.styles.tsx +108 -281
- package/src/Alert/Alert.web.tsx +6 -10
- package/src/Avatar/Avatar.native.tsx +5 -2
- package/src/Avatar/Avatar.styles.old.tsx +99 -0
- package/src/Avatar/Avatar.styles.tsx +47 -62
- package/src/Avatar/Avatar.web.tsx +2 -2
- package/src/Badge/Badge.native.tsx +2 -2
- package/src/Badge/Badge.styles.old.tsx +157 -0
- package/src/Badge/Badge.styles.tsx +69 -108
- package/src/Badge/Badge.web.tsx +6 -6
- package/src/Breadcrumb/Breadcrumb.native.tsx +12 -5
- package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
- package/src/Breadcrumb/Breadcrumb.styles.tsx +93 -209
- package/src/Breadcrumb/Breadcrumb.web.tsx +39 -27
- package/src/Button/Button.native.tsx +39 -14
- package/src/Button/Button.styles.tsx +99 -253
- package/src/Button/Button.web.tsx +10 -8
- package/src/Card/Card.native.tsx +8 -4
- package/src/Card/Card.styles.old.tsx +160 -0
- package/src/Card/Card.styles.tsx +107 -142
- package/src/Card/Card.web.tsx +6 -4
- package/src/Checkbox/Checkbox.native.tsx +14 -6
- package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
- package/src/Checkbox/Checkbox.styles.tsx +109 -197
- package/src/Checkbox/Checkbox.web.tsx +7 -7
- package/src/Chip/Chip.native.tsx +5 -5
- package/src/Chip/Chip.styles.old.tsx +184 -0
- package/src/Chip/Chip.styles.tsx +34 -22
- package/src/Chip/Chip.web.tsx +5 -5
- package/src/Dialog/Dialog.native.tsx +16 -7
- package/src/Dialog/Dialog.styles.old.tsx +202 -0
- package/src/Dialog/Dialog.styles.tsx +108 -132
- package/src/Dialog/Dialog.web.tsx +4 -4
- package/src/Divider/Divider.native.tsx +29 -42
- package/src/Divider/Divider.styles.old.tsx +172 -0
- package/src/Divider/Divider.styles.tsx +116 -242
- package/src/Divider/Divider.web.tsx +17 -14
- package/src/Icon/Icon.native.tsx +12 -4
- package/src/Icon/Icon.styles.old.tsx +81 -0
- package/src/Icon/Icon.styles.tsx +52 -60
- package/src/Icon/Icon.web.tsx +43 -7
- package/src/Icon/IconSvg/IconSvg.web.tsx +2 -0
- package/src/Image/Image.styles.old.tsx +69 -0
- package/src/Image/Image.styles.tsx +45 -43
- package/src/Input/Input.native.tsx +140 -56
- package/src/Input/Input.styles.old.tsx +289 -0
- package/src/Input/Input.styles.tsx +177 -228
- package/src/Input/Input.web.tsx +5 -8
- package/src/Link/Link.native.tsx +4 -1
- package/src/List/List.native.tsx +5 -2
- package/src/List/List.styles.old.tsx +242 -0
- package/src/List/List.styles.tsx +178 -240
- package/src/List/ListItem.native.tsx +16 -8
- package/src/List/ListItem.web.tsx +26 -15
- package/src/Menu/Menu.native.tsx +1 -1
- package/src/Menu/Menu.styles.old.tsx +197 -0
- package/src/Menu/Menu.styles.tsx +90 -156
- package/src/Menu/Menu.web.tsx +2 -2
- package/src/Menu/MenuItem.native.tsx +9 -5
- package/src/Menu/MenuItem.styles.old.tsx +114 -0
- package/src/Menu/MenuItem.styles.tsx +71 -104
- package/src/Menu/MenuItem.web.tsx +23 -5
- package/src/Popover/Popover.native.tsx +10 -4
- package/src/Popover/Popover.styles.old.tsx +135 -0
- package/src/Popover/Popover.styles.tsx +46 -96
- package/src/Popover/Popover.web.tsx +1 -1
- package/src/Pressable/Pressable.native.tsx +3 -1
- package/src/Pressable/Pressable.styles.old.tsx +27 -0
- package/src/Pressable/Pressable.styles.tsx +35 -20
- package/src/Pressable/Pressable.web.tsx +1 -1
- package/src/Progress/Progress.native.tsx +15 -6
- package/src/Progress/Progress.styles.old.tsx +200 -0
- package/src/Progress/Progress.styles.tsx +69 -118
- package/src/Progress/Progress.web.tsx +10 -9
- package/src/RadioButton/RadioButton.native.tsx +10 -4
- package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
- package/src/RadioButton/RadioButton.styles.tsx +81 -145
- package/src/RadioButton/RadioButton.web.tsx +4 -4
- package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
- package/src/SVGImage/SVGImage.styles.tsx +35 -66
- package/src/Screen/Screen.native.tsx +30 -27
- package/src/Screen/Screen.styles.old.tsx +87 -0
- package/src/Screen/Screen.styles.tsx +120 -71
- package/src/Screen/Screen.web.tsx +2 -2
- package/src/Select/Select.native.tsx +44 -29
- package/src/Select/Select.styles.old.tsx +353 -0
- package/src/Select/Select.styles.tsx +244 -293
- package/src/Select/Select.web.tsx +5 -5
- package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
- package/src/Skeleton/Skeleton.styles.tsx +31 -43
- package/src/Slider/Slider.native.tsx +9 -5
- package/src/Slider/Slider.styles.old.tsx +259 -0
- package/src/Slider/Slider.styles.tsx +157 -227
- package/src/Slider/Slider.web.tsx +5 -5
- package/src/Switch/Switch.native.tsx +11 -5
- package/src/Switch/Switch.styles.old.tsx +203 -0
- package/src/Switch/Switch.styles.tsx +103 -149
- package/src/Switch/Switch.web.tsx +8 -8
- package/src/TabBar/TabBar.native.tsx +24 -31
- package/src/TabBar/TabBar.styles.old.tsx +343 -0
- package/src/TabBar/TabBar.styles.tsx +204 -494
- package/src/TabBar/TabBar.web.tsx +21 -33
- package/src/Table/Table.native.tsx +18 -9
- package/src/Table/Table.styles.old.tsx +311 -0
- package/src/Table/Table.styles.tsx +151 -278
- package/src/Table/Table.web.tsx +1 -1
- package/src/Text/Text.native.tsx +1 -4
- package/src/Text/Text.style.demo.tsx +16 -0
- package/src/Text/Text.styles.old.tsx +219 -0
- package/src/Text/Text.styles.tsx +94 -78
- package/src/Text/Text.web.tsx +2 -2
- package/src/Text/index.ts +1 -0
- package/src/TextArea/TextArea.styles.old.tsx +213 -0
- package/src/TextArea/TextArea.styles.tsx +101 -157
- package/src/Tooltip/Tooltip.native.tsx +2 -2
- package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
- package/src/Tooltip/Tooltip.styles.tsx +38 -53
- package/src/Tooltip/Tooltip.web.tsx +2 -2
- package/src/Video/Video.styles.old.tsx +51 -0
- package/src/Video/Video.styles.tsx +32 -28
- package/src/View/View.native.tsx +12 -12
- package/src/View/View.styles.old.tsx +125 -0
- package/src/View/View.styles.tsx +84 -103
- package/src/View/View.web.tsx +14 -2
- package/src/examples/CardExamples.tsx +0 -6
- package/src/extensions/applyExtension.ts +210 -0
- package/src/extensions/extendComponent.ts +438 -0
- package/src/extensions/index.ts +102 -0
- package/src/extensions/types.ts +497 -0
- package/src/globals.ts +16 -0
- package/src/index.native.ts +4 -0
- package/src/index.ts +28 -0
- package/src/utils/deepMerge.ts +54 -2
|
@@ -1,239 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Divider styles using defineStyle with dynamic functions.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Intent } from '@idealyst/theme';
|
|
7
|
+
|
|
8
|
+
// Required: Unistyles must see StyleSheet usage in original source to process this file
|
|
9
|
+
void StyleSheet;
|
|
10
|
+
|
|
11
|
+
// Wrap theme for $iterator support
|
|
12
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
3
13
|
|
|
4
14
|
type DividerOrientation = 'horizontal' | 'vertical';
|
|
5
15
|
type DividerThickness = 'thin' | 'md' | 'thick';
|
|
6
16
|
type DividerType = 'solid' | 'dashed' | 'dotted';
|
|
7
17
|
type DividerIntent = Intent | 'secondary' | 'neutral' | 'info';
|
|
8
|
-
type DividerLength = 'full' | 'auto';
|
|
9
18
|
type DividerSpacing = 'none' | 'sm' | 'md' | 'lg';
|
|
19
|
+
type DividerLength = 'full' | 'auto';
|
|
10
20
|
|
|
11
|
-
type
|
|
12
|
-
orientation
|
|
13
|
-
thickness
|
|
14
|
-
type
|
|
15
|
-
intent
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
variants.push(
|
|
31
|
-
{ orientation: 'horizontal', thickness: 'thin', styles: { height: 1 } },
|
|
32
|
-
{ orientation: 'horizontal', thickness: 'md', styles: { height: 2 } },
|
|
33
|
-
{ orientation: 'horizontal', thickness: 'thick', styles: { height: 4 } }
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
variants.push(
|
|
37
|
-
{ orientation: 'vertical', thickness: 'thin', styles: { width: 1 } },
|
|
38
|
-
{ orientation: 'vertical', thickness: 'md', styles: { width: 2 } },
|
|
39
|
-
{ orientation: 'vertical', thickness: 'thick', styles: { width: 4 } }
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
variants.push(
|
|
43
|
-
{ orientation: 'horizontal', spacing: 'sm', styles: { marginVertical: 8 } },
|
|
44
|
-
{ orientation: 'horizontal', spacing: 'md', styles: { marginVertical: 16 } },
|
|
45
|
-
{ orientation: 'horizontal', spacing: 'lg', styles: { marginVertical: 24 } }
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
variants.push(
|
|
49
|
-
{ orientation: 'vertical', spacing: 'sm', styles: { marginHorizontal: 8 } },
|
|
50
|
-
{ orientation: 'vertical', spacing: 'md', styles: { marginHorizontal: 16 } },
|
|
51
|
-
{ orientation: 'vertical', spacing: 'lg', styles: { marginHorizontal: 24 } }
|
|
52
|
-
);
|
|
53
|
-
|
|
54
|
-
const borderColor = theme.colors.border.secondary;
|
|
55
|
-
variants.push(
|
|
56
|
-
{
|
|
57
|
-
type: 'dashed',
|
|
58
|
-
orientation: 'horizontal',
|
|
59
|
-
styles: {
|
|
60
|
-
_web: {
|
|
61
|
-
borderTop: `1px dashed ${borderColor}`,
|
|
62
|
-
borderLeft: 'none',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
type: 'dashed',
|
|
68
|
-
orientation: 'vertical',
|
|
69
|
-
styles: {
|
|
70
|
-
_web: {
|
|
71
|
-
borderLeft: `1px dashed ${borderColor}`,
|
|
72
|
-
borderTop: 'none',
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
}
|
|
76
|
-
);
|
|
77
|
-
|
|
78
|
-
variants.push(
|
|
79
|
-
{
|
|
80
|
-
type: 'dotted',
|
|
81
|
-
orientation: 'horizontal',
|
|
82
|
-
styles: {
|
|
83
|
-
_web: {
|
|
84
|
-
borderTop: `1px dotted ${borderColor}`,
|
|
85
|
-
borderLeft: 'none',
|
|
86
|
-
},
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
{
|
|
90
|
-
type: 'dotted',
|
|
91
|
-
orientation: 'vertical',
|
|
92
|
-
styles: {
|
|
93
|
-
_web: {
|
|
94
|
-
borderLeft: `1px dotted ${borderColor}`,
|
|
95
|
-
borderTop: 'none',
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const intents: DividerIntent[] = ['primary', 'success', 'error', 'warning', 'info'];
|
|
102
|
-
for (const intent of intents) {
|
|
103
|
-
const color = getIntentColor(theme, intent);
|
|
104
|
-
|
|
105
|
-
variants.push({
|
|
106
|
-
type: 'dashed',
|
|
107
|
-
intent: intent,
|
|
108
|
-
orientation: 'horizontal',
|
|
109
|
-
styles: {
|
|
110
|
-
borderTopColor: color,
|
|
111
|
-
_web: { borderTop: `1px dashed ${color}` },
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
variants.push({
|
|
116
|
-
type: 'dashed',
|
|
117
|
-
intent: intent,
|
|
118
|
-
orientation: 'vertical',
|
|
119
|
-
styles: {
|
|
120
|
-
borderLeftColor: color,
|
|
121
|
-
_web: { borderLeft: `1px dashed ${color}` },
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
variants.push({
|
|
126
|
-
type: 'dotted',
|
|
127
|
-
intent: intent,
|
|
128
|
-
orientation: 'horizontal',
|
|
129
|
-
styles: {
|
|
130
|
-
borderTopColor: color,
|
|
131
|
-
_web: { borderTop: `1px dotted ${color}` },
|
|
132
|
-
},
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
variants.push({
|
|
136
|
-
type: 'dotted',
|
|
137
|
-
intent: intent,
|
|
138
|
-
orientation: 'vertical',
|
|
139
|
-
styles: {
|
|
140
|
-
borderLeftColor: color,
|
|
141
|
-
_web: { borderLeft: `1px dotted ${color}` },
|
|
142
|
-
},
|
|
143
|
-
});
|
|
21
|
+
export type DividerDynamicProps = {
|
|
22
|
+
orientation?: DividerOrientation;
|
|
23
|
+
thickness?: DividerThickness;
|
|
24
|
+
type?: DividerType;
|
|
25
|
+
intent?: DividerIntent;
|
|
26
|
+
spacing?: DividerSpacing;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type LineDynamicProps = {
|
|
30
|
+
orientation?: DividerOrientation;
|
|
31
|
+
thickness?: DividerThickness;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function getThicknessValue(thickness: DividerThickness): number {
|
|
35
|
+
switch (thickness) {
|
|
36
|
+
case 'thin': return 1;
|
|
37
|
+
case 'md': return 2;
|
|
38
|
+
case 'thick': return 4;
|
|
39
|
+
default: return 1;
|
|
144
40
|
}
|
|
145
|
-
|
|
146
|
-
return variants;
|
|
147
41
|
}
|
|
148
42
|
|
|
149
|
-
function
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
] as const;
|
|
43
|
+
function getSpacingValue(spacing: DividerSpacing): number {
|
|
44
|
+
switch (spacing) {
|
|
45
|
+
case 'none': return 0;
|
|
46
|
+
case 'sm': return 8;
|
|
47
|
+
case 'md': return 16;
|
|
48
|
+
case 'lg': return 24;
|
|
49
|
+
default: return 0;
|
|
50
|
+
}
|
|
158
51
|
}
|
|
159
52
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
divider: {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Divider styles with dynamic functions for orientation/thickness/intent combinations.
|
|
55
|
+
*/
|
|
56
|
+
export const dividerStyles = defineStyle('Divider', (theme: Theme) => ({
|
|
57
|
+
divider: ({
|
|
58
|
+
orientation = 'horizontal',
|
|
59
|
+
thickness = 'thin',
|
|
60
|
+
type = 'solid',
|
|
61
|
+
intent = 'neutral',
|
|
62
|
+
spacing = 'md'
|
|
63
|
+
}: DividerDynamicProps) => {
|
|
64
|
+
const thicknessValue = getThicknessValue(thickness);
|
|
65
|
+
const spacingValue = getSpacingValue(spacing);
|
|
66
|
+
const isHorizontal = orientation === 'horizontal';
|
|
67
|
+
const isDashedOrDotted = type === 'dashed' || type === 'dotted';
|
|
68
|
+
|
|
69
|
+
// Get color based on intent - inline for Unistyles to trace
|
|
70
|
+
const color = intent === 'secondary'
|
|
71
|
+
? theme.colors.border.primary
|
|
72
|
+
: intent === 'neutral'
|
|
73
|
+
? theme.colors.border.secondary
|
|
74
|
+
: intent === 'info'
|
|
75
|
+
? theme.intents.primary.primary
|
|
76
|
+
: theme.intents[intent as Intent].primary;
|
|
77
|
+
|
|
78
|
+
const dimensionStyles = isHorizontal
|
|
79
|
+
? { width: '100%', height: thicknessValue, flexDirection: 'row' as const }
|
|
80
|
+
: { width: thicknessValue, height: '100%', flexDirection: 'column' as const };
|
|
81
|
+
|
|
82
|
+
const spacingStyles = isHorizontal
|
|
83
|
+
? { marginVertical: spacingValue }
|
|
84
|
+
: { marginHorizontal: spacingValue };
|
|
85
|
+
|
|
86
|
+
const webBorderStyles = isDashedOrDotted ? {
|
|
87
|
+
border: 'none',
|
|
88
|
+
backgroundColor: 'transparent',
|
|
89
|
+
...(isHorizontal
|
|
90
|
+
? { borderTop: `${thicknessValue}px ${type} ${color}` }
|
|
91
|
+
: { borderLeft: `${thicknessValue}px ${type} ${color}` }
|
|
92
|
+
),
|
|
93
|
+
} : {};
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
backgroundColor: isDashedOrDotted ? 'transparent' : color,
|
|
97
|
+
...dimensionStyles,
|
|
98
|
+
...spacingStyles,
|
|
99
|
+
variants: {
|
|
100
|
+
length: {
|
|
101
|
+
full: {},
|
|
102
|
+
auto: {},
|
|
172
103
|
},
|
|
173
|
-
vertical: {
|
|
174
|
-
width: 1,
|
|
175
|
-
height: '100%',
|
|
176
|
-
flexDirection: 'column',
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
thickness: {
|
|
180
|
-
thin: {},
|
|
181
|
-
md: {},
|
|
182
|
-
thick: {},
|
|
183
|
-
},
|
|
184
|
-
type: {
|
|
185
|
-
solid: {},
|
|
186
|
-
dashed: {
|
|
187
|
-
backgroundColor: 'transparent',
|
|
188
|
-
_web: {
|
|
189
|
-
border: 'none',
|
|
190
|
-
backgroundColor: 'transparent',
|
|
191
|
-
},
|
|
192
|
-
},
|
|
193
|
-
dotted: {
|
|
194
|
-
backgroundColor: 'transparent',
|
|
195
|
-
_web: {
|
|
196
|
-
border: 'none',
|
|
197
|
-
backgroundColor: 'transparent',
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
},
|
|
201
|
-
intent: {
|
|
202
|
-
primary: { backgroundColor: theme.intents.primary.primary },
|
|
203
|
-
secondary: { backgroundColor: theme.colors.border.primary },
|
|
204
|
-
neutral: { backgroundColor: theme.colors.border.secondary },
|
|
205
|
-
success: { backgroundColor: theme.intents.success.primary },
|
|
206
|
-
error: { backgroundColor: theme.intents.error.primary },
|
|
207
|
-
warning: { backgroundColor: theme.intents.warning.primary },
|
|
208
|
-
info: { backgroundColor: theme.intents.primary.primary },
|
|
209
|
-
},
|
|
210
|
-
length: {
|
|
211
|
-
full: {},
|
|
212
|
-
auto: {},
|
|
213
|
-
},
|
|
214
|
-
spacing: {
|
|
215
|
-
none: { margin: 0 },
|
|
216
|
-
sm: {},
|
|
217
|
-
md: {},
|
|
218
|
-
lg: {},
|
|
219
104
|
},
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
}
|
|
223
|
-
|
|
105
|
+
_web: webBorderStyles,
|
|
106
|
+
} as const;
|
|
107
|
+
},
|
|
108
|
+
|
|
109
|
+
container: (_props: { orientation?: DividerOrientation; spacing?: DividerSpacing }) => ({
|
|
224
110
|
alignItems: 'center',
|
|
225
111
|
justifyContent: 'center',
|
|
226
112
|
display: 'flex',
|
|
227
113
|
variants: {
|
|
228
114
|
orientation: {
|
|
229
|
-
horizontal: {
|
|
230
|
-
|
|
231
|
-
width: '100%',
|
|
232
|
-
},
|
|
233
|
-
vertical: {
|
|
234
|
-
flexDirection: 'column',
|
|
235
|
-
height: '100%',
|
|
236
|
-
},
|
|
115
|
+
horizontal: { flexDirection: 'row', width: '100%' },
|
|
116
|
+
vertical: { flexDirection: 'column', height: '100%' },
|
|
237
117
|
},
|
|
238
118
|
spacing: {
|
|
239
119
|
none: { gap: 0 },
|
|
@@ -244,37 +124,31 @@ export const dividerStyles = StyleSheet.create((theme: Theme) => {
|
|
|
244
124
|
xl: { gap: 32 },
|
|
245
125
|
},
|
|
246
126
|
},
|
|
247
|
-
},
|
|
248
|
-
|
|
127
|
+
}),
|
|
128
|
+
|
|
129
|
+
content: (_props: { orientation?: DividerOrientation }) => ({
|
|
249
130
|
backgroundColor: theme.colors.surface.primary,
|
|
250
131
|
color: theme.colors.text.secondary,
|
|
251
132
|
fontSize: 14,
|
|
252
133
|
variants: {
|
|
253
134
|
orientation: {
|
|
254
|
-
horizontal: {
|
|
255
|
-
|
|
256
|
-
},
|
|
257
|
-
vertical: {
|
|
258
|
-
paddingVertical: 8,
|
|
259
|
-
},
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
line: {
|
|
264
|
-
backgroundColor: theme.colors.border.secondary,
|
|
265
|
-
flex: 1,
|
|
266
|
-
variants: {
|
|
267
|
-
orientation: {
|
|
268
|
-
horizontal: { height: 1 },
|
|
269
|
-
vertical: { width: 1 },
|
|
270
|
-
},
|
|
271
|
-
thickness: {
|
|
272
|
-
thin: {},
|
|
273
|
-
md: {},
|
|
274
|
-
thick: {},
|
|
135
|
+
horizontal: { paddingHorizontal: 8 },
|
|
136
|
+
vertical: { paddingVertical: 8 },
|
|
275
137
|
},
|
|
276
138
|
},
|
|
277
|
-
|
|
139
|
+
}),
|
|
140
|
+
|
|
141
|
+
line: ({ orientation = 'horizontal', thickness = 'thin' }: LineDynamicProps) => {
|
|
142
|
+
const thicknessValue = getThicknessValue(thickness);
|
|
143
|
+
const isHorizontal = orientation === 'horizontal';
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
backgroundColor: theme.colors.border.secondary,
|
|
147
|
+
flex: 1,
|
|
148
|
+
...(isHorizontal
|
|
149
|
+
? { height: thicknessValue }
|
|
150
|
+
: { width: thicknessValue }
|
|
151
|
+
),
|
|
152
|
+
} as const;
|
|
278
153
|
},
|
|
279
|
-
|
|
280
|
-
});
|
|
154
|
+
}));
|
|
@@ -17,30 +17,33 @@ const Divider = forwardRef<HTMLDivElement, DividerProps>(({
|
|
|
17
17
|
accessibilityLabel,
|
|
18
18
|
id,
|
|
19
19
|
}, ref) => {
|
|
20
|
-
// Apply variants for
|
|
20
|
+
// Apply variants for container, content (orientation, spacing)
|
|
21
21
|
dividerStyles.useVariants({
|
|
22
|
+
orientation,
|
|
23
|
+
spacing,
|
|
24
|
+
length: typeof length === 'number' ? 'auto' : length,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Get dynamic divider style
|
|
28
|
+
const dividerStyle = (dividerStyles.divider as any)({
|
|
22
29
|
orientation,
|
|
23
30
|
thickness,
|
|
24
31
|
type,
|
|
25
32
|
intent,
|
|
26
|
-
length: typeof length === 'number' ? 'auto' : length,
|
|
27
33
|
spacing,
|
|
28
34
|
});
|
|
29
35
|
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
36
|
+
// Get dynamic line style
|
|
37
|
+
const lineStyle = (dividerStyles.line as any)({
|
|
38
|
+
orientation,
|
|
39
|
+
thickness,
|
|
40
|
+
});
|
|
35
41
|
|
|
36
42
|
// Generate web props
|
|
37
|
-
const dividerProps = getWebProps([
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
]);
|
|
41
|
-
const containerProps = getWebProps(containerStyleArray);
|
|
42
|
-
const contentProps = getWebProps(contentStyleArray);
|
|
43
|
-
const lineProps = getWebProps(lineStyleArray);
|
|
43
|
+
const dividerProps = getWebProps([dividerStyle, style as any]);
|
|
44
|
+
const containerProps = getWebProps([dividerStyles.container]);
|
|
45
|
+
const contentProps = getWebProps([dividerStyles.content]);
|
|
46
|
+
const lineProps = getWebProps([lineStyle]);
|
|
44
47
|
|
|
45
48
|
const mergedDividerRef = useMergeRefs(ref, dividerProps.ref);
|
|
46
49
|
const mergedContainerRef = useMergeRefs(ref, containerProps.ref);
|
package/src/Icon/Icon.native.tsx
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { forwardRef } from 'react';
|
|
1
|
+
import { forwardRef, useMemo } from 'react';
|
|
2
2
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
3
3
|
import { IconProps } from './types';
|
|
4
4
|
import { iconStyles } from './Icon.styles';
|
|
5
|
+
import { useUnistyles } from 'react-native-unistyles';
|
|
5
6
|
|
|
6
7
|
const Icon = forwardRef<any, IconProps>(({
|
|
7
8
|
name,
|
|
@@ -13,18 +14,25 @@ const Icon = forwardRef<any, IconProps>(({
|
|
|
13
14
|
accessibilityLabel,
|
|
14
15
|
id,
|
|
15
16
|
}: IconProps, ref) => {
|
|
17
|
+
const { theme } = useUnistyles();
|
|
16
18
|
|
|
19
|
+
// Call dynamic style with variants - includes theme-reactive color
|
|
20
|
+
const iconStyle = (iconStyles.icon as any)({ color, intent, size });
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
const iconSize = useMemo(() => {
|
|
23
|
+
return iconStyle.width;
|
|
24
|
+
}, [iconStyle]);
|
|
20
25
|
|
|
21
|
-
//
|
|
26
|
+
// Extract color from iconStyle for explicit color prop (RN vector icons need this)
|
|
27
|
+
const iconColor = iconStyle.color;
|
|
22
28
|
|
|
23
29
|
return (
|
|
24
30
|
<MaterialCommunityIcons
|
|
25
31
|
ref={ref}
|
|
26
32
|
nativeID={id}
|
|
33
|
+
size={iconSize}
|
|
27
34
|
name={name}
|
|
35
|
+
color={iconColor}
|
|
28
36
|
style={[iconStyle, style]}
|
|
29
37
|
testID={testID}
|
|
30
38
|
accessibilityLabel={accessibilityLabel}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import { Theme, StylesheetStyles, Intent, Color, getColorFromString } from '@idealyst/theme';
|
|
3
|
+
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import { IconSizeVariant } from './types';
|
|
5
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
6
|
+
|
|
7
|
+
type IconVariants = {
|
|
8
|
+
size: IconSizeVariant;
|
|
9
|
+
intent?: Intent;
|
|
10
|
+
color?: Color;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type ExpandedIconStyles = StylesheetStyles<keyof IconVariants>;
|
|
14
|
+
|
|
15
|
+
export type IconStylesheet = {
|
|
16
|
+
icon: ExpandedIconStyles;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create color variants for icon
|
|
21
|
+
*/
|
|
22
|
+
function getIconColor(theme: Theme, color?: Color, intent?: Intent): string {
|
|
23
|
+
if (intent) {
|
|
24
|
+
return theme.intents[intent]?.primary
|
|
25
|
+
} else if (color) {
|
|
26
|
+
return getColorFromString(theme, color);
|
|
27
|
+
}
|
|
28
|
+
return theme.colors.text.primary;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function buildIconSize(theme: Theme, size?: IconSizeVariant) {
|
|
32
|
+
// Handle direct numeric sizes
|
|
33
|
+
if (typeof size === 'number') {
|
|
34
|
+
return {
|
|
35
|
+
width: size,
|
|
36
|
+
height: size,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Default to 'md' if size is undefined
|
|
41
|
+
const sizeKey = size || 'md';
|
|
42
|
+
const iconSize = theme.sizes.icon[sizeKey];
|
|
43
|
+
|
|
44
|
+
if (typeof iconSize === 'number') {
|
|
45
|
+
return {
|
|
46
|
+
width: iconSize,
|
|
47
|
+
height: iconSize,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return buildSizeVariants(theme, 'icon', (size) => ({
|
|
52
|
+
width: size.width,
|
|
53
|
+
height: size.height,
|
|
54
|
+
}))[sizeKey];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function createIconStyles(theme: Theme) {
|
|
58
|
+
return ({ color, intent, size }: Partial<IconVariants>) => {
|
|
59
|
+
const iconSize = buildIconSize(theme, size);
|
|
60
|
+
return {
|
|
61
|
+
width: iconSize.width,
|
|
62
|
+
height: iconSize.height,
|
|
63
|
+
color: getIconColor(theme, color, intent),
|
|
64
|
+
_web: {
|
|
65
|
+
display: 'inline-block',
|
|
66
|
+
verticalAlign: 'middle',
|
|
67
|
+
flexShrink: 0,
|
|
68
|
+
lineHeight: 0,
|
|
69
|
+
},
|
|
70
|
+
} as const;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
75
|
+
// transform on native cannot resolve function calls to extract variant structures.
|
|
76
|
+
export const iconStyles = StyleSheet.create((theme: Theme) => {
|
|
77
|
+
// Apply extensions to main visual elements
|
|
78
|
+
return applyExtensions('Icon', theme, {
|
|
79
|
+
icon: createIconStyles(theme),
|
|
80
|
+
});
|
|
81
|
+
});
|