@idealyst/components 1.1.7 → 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 +3 -3
- package/src/Accordion/Accordion.native.tsx +8 -6
- package/src/Accordion/Accordion.styles.old.tsx +298 -0
- package/src/Accordion/Accordion.styles.tsx +102 -236
- package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
- package/src/ActivityIndicator/ActivityIndicator.styles.tsx +44 -74
- package/src/Alert/Alert.native.tsx +16 -6
- package/src/Alert/Alert.styles.old.tsx +209 -0
- package/src/Alert/Alert.styles.tsx +67 -149
- package/src/Avatar/Avatar.styles.old.tsx +99 -0
- package/src/Avatar/Avatar.styles.tsx +35 -80
- package/src/Badge/Badge.styles.old.tsx +157 -0
- package/src/Badge/Badge.styles.tsx +61 -121
- package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
- package/src/Breadcrumb/Breadcrumb.styles.tsx +83 -200
- package/src/Breadcrumb/Breadcrumb.web.tsx +28 -23
- package/src/Button/Button.styles.tsx +89 -141
- package/src/Card/Card.native.tsx +7 -11
- package/src/Card/Card.styles.old.tsx +160 -0
- package/src/Card/Card.styles.tsx +105 -142
- package/src/Card/Card.web.tsx +5 -4
- package/src/Checkbox/Checkbox.native.tsx +9 -5
- package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
- package/src/Checkbox/Checkbox.styles.tsx +104 -216
- package/src/Checkbox/Checkbox.web.tsx +6 -6
- package/src/Chip/Chip.styles.old.tsx +184 -0
- package/src/Chip/Chip.styles.tsx +34 -72
- package/src/Dialog/Dialog.native.tsx +7 -4
- package/src/Dialog/Dialog.styles.old.tsx +202 -0
- package/src/Dialog/Dialog.styles.tsx +69 -133
- package/src/Divider/Divider.styles.old.tsx +172 -0
- package/src/Divider/Divider.styles.tsx +62 -84
- package/src/Icon/Icon.native.tsx +8 -8
- package/src/Icon/Icon.styles.old.tsx +81 -0
- package/src/Icon/Icon.styles.tsx +52 -66
- 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 +46 -60
- package/src/Input/Input.native.tsx +138 -53
- package/src/Input/Input.styles.old.tsx +289 -0
- package/src/Input/Input.styles.tsx +127 -198
- package/src/List/List.native.tsx +5 -2
- package/src/List/List.styles.old.tsx +242 -0
- package/src/List/List.styles.tsx +179 -215
- package/src/List/ListItem.native.tsx +12 -6
- package/src/List/ListItem.web.tsx +23 -13
- package/src/Menu/Menu.styles.old.tsx +197 -0
- package/src/Menu/Menu.styles.tsx +68 -150
- package/src/Menu/MenuItem.native.tsx +5 -3
- package/src/Menu/MenuItem.styles.old.tsx +114 -0
- package/src/Menu/MenuItem.styles.tsx +57 -89
- package/src/Menu/MenuItem.web.tsx +8 -3
- package/src/Popover/Popover.native.tsx +10 -4
- package/src/Popover/Popover.styles.old.tsx +135 -0
- package/src/Popover/Popover.styles.tsx +51 -112
- package/src/Pressable/Pressable.styles.old.tsx +27 -0
- package/src/Pressable/Pressable.styles.tsx +35 -27
- package/src/Progress/Progress.styles.old.tsx +200 -0
- package/src/Progress/Progress.styles.tsx +75 -164
- package/src/RadioButton/RadioButton.native.tsx +4 -3
- package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
- package/src/RadioButton/RadioButton.styles.tsx +83 -154
- package/src/RadioButton/RadioButton.web.tsx +2 -2
- package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
- package/src/SVGImage/SVGImage.styles.tsx +35 -78
- package/src/Screen/Screen.native.tsx +18 -25
- package/src/Screen/Screen.styles.old.tsx +87 -0
- package/src/Screen/Screen.styles.tsx +105 -67
- package/src/Screen/Screen.web.tsx +1 -1
- package/src/Select/Select.native.tsx +42 -33
- package/src/Select/Select.styles.old.tsx +353 -0
- package/src/Select/Select.styles.tsx +223 -292
- package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
- package/src/Skeleton/Skeleton.styles.tsx +29 -53
- package/src/Slider/Slider.styles.old.tsx +259 -0
- package/src/Slider/Slider.styles.tsx +153 -234
- package/src/Switch/Switch.native.tsx +7 -5
- package/src/Switch/Switch.styles.old.tsx +203 -0
- package/src/Switch/Switch.styles.tsx +101 -174
- package/src/Switch/Switch.web.tsx +5 -5
- package/src/TabBar/TabBar.native.tsx +3 -2
- package/src/TabBar/TabBar.styles.old.tsx +343 -0
- package/src/TabBar/TabBar.styles.tsx +145 -279
- package/src/Table/Table.native.tsx +18 -9
- package/src/Table/Table.styles.old.tsx +311 -0
- package/src/Table/Table.styles.tsx +152 -286
- package/src/Text/Text.native.tsx +1 -3
- 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 -84
- 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 +93 -181
- package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
- package/src/Tooltip/Tooltip.styles.tsx +32 -56
- package/src/Video/Video.styles.old.tsx +51 -0
- package/src/Video/Video.styles.tsx +32 -44
- package/src/View/View.native.tsx +12 -14
- package/src/View/View.styles.old.tsx +125 -0
- package/src/View/View.styles.tsx +76 -106
- package/src/View/View.web.tsx +1 -0
- package/src/examples/CardExamples.tsx +0 -6
- package/src/extensions/extendComponent.ts +61 -0
|
@@ -1,103 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Avatar styles using defineStyle with $iterator expansion.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
5
|
-
|
|
6
|
-
type AvatarSize = Size;
|
|
7
|
-
type AvatarShape = 'circle' | 'square';
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Size } from '@idealyst/theme';
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
shape: AvatarShape;
|
|
12
|
-
}
|
|
8
|
+
// Required: Unistyles must see StyleSheet usage in original source to process this file
|
|
9
|
+
void StyleSheet;
|
|
13
10
|
|
|
14
|
-
|
|
11
|
+
// Wrap theme for $iterator support
|
|
12
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
avatar: ExpandedAvatarStyles;
|
|
18
|
-
image: ExpandedAvatarStyles;
|
|
19
|
-
fallback: ExpandedAvatarStyles;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function createAvatarSizeVariants(theme: Theme) {
|
|
23
|
-
return buildSizeVariants(theme, 'avatar', (size) => ({
|
|
24
|
-
width: size.width,
|
|
25
|
-
height: size.height,
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function createAvatarShapeVariants(theme: Theme) {
|
|
30
|
-
return {
|
|
31
|
-
circle: {
|
|
32
|
-
borderRadius: 9999,
|
|
33
|
-
},
|
|
34
|
-
square: {
|
|
35
|
-
borderRadius: 8,
|
|
36
|
-
},
|
|
37
|
-
} as const;
|
|
38
|
-
}
|
|
14
|
+
type AvatarShape = 'circle' | 'square';
|
|
39
15
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
16
|
+
export type AvatarDynamicProps = {
|
|
17
|
+
size?: Size;
|
|
18
|
+
shape?: AvatarShape;
|
|
19
|
+
};
|
|
45
20
|
|
|
46
21
|
/**
|
|
47
|
-
*
|
|
22
|
+
* Avatar styles with size and shape variants.
|
|
48
23
|
*/
|
|
49
|
-
|
|
50
|
-
|
|
24
|
+
export const avatarStyles = defineStyle('Avatar', (theme: Theme) => ({
|
|
25
|
+
avatar: (_props: AvatarDynamicProps) => ({
|
|
51
26
|
display: 'flex' as const,
|
|
52
27
|
alignItems: 'center' as const,
|
|
53
28
|
justifyContent: 'center' as const,
|
|
54
29
|
backgroundColor: theme.colors.surface.secondary,
|
|
55
30
|
overflow: 'hidden' as const,
|
|
56
31
|
variants: {
|
|
57
|
-
size
|
|
58
|
-
|
|
32
|
+
// $iterator expands for each avatar size
|
|
33
|
+
size: {
|
|
34
|
+
width: theme.sizes.$avatar.width,
|
|
35
|
+
height: theme.sizes.$avatar.height,
|
|
36
|
+
},
|
|
37
|
+
shape: {
|
|
38
|
+
circle: { borderRadius: 9999 },
|
|
39
|
+
square: { borderRadius: 8 },
|
|
40
|
+
},
|
|
59
41
|
},
|
|
60
|
-
})
|
|
61
|
-
}
|
|
42
|
+
}),
|
|
62
43
|
|
|
63
|
-
|
|
64
|
-
* Create image styles
|
|
65
|
-
*/
|
|
66
|
-
function createImageStyles() {
|
|
67
|
-
return () => ({
|
|
44
|
+
image: (_props: AvatarDynamicProps) => ({
|
|
68
45
|
width: '100%' as const,
|
|
69
46
|
height: '100%' as const,
|
|
70
|
-
})
|
|
71
|
-
}
|
|
47
|
+
}),
|
|
72
48
|
|
|
73
|
-
|
|
74
|
-
* Create fallback styles
|
|
75
|
-
*/
|
|
76
|
-
function createFallbackStyles(theme: Theme) {
|
|
77
|
-
return () => ({
|
|
49
|
+
fallback: (_props: AvatarDynamicProps) => ({
|
|
78
50
|
color: theme.colors.text.primary,
|
|
79
51
|
fontWeight: '600' as const,
|
|
80
52
|
variants: {
|
|
81
|
-
size:
|
|
53
|
+
size: {
|
|
54
|
+
fontSize: theme.sizes.$avatar.fontSize,
|
|
55
|
+
},
|
|
82
56
|
},
|
|
83
|
-
})
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
87
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
88
|
-
export const avatarStyles = StyleSheet.create((theme: Theme) => {
|
|
89
|
-
// Apply extensions to main visual elements
|
|
90
|
-
const extended = applyExtensions('Avatar', theme, {
|
|
91
|
-
avatar: createContainerStyles(theme),
|
|
92
|
-
fallback: createFallbackStyles(theme),
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
return {
|
|
96
|
-
...extended,
|
|
97
|
-
// Minor utility styles (not extended)
|
|
98
|
-
image: {
|
|
99
|
-
width: '100%',
|
|
100
|
-
height: '100%',
|
|
101
|
-
},
|
|
102
|
-
};
|
|
103
|
-
});
|
|
57
|
+
}),
|
|
58
|
+
}));
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import { Theme, StylesheetStyles, getColorFromString, Size, Color } from '@idealyst/theme';
|
|
3
|
+
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
5
|
+
|
|
6
|
+
type BadgeType = 'filled' | 'outlined' | 'dot';
|
|
7
|
+
|
|
8
|
+
type BadgeVariants = {
|
|
9
|
+
size: Size;
|
|
10
|
+
type: BadgeType;
|
|
11
|
+
color: Color;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type ExpandedBadgeStyles = StylesheetStyles<keyof BadgeVariants>;
|
|
15
|
+
|
|
16
|
+
export type BadgeStylesheet = {
|
|
17
|
+
badge: ExpandedBadgeStyles;
|
|
18
|
+
content: ExpandedBadgeStyles;
|
|
19
|
+
icon: ExpandedBadgeStyles;
|
|
20
|
+
text: ExpandedBadgeStyles;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Create type variants for badge
|
|
25
|
+
*/
|
|
26
|
+
function createBadgeTypeVariants(theme: Theme, color: Color) {
|
|
27
|
+
const colorValue = getColorFromString(theme, color);
|
|
28
|
+
return {
|
|
29
|
+
filled: {
|
|
30
|
+
borderWidth: 0,
|
|
31
|
+
backgroundColor: colorValue,
|
|
32
|
+
},
|
|
33
|
+
outlined: {
|
|
34
|
+
backgroundColor: 'transparent',
|
|
35
|
+
borderWidth: 2,
|
|
36
|
+
borderStyle: 'solid',
|
|
37
|
+
borderColor: colorValue,
|
|
38
|
+
},
|
|
39
|
+
dot: {
|
|
40
|
+
minWidth: 8,
|
|
41
|
+
width: 8,
|
|
42
|
+
height: 8,
|
|
43
|
+
paddingHorizontal: 0,
|
|
44
|
+
paddingVertical: 0,
|
|
45
|
+
backgroundColor: colorValue,
|
|
46
|
+
},
|
|
47
|
+
} as const;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Create type variants for badge text
|
|
52
|
+
*/
|
|
53
|
+
function createTextTypeVariants(theme: Theme, color: Color){
|
|
54
|
+
const colorValue = getColorFromString(theme, color);
|
|
55
|
+
return {
|
|
56
|
+
filled: {
|
|
57
|
+
color: theme.colors.text.inverse,
|
|
58
|
+
},
|
|
59
|
+
outlined: {
|
|
60
|
+
color: colorValue,
|
|
61
|
+
},
|
|
62
|
+
dot: {
|
|
63
|
+
display: 'none',
|
|
64
|
+
},
|
|
65
|
+
} as const;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Generate badge container styles
|
|
70
|
+
*/
|
|
71
|
+
function createBadgeStyles(theme: Theme) {
|
|
72
|
+
return ({ color }: Partial<BadgeVariants>) => {
|
|
73
|
+
return {
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
justifyContent: 'center',
|
|
76
|
+
borderRadius: 9999,
|
|
77
|
+
variants: {
|
|
78
|
+
size: buildSizeVariants(theme, 'badge', (size) => ({
|
|
79
|
+
minWidth: size.minWidth,
|
|
80
|
+
height: size.height,
|
|
81
|
+
paddingHorizontal: size.paddingHorizontal,
|
|
82
|
+
})),
|
|
83
|
+
type: createBadgeTypeVariants(theme, color),
|
|
84
|
+
},
|
|
85
|
+
_web: {
|
|
86
|
+
display: 'flex',
|
|
87
|
+
alignItems: 'center',
|
|
88
|
+
justifyContent: 'center',
|
|
89
|
+
boxSizing: 'border-box',
|
|
90
|
+
fontWeight: '600',
|
|
91
|
+
lineHeight: 1,
|
|
92
|
+
},
|
|
93
|
+
} as const;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Generate badge text styles
|
|
99
|
+
*/
|
|
100
|
+
function createTextStyles(theme: Theme) {
|
|
101
|
+
return ({ color }: Partial<BadgeVariants>) => {
|
|
102
|
+
return {
|
|
103
|
+
fontWeight: '600',
|
|
104
|
+
textAlign: 'center',
|
|
105
|
+
variants: {
|
|
106
|
+
size: buildSizeVariants(theme, 'badge', (size) => ({
|
|
107
|
+
fontSize: size.fontSize,
|
|
108
|
+
lineHeight: size.lineHeight,
|
|
109
|
+
})),
|
|
110
|
+
type: createTextTypeVariants(theme, color),
|
|
111
|
+
},
|
|
112
|
+
} as const;
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Create content styles
|
|
118
|
+
*/
|
|
119
|
+
function createContentStyles() {
|
|
120
|
+
return () => ({
|
|
121
|
+
display: 'flex' as const,
|
|
122
|
+
flexDirection: 'row' as const,
|
|
123
|
+
alignItems: 'center' as const,
|
|
124
|
+
justifyContent: 'center' as const,
|
|
125
|
+
gap: 4,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Create icon styles
|
|
131
|
+
*/
|
|
132
|
+
function createIconStyles(theme: Theme) {
|
|
133
|
+
return () => ({
|
|
134
|
+
display: 'flex' as const,
|
|
135
|
+
alignItems: 'center' as const,
|
|
136
|
+
justifyContent: 'center' as const,
|
|
137
|
+
variants: {
|
|
138
|
+
size: buildSizeVariants(theme, 'badge', (size) => ({
|
|
139
|
+
width: size.iconSize,
|
|
140
|
+
height: size.iconSize,
|
|
141
|
+
})),
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
147
|
+
// transform on native cannot resolve function calls to extract variant structures.
|
|
148
|
+
export const badgeStyles = StyleSheet.create((theme: Theme) => {
|
|
149
|
+
// Apply extensions to main visual elements
|
|
150
|
+
|
|
151
|
+
return applyExtensions('Badge', theme, {badge: createBadgeStyles(theme),
|
|
152
|
+
text: createTextStyles(theme),
|
|
153
|
+
// Additional styles (merged from return)
|
|
154
|
+
// Minor utility styles (not extended)
|
|
155
|
+
content: createContentStyles()(),
|
|
156
|
+
icon: createIconStyles(theme)()});
|
|
157
|
+
});
|
|
@@ -1,86 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Badge styles using defineStyle with $iterator expansion.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper, getColorFromString } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Size, Color } from '@idealyst/theme';
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
// Required: Unistyles must see StyleSheet usage in original source to process this file
|
|
9
|
+
void StyleSheet;
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type: BadgeType;
|
|
11
|
-
color: Color;
|
|
12
|
-
}
|
|
11
|
+
// Wrap theme for $iterator support
|
|
12
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
type BadgeType = 'filled' | 'outlined' | 'dot';
|
|
15
15
|
|
|
16
|
-
export type
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
16
|
+
export type BadgeDynamicProps = {
|
|
17
|
+
size?: Size;
|
|
18
|
+
type?: BadgeType;
|
|
19
|
+
color?: Color;
|
|
20
|
+
};
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
|
-
*
|
|
23
|
+
* Badge styles with color-based type variants.
|
|
25
24
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
filled: {
|
|
30
|
-
borderWidth: 0,
|
|
31
|
-
backgroundColor: colorValue,
|
|
32
|
-
},
|
|
33
|
-
outlined: {
|
|
34
|
-
backgroundColor: 'transparent',
|
|
35
|
-
borderWidth: 2,
|
|
36
|
-
borderStyle: 'solid',
|
|
37
|
-
borderColor: colorValue,
|
|
38
|
-
},
|
|
39
|
-
dot: {
|
|
40
|
-
minWidth: 8,
|
|
41
|
-
width: 8,
|
|
42
|
-
height: 8,
|
|
43
|
-
paddingHorizontal: 0,
|
|
44
|
-
paddingVertical: 0,
|
|
45
|
-
backgroundColor: colorValue,
|
|
46
|
-
},
|
|
47
|
-
} as const;
|
|
48
|
-
}
|
|
25
|
+
export const badgeStyles = defineStyle('Badge', (theme: Theme) => ({
|
|
26
|
+
badge: ({ color = 'primary', type = 'filled' }: BadgeDynamicProps) => {
|
|
27
|
+
const colorValue = getColorFromString(theme as unknown as BaseTheme, color);
|
|
49
28
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
filled: {
|
|
57
|
-
color: theme.colors.text.inverse,
|
|
58
|
-
},
|
|
59
|
-
outlined: {
|
|
60
|
-
color: colorValue,
|
|
61
|
-
},
|
|
62
|
-
dot: {
|
|
63
|
-
display: 'none',
|
|
64
|
-
},
|
|
65
|
-
} as const;
|
|
66
|
-
}
|
|
29
|
+
const typeStyles = type === 'filled'
|
|
30
|
+
? { borderWidth: 0, backgroundColor: colorValue }
|
|
31
|
+
: type === 'outlined'
|
|
32
|
+
? { backgroundColor: 'transparent', borderWidth: 2, borderStyle: 'solid' as const, borderColor: colorValue }
|
|
33
|
+
: { minWidth: 8, width: 8, height: 8, paddingHorizontal: 0, paddingVertical: 0, backgroundColor: colorValue };
|
|
67
34
|
|
|
68
|
-
/**
|
|
69
|
-
* Generate badge container styles
|
|
70
|
-
*/
|
|
71
|
-
function createBadgeStyles(theme: Theme) {
|
|
72
|
-
return ({ color }: Partial<BadgeVariants>) => {
|
|
73
35
|
return {
|
|
74
|
-
alignItems: 'center',
|
|
75
|
-
justifyContent: 'center',
|
|
36
|
+
alignItems: 'center' as const,
|
|
37
|
+
justifyContent: 'center' as const,
|
|
76
38
|
borderRadius: 9999,
|
|
39
|
+
...typeStyles,
|
|
77
40
|
variants: {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
41
|
+
// $iterator expands for each badge size
|
|
42
|
+
size: {
|
|
43
|
+
minWidth: theme.sizes.$badge.minWidth,
|
|
44
|
+
height: theme.sizes.$badge.height,
|
|
45
|
+
paddingHorizontal: theme.sizes.$badge.paddingHorizontal,
|
|
46
|
+
},
|
|
84
47
|
},
|
|
85
48
|
_web: {
|
|
86
49
|
display: 'flex',
|
|
@@ -91,71 +54,48 @@ function createBadgeStyles(theme: Theme) {
|
|
|
91
54
|
lineHeight: 1,
|
|
92
55
|
},
|
|
93
56
|
} as const;
|
|
94
|
-
}
|
|
95
|
-
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
text: ({ color = 'primary', type = 'filled' }: BadgeDynamicProps) => {
|
|
60
|
+
const colorValue = getColorFromString(theme as unknown as BaseTheme, color);
|
|
61
|
+
|
|
62
|
+
const textColor = type === 'filled'
|
|
63
|
+
? theme.colors.text.inverse
|
|
64
|
+
: type === 'outlined'
|
|
65
|
+
? colorValue
|
|
66
|
+
: 'transparent'; // dot type hides text
|
|
96
67
|
|
|
97
|
-
/**
|
|
98
|
-
* Generate badge text styles
|
|
99
|
-
*/
|
|
100
|
-
function createTextStyles(theme: Theme) {
|
|
101
|
-
return ({ color }: Partial<BadgeVariants>) => {
|
|
102
68
|
return {
|
|
103
|
-
fontWeight: '600',
|
|
104
|
-
textAlign: 'center',
|
|
69
|
+
fontWeight: '600' as const,
|
|
70
|
+
textAlign: 'center' as const,
|
|
71
|
+
color: textColor,
|
|
72
|
+
...(type === 'dot' ? { display: 'none' as const } : {}),
|
|
105
73
|
variants: {
|
|
106
|
-
size:
|
|
107
|
-
fontSize:
|
|
108
|
-
lineHeight:
|
|
109
|
-
}
|
|
110
|
-
type: createTextTypeVariants(theme, color),
|
|
74
|
+
size: {
|
|
75
|
+
fontSize: theme.sizes.$badge.fontSize,
|
|
76
|
+
lineHeight: theme.sizes.$badge.lineHeight,
|
|
77
|
+
},
|
|
111
78
|
},
|
|
112
79
|
} as const;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
80
|
+
},
|
|
115
81
|
|
|
116
|
-
|
|
117
|
-
* Create content styles
|
|
118
|
-
*/
|
|
119
|
-
function createContentStyles() {
|
|
120
|
-
return () => ({
|
|
82
|
+
content: (_props: BadgeDynamicProps) => ({
|
|
121
83
|
display: 'flex' as const,
|
|
122
84
|
flexDirection: 'row' as const,
|
|
123
85
|
alignItems: 'center' as const,
|
|
124
86
|
justifyContent: 'center' as const,
|
|
125
87
|
gap: 4,
|
|
126
|
-
})
|
|
127
|
-
}
|
|
88
|
+
}),
|
|
128
89
|
|
|
129
|
-
|
|
130
|
-
* Create icon styles
|
|
131
|
-
*/
|
|
132
|
-
function createIconStyles(theme: Theme) {
|
|
133
|
-
return () => ({
|
|
90
|
+
icon: (_props: BadgeDynamicProps) => ({
|
|
134
91
|
display: 'flex' as const,
|
|
135
92
|
alignItems: 'center' as const,
|
|
136
93
|
justifyContent: 'center' as const,
|
|
137
94
|
variants: {
|
|
138
|
-
size:
|
|
139
|
-
width:
|
|
140
|
-
height:
|
|
141
|
-
}
|
|
95
|
+
size: {
|
|
96
|
+
width: theme.sizes.$badge.iconSize,
|
|
97
|
+
height: theme.sizes.$badge.iconSize,
|
|
98
|
+
},
|
|
142
99
|
},
|
|
143
|
-
})
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
147
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
148
|
-
export const badgeStyles = StyleSheet.create((theme: Theme) => {
|
|
149
|
-
// Apply extensions to main visual elements
|
|
150
|
-
const extended = applyExtensions('Badge', theme, {
|
|
151
|
-
badge: createBadgeStyles(theme),
|
|
152
|
-
text: createTextStyles(theme),
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
return {
|
|
156
|
-
...extended,
|
|
157
|
-
// Minor utility styles (not extended)
|
|
158
|
-
content: createContentStyles()(),
|
|
159
|
-
icon: createIconStyles(theme)(),
|
|
160
|
-
};
|
|
161
|
-
});
|
|
100
|
+
}),
|
|
101
|
+
}));
|