@idealyst/components 1.2.13 → 1.2.15
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.web.tsx +1 -1
- package/src/ActivityIndicator/ActivityIndicator.native.tsx +3 -3
- package/src/ActivityIndicator/ActivityIndicator.web.tsx +3 -3
- package/src/Alert/Alert.native.tsx +1 -1
- package/src/Alert/Alert.web.tsx +1 -1
- package/src/Avatar/Avatar.native.tsx +1 -1
- package/src/Badge/Badge.web.tsx +6 -2
- package/src/Badge/types.ts +5 -0
- package/src/Breadcrumb/Breadcrumb.native.tsx +20 -21
- package/src/Button/Button.native.tsx +3 -3
- package/src/Button/Button.web.tsx +5 -1
- package/src/Button/types.ts +5 -0
- package/src/Card/Card.web.tsx +4 -1
- package/src/Card/types.ts +5 -0
- package/src/Dialog/Dialog.native.tsx +3 -3
- package/src/Divider/Divider.web.tsx +2 -2
- package/src/Icon/Icon.web.tsx +2 -2
- package/src/Icon/types.ts +3 -0
- package/src/Image/Image.styles.tsx +5 -5
- package/src/Image/Image.web.tsx +3 -3
- package/src/List/List.native.tsx +1 -2
- package/src/List/List.web.tsx +1 -2
- package/src/List/ListSection.web.tsx +3 -3
- package/src/Menu/Menu.web.tsx +8 -10
- package/src/Menu/MenuItem.web.tsx +1 -1
- package/src/Popover/Popover.web.tsx +1 -1
- package/src/Pressable/Pressable.web.tsx +1 -1
- package/src/Progress/Progress.styles.tsx +76 -30
- package/src/Progress/Progress.web.tsx +13 -15
- package/src/SVGImage/SVGImage.web.tsx +1 -1
- package/src/Select/Select.web.tsx +2 -2
- 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/Slider/Slider.styles.tsx +131 -44
- package/src/Slider/Slider.web.tsx +22 -22
- package/src/TabBar/TabBar.native.tsx +2 -2
- package/src/Text/Text.web.tsx +29 -3
- package/src/Text/types.ts +14 -1
- package/src/TextArea/TextArea.styles.tsx +96 -57
- package/src/TextArea/TextArea.web.tsx +19 -28
- package/src/Tooltip/Tooltip.web.tsx +3 -3
- package/src/Video/Video.styles.tsx +3 -3
- package/src/Video/Video.web.tsx +1 -1
- package/src/View/View.styles.tsx +2 -2
- package/src/View/View.web.tsx +93 -9
- package/src/View/types.ts +5 -1
- package/src/examples/ViewExamples.tsx +34 -0
- package/src/extensions/index.ts +0 -7
- package/src/hooks/useMergeRefs.ts +12 -6
- package/src/index.native.ts +1 -1
- package/src/index.ts +1 -1
- package/src/utils/accessibility/keyboardPatterns.ts +4 -0
- package/src/utils/accessibility/types.ts +5 -1
- package/src/utils/accessibility/useAnnounce.ts +1 -1
- package/src/utils/accessibility/useKeyboardNavigation.ts +1 -1
- package/src/utils/index.ts +0 -3
- package/src/utils/viewStyleProps.ts +2 -0
- 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
- package/src/extensions/applyExtension.ts +0 -210
- package/src/utils/buildSizeVariants.ts +0 -16
|
@@ -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
|
-
});
|
|
@@ -1,231 +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 BreadcrumbSize = Size;
|
|
7
|
-
type BreadcrumbIntent = 'primary' | 'neutral';
|
|
8
|
-
|
|
9
|
-
type BreadcrumbVariants = {
|
|
10
|
-
size: BreadcrumbSize;
|
|
11
|
-
intent: BreadcrumbIntent;
|
|
12
|
-
disabled: boolean;
|
|
13
|
-
isLast: boolean;
|
|
14
|
-
clickable: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type ExpandedBreadcrumbStyles = StylesheetStyles<keyof BreadcrumbVariants>;
|
|
18
|
-
|
|
19
|
-
export type BreadcrumbStylesheet = {
|
|
20
|
-
container: ExpandedBreadcrumbStyles;
|
|
21
|
-
item: ExpandedBreadcrumbStyles;
|
|
22
|
-
itemText: ExpandedBreadcrumbStyles;
|
|
23
|
-
icon: ExpandedBreadcrumbStyles;
|
|
24
|
-
separator: ExpandedBreadcrumbStyles;
|
|
25
|
-
ellipsis: ExpandedBreadcrumbStyles;
|
|
26
|
-
ellipsisIcon: ExpandedBreadcrumbStyles;
|
|
27
|
-
menuButton: ExpandedBreadcrumbStyles;
|
|
28
|
-
menuButtonIcon: ExpandedBreadcrumbStyles;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type ItemTextDynamicProps = {
|
|
32
|
-
intent?: BreadcrumbIntent;
|
|
33
|
-
isLast?: boolean;
|
|
34
|
-
disabled?: boolean;
|
|
35
|
-
clickable?: boolean;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Create size variants for item text
|
|
40
|
-
*/
|
|
41
|
-
function createItemTextSizeVariants(theme: Theme) {
|
|
42
|
-
return buildSizeVariants(theme, 'breadcrumb', (size) => ({
|
|
43
|
-
fontSize: size.fontSize,
|
|
44
|
-
lineHeight: size.lineHeight,
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Get item text color based on state
|
|
50
|
-
*/
|
|
51
|
-
function getItemTextColor(theme: Theme, intent: BreadcrumbIntent, isLast: boolean, disabled: boolean, clickable: boolean): string {
|
|
52
|
-
if (disabled) {
|
|
53
|
-
return theme.colors.text.secondary;
|
|
54
|
-
}
|
|
55
|
-
if (isLast) {
|
|
56
|
-
return theme.colors.text.primary;
|
|
57
|
-
}
|
|
58
|
-
if (clickable) {
|
|
59
|
-
return intent === 'primary' ? theme.intents.primary.primary : theme.colors.text.secondary;
|
|
60
|
-
}
|
|
61
|
-
return theme.colors.text.secondary;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Create size variants for icons
|
|
66
|
-
*/
|
|
67
|
-
function createIconSizeVariants(theme: Theme) {
|
|
68
|
-
return buildSizeVariants(theme, 'breadcrumb', (size) => ({
|
|
69
|
-
width: size.iconSize,
|
|
70
|
-
height: size.iconSize,
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Get icon color based on intent
|
|
76
|
-
*/
|
|
77
|
-
function getIconColor(theme: Theme, intent: BreadcrumbIntent) {
|
|
78
|
-
if (intent === 'primary') {
|
|
79
|
-
return theme.intents.primary.primary;
|
|
80
|
-
}
|
|
81
|
-
return theme.colors.text.secondary;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const createItemTextStyles = (theme: Theme) => {
|
|
85
|
-
return ({ intent = 'primary', isLast = false, disabled = false, clickable = true }: ItemTextDynamicProps) => {
|
|
86
|
-
const color = getItemTextColor(theme, intent, isLast, disabled, clickable);
|
|
87
|
-
return {
|
|
88
|
-
color,
|
|
89
|
-
opacity: disabled ? 0.5 : 1,
|
|
90
|
-
variants: {
|
|
91
|
-
size: createItemTextSizeVariants(theme),
|
|
92
|
-
},
|
|
93
|
-
} as const;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const createIconStyles = (theme: Theme) => {
|
|
98
|
-
return {
|
|
99
|
-
variants: {
|
|
100
|
-
size: createIconSizeVariants(theme),
|
|
101
|
-
},
|
|
102
|
-
} as const;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const createSeparatorStyles = (theme: Theme) => {
|
|
106
|
-
return {
|
|
107
|
-
color: theme.colors.text.tertiary,
|
|
108
|
-
variants: {
|
|
109
|
-
size: createItemTextSizeVariants(theme),
|
|
110
|
-
},
|
|
111
|
-
} as const;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const createEllipsisIconStyles = (theme: Theme) => {
|
|
115
|
-
return ({ intent }: Partial<BreadcrumbVariants>) => {
|
|
116
|
-
return {
|
|
117
|
-
color: getIconColor(theme, intent),
|
|
118
|
-
variants: {
|
|
119
|
-
size: createIconSizeVariants(theme),
|
|
120
|
-
},
|
|
121
|
-
} as const;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const createMenuButtonIconStyles = (theme: Theme) => {
|
|
126
|
-
return ({ intent }: Partial<BreadcrumbVariants>) => {
|
|
127
|
-
return {
|
|
128
|
-
color: getIconColor(theme, intent),
|
|
129
|
-
variants: {
|
|
130
|
-
size: createIconSizeVariants(theme),
|
|
131
|
-
},
|
|
132
|
-
} as const;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Style creators for extension support
|
|
137
|
-
function createContainerStyles() {
|
|
138
|
-
return () => ({
|
|
139
|
-
display: 'flex' as const,
|
|
140
|
-
flexDirection: 'row' as const,
|
|
141
|
-
alignItems: 'center' as const,
|
|
142
|
-
flexWrap: 'wrap' as const,
|
|
143
|
-
gap: 8,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function createItemStyles() {
|
|
148
|
-
return () => ({
|
|
149
|
-
display: 'flex' as const,
|
|
150
|
-
flexDirection: 'row' as const,
|
|
151
|
-
alignItems: 'center' as const,
|
|
152
|
-
gap: 4,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel transform on native cannot resolve function calls to extract variant structures.
|
|
157
|
-
export const breadcrumbStyles = StyleSheet.create((theme: Theme) => {
|
|
158
|
-
// Apply extensions to main visual elements
|
|
159
|
-
|
|
160
|
-
return applyExtensions('Breadcrumb', theme, {container: createContainerStyles(),
|
|
161
|
-
item: createItemStyles(),
|
|
162
|
-
itemText: createItemTextStyles(theme),
|
|
163
|
-
// Additional styles (merged from return)
|
|
164
|
-
// Minor utility styles (not extended)
|
|
165
|
-
icon: createIconStyles(theme),
|
|
166
|
-
separator: createSeparatorStyles(theme),
|
|
167
|
-
ellipsis: {
|
|
168
|
-
display: 'flex',
|
|
169
|
-
alignItems: 'center',
|
|
170
|
-
justifyContent: 'center',
|
|
171
|
-
},
|
|
172
|
-
ellipsisIcon: createEllipsisIconStyles(theme),
|
|
173
|
-
menuButton: {
|
|
174
|
-
paddingVertical: 4,
|
|
175
|
-
paddingHorizontal: 8,
|
|
176
|
-
},
|
|
177
|
-
menuButtonIcon: createMenuButtonIconStyles(theme)});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// Export individual style sheets for backwards compatibility
|
|
181
|
-
export const breadcrumbContainerStyles = StyleSheet.create((theme: Theme) => {
|
|
182
|
-
return {
|
|
183
|
-
container: {
|
|
184
|
-
display: 'flex',
|
|
185
|
-
flexDirection: 'row',
|
|
186
|
-
alignItems: 'center',
|
|
187
|
-
flexWrap: 'wrap',
|
|
188
|
-
gap: 8,
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
export const breadcrumbItemStyles = StyleSheet.create((theme: Theme) => {
|
|
194
|
-
return {
|
|
195
|
-
item: {
|
|
196
|
-
display: 'flex',
|
|
197
|
-
flexDirection: 'row',
|
|
198
|
-
alignItems: 'center',
|
|
199
|
-
gap: 4,
|
|
200
|
-
},
|
|
201
|
-
itemText: createItemTextStyles(theme),
|
|
202
|
-
icon: createIconStyles(theme),
|
|
203
|
-
} as const;
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
export const breadcrumbSeparatorStyles = StyleSheet.create((theme: Theme) => {
|
|
207
|
-
return {
|
|
208
|
-
separator: createSeparatorStyles(theme),
|
|
209
|
-
} as const;
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
export const breadcrumbEllipsisStyles = StyleSheet.create((theme: Theme) => {
|
|
213
|
-
return {
|
|
214
|
-
ellipsis: {
|
|
215
|
-
display: 'flex',
|
|
216
|
-
alignItems: 'center',
|
|
217
|
-
justifyContent: 'center',
|
|
218
|
-
},
|
|
219
|
-
icon: createEllipsisIconStyles(theme),
|
|
220
|
-
} as const;
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
export const breadcrumbMenuButtonStyles = StyleSheet.create((theme: Theme) => {
|
|
224
|
-
return {
|
|
225
|
-
button: {
|
|
226
|
-
paddingVertical: 4,
|
|
227
|
-
paddingHorizontal: 8,
|
|
228
|
-
},
|
|
229
|
-
icon: createMenuButtonIconStyles(theme),
|
|
230
|
-
} as const;
|
|
231
|
-
});
|