@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,94 +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 { applyExtensions } from '../extensions/applyExtension';
|
|
5
|
-
|
|
6
|
-
type ActivityIndicatorSize = Size;
|
|
7
|
-
type ActivityIndicatorIntent = Intent;
|
|
8
|
-
|
|
9
|
-
type ActivityIndicatorVariants = {
|
|
10
|
-
size: ActivityIndicatorSize;
|
|
11
|
-
intent: ActivityIndicatorIntent;
|
|
12
|
-
animating: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type ExpandedActivityIndicatorStyles = StylesheetStyles<keyof ActivityIndicatorVariants>;
|
|
16
|
-
|
|
17
|
-
export type ActivityIndicatorStylesheet = {
|
|
18
|
-
container: ExpandedActivityIndicatorStyles;
|
|
19
|
-
spinner: ExpandedActivityIndicatorStyles;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
function createContainerSizeVariants(theme: Theme) {
|
|
23
|
-
return buildSizeVariants(theme, 'activityIndicator', (size) => ({
|
|
24
|
-
width: size.size,
|
|
25
|
-
height: size.size,
|
|
26
|
-
}));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function createSpinnerSizeVariants(theme: Theme) {
|
|
30
|
-
return buildSizeVariants(theme, 'activityIndicator', (size) => ({
|
|
31
|
-
width: size.size,
|
|
32
|
-
height: size.size,
|
|
33
|
-
borderWidth: size.borderWidth,
|
|
34
|
-
}));
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function getSpinnerColor(theme: Theme, intent: ActivityIndicatorIntent) {
|
|
38
|
-
return theme.intents[intent].primary;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
function createSpinnerStyles(theme: Theme) {
|
|
42
|
-
return ({ intent }: Partial<ActivityIndicatorVariants>) => {
|
|
43
|
-
const color = getSpinnerColor(theme, intent);
|
|
44
|
-
return {
|
|
45
|
-
borderRadius: 9999,
|
|
46
|
-
borderStyle: 'solid',
|
|
47
|
-
color,
|
|
48
|
-
variants: {
|
|
49
|
-
size: createSpinnerSizeVariants(theme),
|
|
50
|
-
animating: {
|
|
51
|
-
true: {},
|
|
52
|
-
false: {},
|
|
53
|
-
},
|
|
54
|
-
},
|
|
55
|
-
_web: {
|
|
56
|
-
borderColor: 'transparent',
|
|
57
|
-
borderTopColor: color,
|
|
58
|
-
borderRightColor: color,
|
|
59
|
-
animation: 'spin 1s linear infinite',
|
|
60
|
-
boxSizing: 'border-box',
|
|
61
|
-
},
|
|
62
|
-
} as const;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Style creators for extension support
|
|
67
|
-
function createContainerStyles(theme: Theme) {
|
|
68
|
-
return () => ({
|
|
69
|
-
alignItems: 'center' as const,
|
|
70
|
-
justifyContent: 'center' as const,
|
|
71
|
-
variants: {
|
|
72
|
-
size: createContainerSizeVariants(theme),
|
|
73
|
-
animating: {
|
|
74
|
-
true: {
|
|
75
|
-
opacity: 1,
|
|
76
|
-
},
|
|
77
|
-
false: {
|
|
78
|
-
opacity: 0,
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
86
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
87
|
-
// @ts-ignore - TS language server needs restart to pick up theme structure changes
|
|
88
|
-
export const activityIndicatorStyles = StyleSheet.create((theme: Theme) => {
|
|
89
|
-
// Apply extensions to main visual elements
|
|
90
|
-
return applyExtensions('ActivityIndicator', theme, {
|
|
91
|
-
container: createContainerStyles(theme),
|
|
92
|
-
spinner: createSpinnerStyles(theme),
|
|
93
|
-
});
|
|
94
|
-
});
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, Intent } from '@idealyst/theme';
|
|
3
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
4
|
-
|
|
5
|
-
type AlertType = 'filled' | 'outlined' | 'soft';
|
|
6
|
-
type AlertIntent = Intent;
|
|
7
|
-
|
|
8
|
-
export type AlertVariants = {
|
|
9
|
-
type: AlertType;
|
|
10
|
-
intent: AlertIntent;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type AlertDynamicProps = {
|
|
14
|
-
intent?: AlertIntent;
|
|
15
|
-
type?: AlertType;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Get the intent value, mapping 'info' to 'primary' for backwards compatibility
|
|
20
|
-
*/
|
|
21
|
-
function getIntentValue(theme: Theme, intent: AlertIntent) {
|
|
22
|
-
return theme.intents[intent];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get container background color based on intent and type
|
|
27
|
-
*/
|
|
28
|
-
function getContainerBackgroundColor(theme: Theme, intent: AlertIntent, type: AlertType): string {
|
|
29
|
-
const intentValue = getIntentValue(theme, intent);
|
|
30
|
-
if (type === 'filled') {
|
|
31
|
-
return intentValue.primary;
|
|
32
|
-
}
|
|
33
|
-
if (type === 'soft') {
|
|
34
|
-
return intentValue.light;
|
|
35
|
-
}
|
|
36
|
-
return 'transparent'; // outlined
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get container border color based on intent and type
|
|
41
|
-
*/
|
|
42
|
-
function getContainerBorderColor(theme: Theme, intent: AlertIntent, type: AlertType): string {
|
|
43
|
-
const intentValue = getIntentValue(theme, intent);
|
|
44
|
-
if (type === 'filled' || type === 'outlined') {
|
|
45
|
-
return intentValue.primary;
|
|
46
|
-
}
|
|
47
|
-
return intentValue.light; // soft
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Get icon/title color based on intent and type
|
|
52
|
-
*/
|
|
53
|
-
function getIconTitleColor(theme: Theme, intent: AlertIntent, type: AlertType): string {
|
|
54
|
-
const intentValue = getIntentValue(theme, intent);
|
|
55
|
-
if (type === 'filled') {
|
|
56
|
-
return intentValue.contrast;
|
|
57
|
-
}
|
|
58
|
-
return intentValue.primary; // outlined, soft
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Get message color based on intent and type
|
|
63
|
-
*/
|
|
64
|
-
function getMessageColor(theme: Theme, intent: AlertIntent, type: AlertType): string {
|
|
65
|
-
const intentValue = getIntentValue(theme, intent);
|
|
66
|
-
if (type === 'filled') {
|
|
67
|
-
return intentValue.contrast;
|
|
68
|
-
}
|
|
69
|
-
return theme.colors.text.primary; // outlined, soft
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Create dynamic container styles
|
|
74
|
-
*/
|
|
75
|
-
function createContainerStyles(theme: Theme) {
|
|
76
|
-
return ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
77
|
-
return {
|
|
78
|
-
display: 'flex',
|
|
79
|
-
flexDirection: 'row',
|
|
80
|
-
alignItems: 'flex-start',
|
|
81
|
-
gap: 8,
|
|
82
|
-
padding: 16,
|
|
83
|
-
borderRadius: 8,
|
|
84
|
-
borderWidth: 1,
|
|
85
|
-
borderStyle: 'solid' as const,
|
|
86
|
-
backgroundColor: getContainerBackgroundColor(theme, intent, type),
|
|
87
|
-
borderColor: getContainerBorderColor(theme, intent, type),
|
|
88
|
-
} as const;
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Create dynamic icon container styles
|
|
94
|
-
*/
|
|
95
|
-
function createIconContainerStyles(theme: Theme) {
|
|
96
|
-
return ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
97
|
-
return {
|
|
98
|
-
display: 'flex',
|
|
99
|
-
alignItems: 'center',
|
|
100
|
-
justifyContent: 'center',
|
|
101
|
-
flexShrink: 0,
|
|
102
|
-
width: 24,
|
|
103
|
-
height: 24,
|
|
104
|
-
color: getIconTitleColor(theme, intent, type),
|
|
105
|
-
} as const;
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Create dynamic title styles
|
|
111
|
-
*/
|
|
112
|
-
function createTitleStyles(theme: Theme) {
|
|
113
|
-
return ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
114
|
-
return {
|
|
115
|
-
fontSize: 16,
|
|
116
|
-
lineHeight: 24,
|
|
117
|
-
fontWeight: '600',
|
|
118
|
-
color: getIconTitleColor(theme, intent, type),
|
|
119
|
-
} as const;
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Create dynamic message styles
|
|
125
|
-
*/
|
|
126
|
-
function createMessageStyles(theme: Theme) {
|
|
127
|
-
return ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
128
|
-
return {
|
|
129
|
-
fontSize: 14,
|
|
130
|
-
lineHeight: 20,
|
|
131
|
-
color: getMessageColor(theme, intent, type),
|
|
132
|
-
} as const;
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Create content styles
|
|
138
|
-
*/
|
|
139
|
-
function createContentStyles() {
|
|
140
|
-
return () => ({
|
|
141
|
-
flex: 1,
|
|
142
|
-
display: 'flex' as const,
|
|
143
|
-
flexDirection: 'column' as const,
|
|
144
|
-
gap: 4,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Create actions styles
|
|
150
|
-
*/
|
|
151
|
-
function createActionsStyles() {
|
|
152
|
-
return () => ({
|
|
153
|
-
marginTop: 4,
|
|
154
|
-
display: 'flex' as const,
|
|
155
|
-
flexDirection: 'row' as const,
|
|
156
|
-
gap: 8,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Create close button styles
|
|
162
|
-
*/
|
|
163
|
-
function createCloseButtonStyles() {
|
|
164
|
-
return () => ({
|
|
165
|
-
padding: 4,
|
|
166
|
-
backgroundColor: 'transparent',
|
|
167
|
-
borderRadius: 4,
|
|
168
|
-
display: 'flex' as const,
|
|
169
|
-
alignItems: 'center' as const,
|
|
170
|
-
justifyContent: 'center' as const,
|
|
171
|
-
flexShrink: 0,
|
|
172
|
-
_web: {
|
|
173
|
-
border: 'none',
|
|
174
|
-
cursor: 'pointer',
|
|
175
|
-
outline: 'none',
|
|
176
|
-
_hover: {
|
|
177
|
-
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Create close icon styles
|
|
185
|
-
*/
|
|
186
|
-
function createCloseIconStyles() {
|
|
187
|
-
return () => ({
|
|
188
|
-
display: 'flex' as const,
|
|
189
|
-
alignItems: 'center' as const,
|
|
190
|
-
justifyContent: 'center' as const,
|
|
191
|
-
width: 16,
|
|
192
|
-
height: 16,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export const alertStyles = StyleSheet.create((theme: Theme) => {
|
|
197
|
-
// Apply extensions to main visual elements
|
|
198
|
-
|
|
199
|
-
return applyExtensions('Alert', theme, {container: createContainerStyles(theme),
|
|
200
|
-
iconContainer: createIconContainerStyles(theme),
|
|
201
|
-
title: createTitleStyles(theme),
|
|
202
|
-
message: createMessageStyles(theme),
|
|
203
|
-
// Additional styles (merged from return)
|
|
204
|
-
// Minor utility styles (not extended)
|
|
205
|
-
content: createContentStyles()(),
|
|
206
|
-
actions: createActionsStyles()(),
|
|
207
|
-
closeButton: createCloseButtonStyles()(),
|
|
208
|
-
closeIcon: createCloseIconStyles()()});
|
|
209
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, StylesheetStyles, Size } from '@idealyst/theme';
|
|
3
|
-
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
5
|
-
|
|
6
|
-
type AvatarSize = Size;
|
|
7
|
-
type AvatarShape = 'circle' | 'square';
|
|
8
|
-
|
|
9
|
-
type AvatarVariants = {
|
|
10
|
-
size: AvatarSize;
|
|
11
|
-
shape: AvatarShape;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type ExpandedAvatarStyles = StylesheetStyles<keyof AvatarVariants>;
|
|
15
|
-
|
|
16
|
-
export type AvatarStylesheet = {
|
|
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
|
-
}
|
|
39
|
-
|
|
40
|
-
function createFallbackSizeVariants(theme: Theme) {
|
|
41
|
-
return buildSizeVariants(theme, 'avatar', (size) => ({
|
|
42
|
-
fontSize: size.fontSize,
|
|
43
|
-
}));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/**
|
|
47
|
-
* Create container styles
|
|
48
|
-
*/
|
|
49
|
-
function createContainerStyles(theme: Theme) {
|
|
50
|
-
return () => ({
|
|
51
|
-
display: 'flex' as const,
|
|
52
|
-
alignItems: 'center' as const,
|
|
53
|
-
justifyContent: 'center' as const,
|
|
54
|
-
backgroundColor: theme.colors.surface.secondary,
|
|
55
|
-
overflow: 'hidden' as const,
|
|
56
|
-
variants: {
|
|
57
|
-
size: createAvatarSizeVariants(theme),
|
|
58
|
-
shape: createAvatarShapeVariants(theme),
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Create image styles
|
|
65
|
-
*/
|
|
66
|
-
function createImageStyles() {
|
|
67
|
-
return () => ({
|
|
68
|
-
width: '100%' as const,
|
|
69
|
-
height: '100%' as const,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Create fallback styles
|
|
75
|
-
*/
|
|
76
|
-
function createFallbackStyles(theme: Theme) {
|
|
77
|
-
return () => ({
|
|
78
|
-
color: theme.colors.text.primary,
|
|
79
|
-
fontWeight: '600' as const,
|
|
80
|
-
variants: {
|
|
81
|
-
size: createFallbackSizeVariants(theme),
|
|
82
|
-
},
|
|
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
|
-
|
|
91
|
-
return applyExtensions('Avatar', theme, {avatar: createContainerStyles(theme),
|
|
92
|
-
fallback: createFallbackStyles(theme),
|
|
93
|
-
// Additional styles (merged from return)
|
|
94
|
-
// Minor utility styles (not extended)
|
|
95
|
-
image: {
|
|
96
|
-
width: '100%',
|
|
97
|
-
height: '100%',
|
|
98
|
-
}});
|
|
99
|
-
});
|
|
@@ -1,157 +0,0 @@
|
|
|
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
|
-
});
|