@idealyst/components 1.1.6 → 1.1.7
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 +15 -9
- package/src/Accordion/Accordion.styles.tsx +193 -168
- package/src/Accordion/Accordion.web.tsx +12 -7
- package/src/ActivityIndicator/ActivityIndicator.native.tsx +3 -2
- package/src/ActivityIndicator/ActivityIndicator.styles.tsx +22 -11
- package/src/ActivityIndicator/ActivityIndicator.web.tsx +2 -2
- package/src/Alert/Alert.native.tsx +11 -10
- package/src/Alert/Alert.styles.tsx +162 -253
- package/src/Alert/Alert.web.tsx +6 -10
- package/src/Avatar/Avatar.native.tsx +5 -2
- package/src/Avatar/Avatar.styles.tsx +48 -18
- package/src/Avatar/Avatar.web.tsx +2 -2
- package/src/Badge/Badge.native.tsx +2 -2
- package/src/Badge/Badge.styles.tsx +37 -16
- package/src/Badge/Badge.web.tsx +6 -6
- package/src/Breadcrumb/Breadcrumb.native.tsx +12 -5
- package/src/Breadcrumb/Breadcrumb.styles.tsx +59 -58
- package/src/Breadcrumb/Breadcrumb.web.tsx +13 -6
- package/src/Button/Button.native.tsx +39 -14
- package/src/Button/Button.styles.tsx +106 -208
- package/src/Button/Button.web.tsx +10 -8
- package/src/Card/Card.native.tsx +14 -6
- package/src/Card/Card.styles.tsx +64 -62
- package/src/Card/Card.web.tsx +5 -4
- package/src/Checkbox/Checkbox.native.tsx +7 -3
- package/src/Checkbox/Checkbox.styles.tsx +49 -25
- package/src/Checkbox/Checkbox.web.tsx +3 -3
- package/src/Chip/Chip.native.tsx +5 -5
- package/src/Chip/Chip.styles.tsx +71 -21
- package/src/Chip/Chip.web.tsx +5 -5
- package/src/Dialog/Dialog.native.tsx +10 -4
- package/src/Dialog/Dialog.styles.tsx +130 -90
- package/src/Dialog/Dialog.web.tsx +4 -4
- package/src/Divider/Divider.native.tsx +29 -42
- package/src/Divider/Divider.styles.tsx +138 -242
- package/src/Divider/Divider.web.tsx +17 -14
- package/src/Icon/Icon.native.tsx +11 -3
- package/src/Icon/Icon.styles.tsx +10 -4
- package/src/Image/Image.styles.tsx +53 -37
- package/src/Input/Input.native.tsx +6 -7
- package/src/Input/Input.styles.tsx +194 -174
- package/src/Input/Input.web.tsx +5 -8
- package/src/Link/Link.native.tsx +4 -1
- package/src/List/List.styles.tsx +79 -105
- package/src/List/ListItem.native.tsx +5 -3
- package/src/List/ListItem.web.tsx +4 -3
- package/src/Menu/Menu.native.tsx +1 -1
- package/src/Menu/Menu.styles.tsx +53 -37
- package/src/Menu/Menu.web.tsx +2 -2
- package/src/Menu/MenuItem.native.tsx +5 -3
- package/src/Menu/MenuItem.styles.tsx +68 -69
- package/src/Menu/MenuItem.web.tsx +16 -3
- package/src/Popover/Popover.native.tsx +1 -1
- package/src/Popover/Popover.styles.tsx +40 -29
- package/src/Popover/Popover.web.tsx +1 -1
- package/src/Pressable/Pressable.native.tsx +3 -1
- package/src/Pressable/Pressable.styles.tsx +20 -13
- package/src/Pressable/Pressable.web.tsx +1 -1
- package/src/Progress/Progress.native.tsx +15 -6
- package/src/Progress/Progress.styles.tsx +125 -85
- package/src/Progress/Progress.web.tsx +10 -9
- package/src/RadioButton/RadioButton.native.tsx +8 -3
- package/src/RadioButton/RadioButton.styles.tsx +44 -37
- package/src/RadioButton/RadioButton.web.tsx +3 -3
- package/src/SVGImage/SVGImage.styles.tsx +28 -16
- package/src/Screen/Screen.native.tsx +23 -13
- package/src/Screen/Screen.styles.tsx +57 -46
- package/src/Screen/Screen.web.tsx +1 -1
- package/src/Select/Select.native.tsx +11 -5
- package/src/Select/Select.styles.tsx +72 -52
- package/src/Select/Select.web.tsx +5 -5
- package/src/Skeleton/Skeleton.styles.tsx +26 -14
- package/src/Slider/Slider.native.tsx +9 -5
- package/src/Slider/Slider.styles.tsx +59 -48
- package/src/Slider/Slider.web.tsx +5 -5
- package/src/Switch/Switch.native.tsx +6 -2
- package/src/Switch/Switch.styles.tsx +46 -19
- package/src/Switch/Switch.web.tsx +4 -4
- package/src/TabBar/TabBar.native.tsx +23 -31
- package/src/TabBar/TabBar.styles.tsx +215 -371
- package/src/TabBar/TabBar.web.tsx +21 -33
- package/src/Table/Table.native.tsx +1 -1
- package/src/Table/Table.styles.tsx +11 -4
- package/src/Table/Table.web.tsx +1 -1
- package/src/Text/Text.native.tsx +3 -4
- package/src/Text/Text.styles.tsx +7 -1
- package/src/Text/Text.web.tsx +1 -1
- package/src/TextArea/TextArea.styles.tsx +90 -58
- package/src/Tooltip/Tooltip.native.tsx +2 -2
- package/src/Tooltip/Tooltip.styles.tsx +21 -12
- package/src/Tooltip/Tooltip.web.tsx +2 -2
- package/src/Video/Video.styles.tsx +39 -23
- package/src/View/View.native.tsx +4 -2
- package/src/View/View.styles.tsx +33 -22
- package/src/View/View.web.tsx +13 -2
- package/src/extensions/applyExtension.ts +210 -0
- package/src/extensions/extendComponent.ts +377 -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
|
@@ -16,21 +16,30 @@ const Divider = forwardRef<View, DividerProps>(({
|
|
|
16
16
|
accessibilityLabel,
|
|
17
17
|
id,
|
|
18
18
|
}, ref) => {
|
|
19
|
-
// Apply variants for
|
|
19
|
+
// Apply variants for container, content (orientation, spacing)
|
|
20
20
|
dividerStyles.useVariants({
|
|
21
|
+
orientation,
|
|
22
|
+
spacing,
|
|
23
|
+
length: typeof length === 'number' ? 'auto' : length,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Get dynamic divider style
|
|
27
|
+
const dividerStyle = (dividerStyles.divider as any)({
|
|
21
28
|
orientation,
|
|
22
29
|
thickness,
|
|
23
|
-
type
|
|
30
|
+
type,
|
|
24
31
|
intent,
|
|
25
|
-
length: typeof length === 'number' ? 'auto' : length,
|
|
26
32
|
spacing,
|
|
27
33
|
});
|
|
28
34
|
|
|
29
|
-
// Get
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
35
|
+
// Get dynamic line style
|
|
36
|
+
const lineStyle = (dividerStyles.line as any)({
|
|
37
|
+
orientation,
|
|
38
|
+
thickness,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// Get thickness value for dashed/dotted border handling on native
|
|
42
|
+
const getThicknessValue = () => {
|
|
34
43
|
switch (thickness) {
|
|
35
44
|
case 'thin': return 1;
|
|
36
45
|
case 'md': return 2;
|
|
@@ -39,11 +48,11 @@ const Divider = forwardRef<View, DividerProps>(({
|
|
|
39
48
|
}
|
|
40
49
|
};
|
|
41
50
|
|
|
42
|
-
// For dashed/dotted variants, use border instead of background
|
|
43
|
-
const
|
|
51
|
+
// For dashed/dotted variants on native, we need to use border instead of background
|
|
52
|
+
const getNativeDashedStyle = () => {
|
|
44
53
|
if (type === 'dashed' || type === 'dotted') {
|
|
45
|
-
const actualThickness =
|
|
46
|
-
|
|
54
|
+
const actualThickness = getThicknessValue();
|
|
55
|
+
|
|
47
56
|
return {
|
|
48
57
|
backgroundColor: 'transparent',
|
|
49
58
|
borderStyle: type,
|
|
@@ -53,15 +62,11 @@ const Divider = forwardRef<View, DividerProps>(({
|
|
|
53
62
|
borderBottomWidth: 0,
|
|
54
63
|
borderLeftWidth: 0,
|
|
55
64
|
borderRightWidth: 0,
|
|
56
|
-
width: '100%',
|
|
57
|
-
height: actualThickness,
|
|
58
65
|
} : {
|
|
59
66
|
borderLeftWidth: actualThickness,
|
|
60
67
|
borderTopWidth: 0,
|
|
61
68
|
borderBottomWidth: 0,
|
|
62
69
|
borderRightWidth: 0,
|
|
63
|
-
height: '100%',
|
|
64
|
-
width: actualThickness,
|
|
65
70
|
}),
|
|
66
71
|
};
|
|
67
72
|
}
|
|
@@ -70,66 +75,48 @@ const Divider = forwardRef<View, DividerProps>(({
|
|
|
70
75
|
|
|
71
76
|
// If no children, render simple divider
|
|
72
77
|
if (!children) {
|
|
73
|
-
if (type === 'dashed' || type === 'dotted') {
|
|
74
|
-
return (
|
|
75
|
-
<View
|
|
76
|
-
ref={ref}
|
|
77
|
-
nativeID={id}
|
|
78
|
-
style={[
|
|
79
|
-
dividerStyle,
|
|
80
|
-
getDashedStyle(),
|
|
81
|
-
style,
|
|
82
|
-
]}
|
|
83
|
-
testID={testID}
|
|
84
|
-
accessibilityLabel={accessibilityLabel || "divider"}
|
|
85
|
-
/>
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
|
|
89
78
|
return (
|
|
90
79
|
<View
|
|
91
80
|
ref={ref}
|
|
92
81
|
nativeID={id}
|
|
93
|
-
style={[
|
|
82
|
+
style={[dividerStyle, getNativeDashedStyle(), style]}
|
|
94
83
|
testID={testID}
|
|
95
84
|
accessibilityLabel={accessibilityLabel || "divider"}
|
|
96
85
|
/>
|
|
97
86
|
);
|
|
98
87
|
}
|
|
99
88
|
|
|
100
|
-
// For lines with content, create
|
|
89
|
+
// For lines with content, create line segments
|
|
101
90
|
const renderLineSegment = () => {
|
|
102
91
|
if (type === 'dashed' || type === 'dotted') {
|
|
103
|
-
const actualThickness =
|
|
104
|
-
|
|
92
|
+
const actualThickness = getThicknessValue();
|
|
93
|
+
|
|
105
94
|
return (
|
|
106
95
|
<View
|
|
107
96
|
style={[
|
|
108
|
-
|
|
97
|
+
lineStyle,
|
|
109
98
|
{
|
|
110
99
|
backgroundColor: 'transparent',
|
|
111
100
|
borderStyle: type,
|
|
112
|
-
borderColor:
|
|
101
|
+
borderColor: lineStyle.backgroundColor,
|
|
113
102
|
...(orientation === 'horizontal' ? {
|
|
114
103
|
borderTopWidth: actualThickness,
|
|
115
104
|
borderBottomWidth: 0,
|
|
116
105
|
borderLeftWidth: 0,
|
|
117
106
|
borderRightWidth: 0,
|
|
118
|
-
height: actualThickness,
|
|
119
107
|
} : {
|
|
120
108
|
borderLeftWidth: actualThickness,
|
|
121
109
|
borderTopWidth: 0,
|
|
122
110
|
borderBottomWidth: 0,
|
|
123
111
|
borderRightWidth: 0,
|
|
124
|
-
width: actualThickness,
|
|
125
112
|
}),
|
|
126
113
|
},
|
|
127
114
|
]}
|
|
128
115
|
/>
|
|
129
116
|
);
|
|
130
117
|
}
|
|
131
|
-
|
|
132
|
-
return <View style={
|
|
118
|
+
|
|
119
|
+
return <View style={lineStyle} />;
|
|
133
120
|
};
|
|
134
121
|
|
|
135
122
|
return (
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, Intent
|
|
2
|
+
import { Theme, Intent } from '@idealyst/theme';
|
|
3
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
3
4
|
|
|
4
5
|
type DividerOrientation = 'horizontal' | 'vertical';
|
|
5
6
|
type DividerThickness = 'thin' | 'md' | 'thick';
|
|
@@ -8,14 +9,18 @@ type DividerIntent = Intent | 'secondary' | 'neutral' | 'info';
|
|
|
8
9
|
type DividerLength = 'full' | 'auto';
|
|
9
10
|
type DividerSpacing = 'none' | 'sm' | 'md' | 'lg';
|
|
10
11
|
|
|
11
|
-
type
|
|
12
|
-
orientation
|
|
13
|
-
thickness
|
|
14
|
-
type
|
|
15
|
-
intent
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
type DividerDynamicProps = {
|
|
13
|
+
orientation?: DividerOrientation;
|
|
14
|
+
thickness?: DividerThickness;
|
|
15
|
+
type?: DividerType;
|
|
16
|
+
intent?: DividerIntent;
|
|
17
|
+
spacing?: DividerSpacing;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
type LineDynamicProps = {
|
|
21
|
+
orientation?: DividerOrientation;
|
|
22
|
+
thickness?: DividerThickness;
|
|
23
|
+
};
|
|
19
24
|
|
|
20
25
|
function getIntentColor(theme: Theme, intent: DividerIntent): string {
|
|
21
26
|
if (intent === 'secondary') return theme.colors.border.primary;
|
|
@@ -24,257 +29,148 @@ function getIntentColor(theme: Theme, intent: DividerIntent): string {
|
|
|
24
29
|
return theme.intents[intent as Intent].primary;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
);
|
|
32
|
+
function getThicknessValue(thickness: DividerThickness): number {
|
|
33
|
+
switch (thickness) {
|
|
34
|
+
case 'thin': return 1;
|
|
35
|
+
case 'md': return 2;
|
|
36
|
+
case 'thick': return 4;
|
|
37
|
+
default: return 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
77
40
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
-
);
|
|
41
|
+
function getSpacingValue(spacing: DividerSpacing): number {
|
|
42
|
+
switch (spacing) {
|
|
43
|
+
case 'none': return 0;
|
|
44
|
+
case 'sm': return 8;
|
|
45
|
+
case 'md': return 16;
|
|
46
|
+
case 'lg': return 24;
|
|
47
|
+
default: return 0;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
100
50
|
|
|
101
|
-
|
|
102
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Create dynamic divider styles
|
|
53
|
+
*/
|
|
54
|
+
function createDividerStyles(theme: Theme) {
|
|
55
|
+
return ({
|
|
56
|
+
orientation = 'horizontal',
|
|
57
|
+
thickness = 'thin',
|
|
58
|
+
type = 'solid',
|
|
59
|
+
intent = 'neutral',
|
|
60
|
+
spacing = 'md'
|
|
61
|
+
}: DividerDynamicProps) => {
|
|
103
62
|
const color = getIntentColor(theme, intent);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
styles: {
|
|
140
|
-
borderLeftColor: color,
|
|
141
|
-
_web: { borderLeft: `1px dotted ${color}` },
|
|
63
|
+
const thicknessValue = getThicknessValue(thickness);
|
|
64
|
+
const spacingValue = getSpacingValue(spacing);
|
|
65
|
+
|
|
66
|
+
const isHorizontal = orientation === 'horizontal';
|
|
67
|
+
const isDashedOrDotted = type === 'dashed' || type === 'dotted';
|
|
68
|
+
|
|
69
|
+
// Base dimension styles based on orientation and thickness
|
|
70
|
+
const dimensionStyles = isHorizontal
|
|
71
|
+
? { width: '100%', height: thicknessValue, flexDirection: 'row' as const }
|
|
72
|
+
: { width: thicknessValue, height: '100%', flexDirection: 'column' as const };
|
|
73
|
+
|
|
74
|
+
// Spacing styles based on orientation
|
|
75
|
+
const spacingStyles = isHorizontal
|
|
76
|
+
? { marginVertical: spacingValue }
|
|
77
|
+
: { marginHorizontal: spacingValue };
|
|
78
|
+
|
|
79
|
+
// Web-specific border styles for dashed/dotted
|
|
80
|
+
const webBorderStyles = isDashedOrDotted ? {
|
|
81
|
+
border: 'none',
|
|
82
|
+
backgroundColor: 'transparent',
|
|
83
|
+
...(isHorizontal
|
|
84
|
+
? { borderTop: `${thicknessValue}px ${type} ${color}` }
|
|
85
|
+
: { borderLeft: `${thicknessValue}px ${type} ${color}` }
|
|
86
|
+
),
|
|
87
|
+
} : {};
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
backgroundColor: isDashedOrDotted ? 'transparent' : color,
|
|
91
|
+
...dimensionStyles,
|
|
92
|
+
...spacingStyles,
|
|
93
|
+
variants: {
|
|
94
|
+
length: {
|
|
95
|
+
full: {},
|
|
96
|
+
auto: {},
|
|
97
|
+
},
|
|
142
98
|
},
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return variants;
|
|
99
|
+
_web: webBorderStyles,
|
|
100
|
+
} as const;
|
|
101
|
+
};
|
|
147
102
|
}
|
|
148
103
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Create dynamic line styles (for dividers with content)
|
|
106
|
+
*/
|
|
107
|
+
function createLineStyles(theme: Theme) {
|
|
108
|
+
return ({ orientation = 'horizontal', thickness = 'thin' }: LineDynamicProps) => {
|
|
109
|
+
const thicknessValue = getThicknessValue(thickness);
|
|
110
|
+
const isHorizontal = orientation === 'horizontal';
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
backgroundColor: theme.colors.border.secondary,
|
|
114
|
+
flex: 1,
|
|
115
|
+
...(isHorizontal
|
|
116
|
+
? { height: thicknessValue }
|
|
117
|
+
: { width: thicknessValue }
|
|
118
|
+
),
|
|
119
|
+
} as const;
|
|
120
|
+
};
|
|
158
121
|
}
|
|
159
122
|
|
|
160
123
|
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
161
124
|
// transform on native cannot resolve function calls to extract variant structures.
|
|
162
125
|
export const dividerStyles = StyleSheet.create((theme: Theme) => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
thin: {},
|
|
181
|
-
md: {},
|
|
182
|
-
thick: {},
|
|
183
|
-
},
|
|
184
|
-
type: {
|
|
185
|
-
solid: {},
|
|
186
|
-
dashed: {
|
|
187
|
-
backgroundColor: 'transparent',
|
|
188
|
-
_web: {
|
|
189
|
-
border: 'none',
|
|
190
|
-
backgroundColor: 'transparent',
|
|
126
|
+
// Apply extensions to main visual elements
|
|
127
|
+
const extended = applyExtensions('Divider', theme, {
|
|
128
|
+
divider: createDividerStyles(theme),
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
...extended,
|
|
133
|
+
// Minor utility styles (not extended)
|
|
134
|
+
container: {
|
|
135
|
+
alignItems: 'center',
|
|
136
|
+
justifyContent: 'center',
|
|
137
|
+
display: 'flex',
|
|
138
|
+
variants: {
|
|
139
|
+
orientation: {
|
|
140
|
+
horizontal: {
|
|
141
|
+
flexDirection: 'row',
|
|
142
|
+
width: '100%',
|
|
191
143
|
},
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
_web: {
|
|
196
|
-
border: 'none',
|
|
197
|
-
backgroundColor: 'transparent',
|
|
144
|
+
vertical: {
|
|
145
|
+
flexDirection: 'column',
|
|
146
|
+
height: '100%',
|
|
198
147
|
},
|
|
199
148
|
},
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
},
|
|
220
|
-
},
|
|
221
|
-
compoundVariants: createDividerCompoundVariants(theme),
|
|
222
|
-
} as const,
|
|
223
|
-
container: {
|
|
224
|
-
alignItems: 'center',
|
|
225
|
-
justifyContent: 'center',
|
|
226
|
-
display: 'flex',
|
|
227
|
-
variants: {
|
|
228
|
-
orientation: {
|
|
229
|
-
horizontal: {
|
|
230
|
-
flexDirection: 'row',
|
|
231
|
-
width: '100%',
|
|
232
|
-
},
|
|
233
|
-
vertical: {
|
|
234
|
-
flexDirection: 'column',
|
|
235
|
-
height: '100%',
|
|
149
|
+
spacing: {
|
|
150
|
+
none: { gap: 0 },
|
|
151
|
+
xs: { gap: 4 },
|
|
152
|
+
sm: { gap: 8 },
|
|
153
|
+
md: { gap: 16 },
|
|
154
|
+
lg: { gap: 24 },
|
|
155
|
+
xl: { gap: 32 },
|
|
236
156
|
},
|
|
237
157
|
},
|
|
238
|
-
spacing: {
|
|
239
|
-
none: { gap: 0 },
|
|
240
|
-
xs: { gap: 4 },
|
|
241
|
-
sm: { gap: 8 },
|
|
242
|
-
md: { gap: 16 },
|
|
243
|
-
lg: { gap: 24 },
|
|
244
|
-
xl: { gap: 32 },
|
|
245
|
-
},
|
|
246
158
|
},
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
159
|
+
content: {
|
|
160
|
+
backgroundColor: theme.colors.surface.primary,
|
|
161
|
+
color: theme.colors.text.secondary,
|
|
162
|
+
fontSize: 14,
|
|
163
|
+
variants: {
|
|
164
|
+
orientation: {
|
|
165
|
+
horizontal: {
|
|
166
|
+
paddingHorizontal: 8,
|
|
167
|
+
},
|
|
168
|
+
vertical: {
|
|
169
|
+
paddingVertical: 8,
|
|
170
|
+
},
|
|
259
171
|
},
|
|
260
172
|
},
|
|
261
173
|
},
|
|
262
|
-
|
|
263
|
-
|
|
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: {},
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
compoundVariants: createLineCompoundVariants(),
|
|
278
|
-
},
|
|
279
|
-
};
|
|
174
|
+
line: createLineStyles(theme),
|
|
175
|
+
};
|
|
280
176
|
});
|
|
@@ -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
|
-
import { iconStyles } from './Icon.styles';
|
|
4
|
+
import { iconStyles, buildIconSize } from './Icon.styles';
|
|
5
|
+
import { useUnistyles } from 'react-native-unistyles';
|
|
5
6
|
|
|
6
7
|
const Icon = forwardRef<any, IconProps>(({
|
|
7
8
|
name,
|
|
@@ -16,7 +17,13 @@ const Icon = forwardRef<any, IconProps>(({
|
|
|
16
17
|
|
|
17
18
|
|
|
18
19
|
// Call dynamic style with variants
|
|
19
|
-
const iconStyle = iconStyles.icon({ color, intent, size });
|
|
20
|
+
const iconStyle = (iconStyles.icon as any)({ color, intent, size });
|
|
21
|
+
|
|
22
|
+
const { theme } = useUnistyles();
|
|
23
|
+
|
|
24
|
+
const iconSize = useMemo(() => {
|
|
25
|
+
return buildIconSize(theme, size).width;
|
|
26
|
+
}, [theme, size]);
|
|
20
27
|
|
|
21
28
|
// Get fontSize from styles for numeric size prop
|
|
22
29
|
|
|
@@ -24,6 +31,7 @@ const Icon = forwardRef<any, IconProps>(({
|
|
|
24
31
|
<MaterialCommunityIcons
|
|
25
32
|
ref={ref}
|
|
26
33
|
nativeID={id}
|
|
34
|
+
size={iconSize}
|
|
27
35
|
name={name}
|
|
28
36
|
style={[iconStyle, style]}
|
|
29
37
|
testID={testID}
|
package/src/Icon/Icon.styles.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { StyleSheet } from 'react-native-unistyles';
|
|
|
2
2
|
import { Theme, StylesheetStyles, Intent, Color, getColorFromString } from '@idealyst/theme';
|
|
3
3
|
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
4
|
import { IconSizeVariant } from './types';
|
|
5
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
5
6
|
|
|
6
7
|
type IconVariants = {
|
|
7
8
|
size: IconSizeVariant;
|
|
@@ -27,7 +28,7 @@ function getIconColor(theme: Theme, color?: Color, intent?: Intent): string {
|
|
|
27
28
|
return theme.colors.text.primary;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
function buildIconSize(theme: Theme, size?: IconSizeVariant) {
|
|
31
|
+
export function buildIconSize(theme: Theme, size?: IconSizeVariant) {
|
|
31
32
|
// Handle direct numeric sizes
|
|
32
33
|
if (typeof size === 'number') {
|
|
33
34
|
return {
|
|
@@ -73,7 +74,12 @@ function createIconStyles(theme: Theme) {
|
|
|
73
74
|
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
74
75
|
// transform on native cannot resolve function calls to extract variant structures.
|
|
75
76
|
export const iconStyles = StyleSheet.create((theme: Theme) => {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
// Apply extensions to main visual elements
|
|
78
|
+
const extended = applyExtensions('Icon', theme, {
|
|
79
|
+
icon: createIconStyles(theme),
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
...extended,
|
|
84
|
+
};
|
|
79
85
|
});
|