@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
|
@@ -30,12 +30,16 @@ const Alert = forwardRef<ComponentRef<typeof View>, AlertProps>(({
|
|
|
30
30
|
testID,
|
|
31
31
|
id,
|
|
32
32
|
}, ref) => {
|
|
33
|
-
//
|
|
33
|
+
// Call all styles as functions to get theme-reactive styles
|
|
34
34
|
const dynamicProps = { intent, type };
|
|
35
35
|
const containerStyle = (alertStyles.container as any)(dynamicProps);
|
|
36
36
|
const iconContainerStyle = (alertStyles.iconContainer as any)(dynamicProps);
|
|
37
37
|
const titleStyle = (alertStyles.title as any)(dynamicProps);
|
|
38
38
|
const messageStyle = (alertStyles.message as any)(dynamicProps);
|
|
39
|
+
const contentStyle = (alertStyles.content as any)({});
|
|
40
|
+
const actionsStyle = (alertStyles.actions as any)({});
|
|
41
|
+
const closeButtonStyle = (alertStyles.closeButton as any)({});
|
|
42
|
+
const closeIconStyle = (alertStyles.closeIcon as any)(dynamicProps);
|
|
39
43
|
|
|
40
44
|
const displayIcon = icon !== undefined ? icon : (showIcon ? defaultIcons[intent] : null);
|
|
41
45
|
|
|
@@ -71,7 +75,7 @@ const Alert = forwardRef<ComponentRef<typeof View>, AlertProps>(({
|
|
|
71
75
|
</View>
|
|
72
76
|
)}
|
|
73
77
|
|
|
74
|
-
<View style={
|
|
78
|
+
<View style={contentStyle}>
|
|
75
79
|
{title && (
|
|
76
80
|
<Text style={titleStyle}>
|
|
77
81
|
{title}
|
|
@@ -84,10 +88,16 @@ const Alert = forwardRef<ComponentRef<typeof View>, AlertProps>(({
|
|
|
84
88
|
</Text>
|
|
85
89
|
)}
|
|
86
90
|
|
|
87
|
-
{children
|
|
91
|
+
{children && (
|
|
92
|
+
typeof children === 'string' ? (
|
|
93
|
+
<Text style={messageStyle}>{children}</Text>
|
|
94
|
+
) : (
|
|
95
|
+
children
|
|
96
|
+
)
|
|
97
|
+
)}
|
|
88
98
|
|
|
89
99
|
{actions && (
|
|
90
|
-
<View style={
|
|
100
|
+
<View style={actionsStyle}>
|
|
91
101
|
{actions}
|
|
92
102
|
</View>
|
|
93
103
|
)}
|
|
@@ -95,7 +105,7 @@ const Alert = forwardRef<ComponentRef<typeof View>, AlertProps>(({
|
|
|
95
105
|
|
|
96
106
|
{dismissible && onDismiss && (
|
|
97
107
|
<TouchableOpacity
|
|
98
|
-
style={
|
|
108
|
+
style={closeButtonStyle}
|
|
99
109
|
onPress={onDismiss}
|
|
100
110
|
accessibilityLabel="Dismiss alert"
|
|
101
111
|
accessibilityRole="button"
|
|
@@ -103,7 +113,7 @@ const Alert = forwardRef<ComponentRef<typeof View>, AlertProps>(({
|
|
|
103
113
|
<MaterialCommunityIcons
|
|
104
114
|
name="close"
|
|
105
115
|
size={16}
|
|
106
|
-
style={
|
|
116
|
+
style={closeIconStyle}
|
|
107
117
|
/>
|
|
108
118
|
</TouchableOpacity>
|
|
109
119
|
)}
|
|
@@ -0,0 +1,209 @@
|
|
|
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,169 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alert styles using defineStyle with dynamic intent/type handling.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Intent } from '@idealyst/theme';
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
// Required: Unistyles must see StyleSheet usage in original source to process this file
|
|
9
|
+
void StyleSheet;
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
// Wrap theme for $iterator support
|
|
12
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
13
|
+
|
|
14
|
+
type AlertType = 'filled' | 'outlined' | 'soft';
|
|
12
15
|
|
|
13
|
-
type AlertDynamicProps = {
|
|
14
|
-
intent?:
|
|
16
|
+
export type AlertDynamicProps = {
|
|
17
|
+
intent?: Intent;
|
|
15
18
|
type?: AlertType;
|
|
16
19
|
};
|
|
17
20
|
|
|
18
21
|
/**
|
|
19
|
-
*
|
|
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
|
|
22
|
+
* Alert styles with intent/type combination handling.
|
|
52
23
|
*/
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
24
|
+
export const alertStyles = defineStyle('Alert', (theme: Theme) => ({
|
|
25
|
+
container: ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
26
|
+
const intentValue = theme.intents[intent];
|
|
27
|
+
|
|
28
|
+
// Background color based on type
|
|
29
|
+
const backgroundColor = type === 'filled'
|
|
30
|
+
? intentValue.primary
|
|
31
|
+
: type === 'soft'
|
|
32
|
+
? intentValue.light
|
|
33
|
+
: 'transparent';
|
|
34
|
+
|
|
35
|
+
// Border color based on type
|
|
36
|
+
const borderColor = (type === 'filled' || type === 'outlined')
|
|
37
|
+
? intentValue.primary
|
|
38
|
+
: intentValue.light;
|
|
60
39
|
|
|
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
40
|
return {
|
|
78
|
-
display: 'flex',
|
|
79
|
-
flexDirection: 'row',
|
|
80
|
-
alignItems: 'flex-start',
|
|
41
|
+
display: 'flex' as const,
|
|
42
|
+
flexDirection: 'row' as const,
|
|
43
|
+
alignItems: 'flex-start' as const,
|
|
81
44
|
gap: 8,
|
|
82
45
|
padding: 16,
|
|
83
46
|
borderRadius: 8,
|
|
84
47
|
borderWidth: 1,
|
|
85
48
|
borderStyle: 'solid' as const,
|
|
86
|
-
backgroundColor
|
|
87
|
-
borderColor
|
|
49
|
+
backgroundColor,
|
|
50
|
+
borderColor,
|
|
88
51
|
} as const;
|
|
89
|
-
}
|
|
90
|
-
|
|
52
|
+
},
|
|
53
|
+
|
|
54
|
+
iconContainer: ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
55
|
+
const intentValue = theme.intents[intent];
|
|
56
|
+
const color = type === 'filled' ? intentValue.contrast : intentValue.primary;
|
|
91
57
|
|
|
92
|
-
/**
|
|
93
|
-
* Create dynamic icon container styles
|
|
94
|
-
*/
|
|
95
|
-
function createIconContainerStyles(theme: Theme) {
|
|
96
|
-
return ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
97
58
|
return {
|
|
98
|
-
display: 'flex',
|
|
99
|
-
alignItems: 'center',
|
|
100
|
-
justifyContent: 'center',
|
|
59
|
+
display: 'flex' as const,
|
|
60
|
+
alignItems: 'center' as const,
|
|
61
|
+
justifyContent: 'center' as const,
|
|
101
62
|
flexShrink: 0,
|
|
102
63
|
width: 24,
|
|
103
64
|
height: 24,
|
|
104
|
-
color
|
|
65
|
+
color,
|
|
105
66
|
} as const;
|
|
106
|
-
}
|
|
107
|
-
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
title: ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
70
|
+
const intentValue = theme.intents[intent];
|
|
71
|
+
const color = type === 'filled' ? intentValue.contrast : intentValue.primary;
|
|
108
72
|
|
|
109
|
-
/**
|
|
110
|
-
* Create dynamic title styles
|
|
111
|
-
*/
|
|
112
|
-
function createTitleStyles(theme: Theme) {
|
|
113
|
-
return ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
114
73
|
return {
|
|
115
74
|
fontSize: 16,
|
|
116
75
|
lineHeight: 24,
|
|
117
|
-
fontWeight: '600',
|
|
118
|
-
color
|
|
76
|
+
fontWeight: '600' as const,
|
|
77
|
+
color,
|
|
119
78
|
} as const;
|
|
120
|
-
}
|
|
121
|
-
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
message: ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
82
|
+
const intentValue = theme.intents[intent];
|
|
83
|
+
const color = type === 'filled' ? intentValue.contrast : theme.colors.text.primary;
|
|
122
84
|
|
|
123
|
-
/**
|
|
124
|
-
* Create dynamic message styles
|
|
125
|
-
*/
|
|
126
|
-
function createMessageStyles(theme: Theme) {
|
|
127
|
-
return ({ intent = 'neutral', type = 'soft' }: AlertDynamicProps) => {
|
|
128
85
|
return {
|
|
129
86
|
fontSize: 14,
|
|
130
87
|
lineHeight: 20,
|
|
131
|
-
color
|
|
88
|
+
color,
|
|
132
89
|
} as const;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
90
|
+
},
|
|
135
91
|
|
|
136
|
-
|
|
137
|
-
* Create content styles
|
|
138
|
-
*/
|
|
139
|
-
function createContentStyles() {
|
|
140
|
-
return () => ({
|
|
92
|
+
content: (_props: AlertDynamicProps) => ({
|
|
141
93
|
flex: 1,
|
|
142
94
|
display: 'flex' as const,
|
|
143
95
|
flexDirection: 'column' as const,
|
|
144
96
|
gap: 4,
|
|
145
|
-
})
|
|
146
|
-
}
|
|
97
|
+
}),
|
|
147
98
|
|
|
148
|
-
|
|
149
|
-
* Create actions styles
|
|
150
|
-
*/
|
|
151
|
-
function createActionsStyles() {
|
|
152
|
-
return () => ({
|
|
99
|
+
actions: (_props: AlertDynamicProps) => ({
|
|
153
100
|
marginTop: 4,
|
|
154
101
|
display: 'flex' as const,
|
|
155
102
|
flexDirection: 'row' as const,
|
|
156
103
|
gap: 8,
|
|
157
|
-
})
|
|
158
|
-
}
|
|
104
|
+
}),
|
|
159
105
|
|
|
160
|
-
|
|
161
|
-
* Create close button styles
|
|
162
|
-
*/
|
|
163
|
-
function createCloseButtonStyles() {
|
|
164
|
-
return () => ({
|
|
106
|
+
closeButton: (_props: AlertDynamicProps) => ({
|
|
165
107
|
padding: 4,
|
|
166
|
-
backgroundColor: 'transparent',
|
|
108
|
+
backgroundColor: 'transparent' as const,
|
|
167
109
|
borderRadius: 4,
|
|
168
110
|
display: 'flex' as const,
|
|
169
111
|
alignItems: 'center' as const,
|
|
@@ -177,37 +119,13 @@ function createCloseButtonStyles() {
|
|
|
177
119
|
backgroundColor: 'rgba(0, 0, 0, 0.1)',
|
|
178
120
|
},
|
|
179
121
|
},
|
|
180
|
-
})
|
|
181
|
-
}
|
|
122
|
+
}),
|
|
182
123
|
|
|
183
|
-
|
|
184
|
-
* Create close icon styles
|
|
185
|
-
*/
|
|
186
|
-
function createCloseIconStyles() {
|
|
187
|
-
return () => ({
|
|
124
|
+
closeIcon: (_props: AlertDynamicProps) => ({
|
|
188
125
|
display: 'flex' as const,
|
|
189
126
|
alignItems: 'center' as const,
|
|
190
127
|
justifyContent: 'center' as const,
|
|
191
128
|
width: 16,
|
|
192
129
|
height: 16,
|
|
193
|
-
})
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
export const alertStyles = StyleSheet.create((theme: Theme) => {
|
|
197
|
-
// Apply extensions to main visual elements
|
|
198
|
-
const extended = applyExtensions('Alert', theme, {
|
|
199
|
-
container: createContainerStyles(theme),
|
|
200
|
-
iconContainer: createIconContainerStyles(theme),
|
|
201
|
-
title: createTitleStyles(theme),
|
|
202
|
-
message: createMessageStyles(theme),
|
|
203
|
-
});
|
|
204
|
-
|
|
205
|
-
return {
|
|
206
|
-
...extended,
|
|
207
|
-
// Minor utility styles (not extended)
|
|
208
|
-
content: createContentStyles()(),
|
|
209
|
-
actions: createActionsStyles()(),
|
|
210
|
-
closeButton: createCloseButtonStyles()(),
|
|
211
|
-
closeIcon: createCloseIconStyles()(),
|
|
212
|
-
};
|
|
213
|
-
});
|
|
130
|
+
}),
|
|
131
|
+
}));
|
|
@@ -0,0 +1,99 @@
|
|
|
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
|
+
});
|