@cdek-it/react-native-ui-kit 0.6.9 → 1.0.0-beta.0
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/README.md +9 -0
- package/dist/components/Accordion/Accordion.js +9 -10
- package/dist/components/Avatar/Avatar.js +7 -9
- package/dist/components/Badge/Badge.js +28 -20
- package/dist/components/Button/BaseButton.d.ts +3 -3
- package/dist/components/Button/BaseButton.js +12 -41
- package/dist/components/Button/Button.js +6 -4
- package/dist/components/Button/ButtonBadge.js +13 -12
- package/dist/components/Button/ButtonSeverity.js +6 -4
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/types.d.ts +2 -25
- package/dist/components/Button/utils/ButtonActivityIndicator.d.ts +3 -3
- package/dist/components/Button/utils/ButtonActivityIndicator.js +16 -12
- package/dist/components/Button/utils/ButtonContainer.d.ts +15 -6
- package/dist/components/Button/utils/ButtonContainer.js +424 -4
- package/dist/components/Button/utils/ButtonIcon.d.ts +8 -4
- package/dist/components/Button/utils/ButtonIcon.js +147 -4
- package/dist/components/Button/utils/ButtonLabel.d.ts +9 -4
- package/dist/components/Button/utils/ButtonLabel.js +139 -4
- package/dist/components/Button/utils/ButtonLeftArea.d.ts +9 -4
- package/dist/components/Button/utils/ButtonLeftArea.js +3 -3
- package/dist/components/Button/utils/ButtonPressedContext.d.ts +1 -0
- package/dist/components/Button/utils/ButtonPressedContext.js +2 -0
- package/dist/components/Button/utils/ButtonRightArea.d.ts +9 -3
- package/dist/components/Button/utils/ButtonRightArea.js +3 -3
- package/dist/components/Button/utils/ButtonVariantContext.d.ts +6 -0
- package/dist/components/Button/utils/ButtonVariantContext.js +4 -0
- package/dist/components/Checkbox/Checkbox.d.ts +6 -7
- package/dist/components/Checkbox/Checkbox.js +74 -22
- package/dist/components/Chip/Chip.js +13 -7
- package/dist/components/Dialog/DialogComponent.js +2 -3
- package/dist/components/Dialog/DialogHeader.js +17 -13
- package/dist/components/Divider/Divider.js +6 -6
- package/dist/components/Input/InputGroup.js +6 -13
- package/dist/components/Input/InputGroupAddon.js +5 -5
- package/dist/components/Input/InputOtp/InputOtp.js +2 -3
- package/dist/components/Input/InputOtp/InputOtpItem.js +2 -3
- package/dist/components/Input/InputSwitch/InputSwitch.js +2 -2
- package/dist/components/Input/InputSwitch/styles/useHandleStyles.js +13 -11
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.d.ts +6 -5
- package/dist/components/Input/InputSwitch/styles/useSliderStyles.js +36 -29
- package/dist/components/Input/InputTextBase/InputTextBase.d.ts +0 -5
- package/dist/components/Input/InputTextBase/InputTextBase.js +41 -26
- package/dist/components/Input/InputTextBase/useInputStyles.d.ts +6 -5
- package/dist/components/Input/InputTextBase/useInputStyles.js +6 -9
- package/dist/components/Input/index.d.ts +0 -1
- package/dist/components/Input/index.js +0 -1
- package/dist/components/List/Base/ListBase.js +9 -12
- package/dist/components/MenuItem/MenuItemAccessory.js +5 -5
- package/dist/components/MenuItem/MenuItemIcon.js +4 -5
- package/dist/components/MenuItem/Template/MenuItemTemplate.js +8 -5
- package/dist/components/Message/Message.js +54 -38
- package/dist/components/ProgressBar/ProgressBar.js +2 -3
- package/dist/components/ProgressSpinner/ProgressSpinner.js +3 -4
- package/dist/components/RadioButton/RadioButton.js +87 -104
- package/dist/components/Rating/Rating.js +2 -3
- package/dist/components/Rating/RatingClear.js +10 -11
- package/dist/components/Rating/RatingItem.js +23 -24
- package/dist/components/Rating/RatingItemContainer.js +2 -3
- package/dist/components/SelectButton/SelectButton.js +2 -3
- package/dist/components/SelectButton/SelectButtonItem.js +22 -49
- package/dist/components/Skeleton/Skeleton.js +2 -3
- package/dist/components/Slider/Slider.js +4 -6
- package/dist/components/Tabs/TabItem/TabItem.js +12 -21
- package/dist/components/Tabs/Tabs.js +2 -3
- package/dist/components/Tag/Tag.js +44 -29
- package/dist/components/Timer/Timer.js +2 -3
- package/dist/components/Timer/TimerFlip.js +2 -3
- package/dist/components/ToggleButton/ToggleButton.js +159 -35
- package/dist/components/Typography/Anchor.js +11 -7
- package/dist/components/Typography/Body.js +2 -3
- package/dist/components/Typography/Caption.js +9 -4
- package/dist/components/Typography/Service.js +13 -7
- package/dist/components/Typography/Subtitle.js +3 -6
- package/dist/components/Typography/Title.js +3 -6
- package/dist/hooks/useChangeTheme.d.ts +2 -1
- package/dist/hooks/useChangeTheme.js +10 -3
- package/dist/hooks/useFonts.d.ts +2 -1
- package/dist/hooks/useFonts.js +3 -3
- package/dist/hooks/useTheme.d.ts +2 -1
- package/dist/hooks/useTheme.js +6 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.js +2 -1
- package/dist/theme/ThemeContext.d.ts +9 -7
- package/dist/theme/ThemeContext.js +21 -14
- package/dist/theme/darkTheme.js +1 -0
- package/dist/theme/index.d.ts +1 -1
- package/dist/theme/index.js +1 -1
- package/dist/theme/lightTheme.js +1 -0
- package/dist/theme/types.d.ts +1 -0
- package/dist/utils/SvgUniversal.d.ts +9 -14
- package/dist/utils/SvgUniversal.js +10 -2
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +18 -8
- package/dist/components/Button/styles/index.d.ts +0 -2
- package/dist/components/Button/styles/index.js +0 -2
- package/dist/components/Button/styles/useBasicButtonStyles.d.ts +0 -98
- package/dist/components/Button/styles/useBasicButtonStyles.js +0 -81
- package/dist/components/Button/styles/useDangerButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useDangerButtonStyles.js +0 -57
- package/dist/components/Button/styles/useInfoButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useInfoButtonStyles.js +0 -56
- package/dist/components/Button/styles/useSeverityButtonStyles.d.ts +0 -64
- package/dist/components/Button/styles/useSeverityButtonStyles.js +0 -29
- package/dist/components/Button/styles/useSuccessButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useSuccessButtonStyles.js +0 -61
- package/dist/components/Button/styles/useWarningButtonStyles.d.ts +0 -63
- package/dist/components/Button/styles/useWarningButtonStyles.js +0 -61
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.d.ts +0 -3
- package/dist/components/Button/utils/useButtonContainerCallbackStyle.js +0 -141
- package/dist/components/Button/utils/useButtonLabelStyle.d.ts +0 -3
- package/dist/components/Button/utils/useButtonLabelStyle.js +0 -40
- package/dist/components/Button/utils/useIconStyle.d.ts +0 -7
- package/dist/components/Button/utils/useIconStyle.js +0 -35
- package/dist/components/Button/utils/useTypeBasedStyle.d.ts +0 -2
- package/dist/components/Button/utils/useTypeBasedStyle.js +0 -4
- package/dist/components/Checkbox/hooks/usePressableStyles.d.ts +0 -15
- package/dist/components/Checkbox/hooks/usePressableStyles.js +0 -91
- package/dist/components/Input/FloatLabel.d.ts +0 -22
- package/dist/components/Input/FloatLabel.js +0 -19
- package/dist/components/ToggleButton/hooks/useIconSize.d.ts +0 -14
- package/dist/components/ToggleButton/hooks/useIconSize.js +0 -26
- package/dist/components/ToggleButton/hooks/useLabelSize.d.ts +0 -8
- package/dist/components/ToggleButton/hooks/useLabelSize.js +0 -19
- package/dist/components/ToggleButton/hooks/useStateStyles.d.ts +0 -11
- package/dist/components/ToggleButton/hooks/useStateStyles.js +0 -92
- package/dist/utils/makeStyles.d.ts +0 -11
- package/dist/utils/makeStyles.js +0 -19
|
@@ -1,10 +1,430 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
1
2
|
import { Pressable } from 'react-native';
|
|
3
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
4
|
import { genericMemo } from '../../../utils/genericMemo';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { ButtonPressedContext } from './ButtonPressedContext';
|
|
6
|
+
import { ButtonVariantContext } from './ButtonVariantContext';
|
|
7
|
+
const ButtonContainerComponent = ({ style, size, disabled, loading, shape, isIconOnly, children, pressableRef, onPressIn, onPressOut, ...props }) => {
|
|
8
|
+
const pressed = useContext(ButtonPressedContext);
|
|
9
|
+
const { variant, severity } = useContext(ButtonVariantContext);
|
|
10
|
+
buttonContainerStyles.useVariants({
|
|
11
|
+
size,
|
|
12
|
+
shape,
|
|
13
|
+
variant,
|
|
14
|
+
severity,
|
|
15
|
+
pressed: pressed ? 'true' : 'false',
|
|
16
|
+
disabled: disabled || loading ? 'true' : 'false',
|
|
17
|
+
iconOnly: isIconOnly ? 'true' : 'false',
|
|
18
|
+
});
|
|
19
|
+
const resolvedStyle = typeof style === 'function'
|
|
20
|
+
? (state) => [
|
|
21
|
+
buttonContainerStyles.container,
|
|
22
|
+
isIconOnly && buttonContainerStyles.iconOnly,
|
|
23
|
+
style(state),
|
|
24
|
+
]
|
|
25
|
+
: [
|
|
26
|
+
buttonContainerStyles.container,
|
|
27
|
+
isIconOnly && buttonContainerStyles.iconOnly,
|
|
28
|
+
...(style ? [style] : []),
|
|
29
|
+
];
|
|
30
|
+
return (<Pressable accessibilityRole='button' disabled={disabled || loading} ref={pressableRef} style={resolvedStyle} onPressIn={onPressIn} onPressOut={onPressOut} {...props}>
|
|
7
31
|
{children}
|
|
8
32
|
</Pressable>);
|
|
9
33
|
};
|
|
10
34
|
export const ButtonContainer = genericMemo(ButtonContainerComponent);
|
|
35
|
+
const buttonContainerStyles = StyleSheet.create(({ theme, border, spacing, sizing }) => ({
|
|
36
|
+
container: {
|
|
37
|
+
flexDirection: 'row',
|
|
38
|
+
justifyContent: 'center',
|
|
39
|
+
alignItems: 'center',
|
|
40
|
+
borderWidth: border.Width.border,
|
|
41
|
+
variants: {
|
|
42
|
+
size: {
|
|
43
|
+
xlarge: {
|
|
44
|
+
paddingHorizontal: spacing.Padding['p-6'],
|
|
45
|
+
paddingVertical: theme.Button.Common.buttonPaddingTopBottom,
|
|
46
|
+
height: theme.Button.Common.buttonHeightXL,
|
|
47
|
+
minHeight: theme.Button.Common.buttonHeightXL,
|
|
48
|
+
maxHeight: theme.Button.Common.buttonHeightXL,
|
|
49
|
+
gap: spacing.Gap['gap-3'],
|
|
50
|
+
borderRadius: theme.General.borderRadius2XL,
|
|
51
|
+
},
|
|
52
|
+
large: {
|
|
53
|
+
paddingHorizontal: spacing.Padding['p-6'],
|
|
54
|
+
paddingVertical: theme.Button.Common.buttonPaddingTopBottom,
|
|
55
|
+
height: theme.Button.Common.buttonHeightLG,
|
|
56
|
+
minHeight: theme.Button.Common.buttonHeightLG,
|
|
57
|
+
maxHeight: theme.Button.Common.buttonHeightLG,
|
|
58
|
+
gap: spacing.Gap['gap-3'],
|
|
59
|
+
borderRadius: theme.General.borderRadius2XL,
|
|
60
|
+
},
|
|
61
|
+
base: {
|
|
62
|
+
paddingHorizontal: theme.Button.Common.buttonPaddingLeftRight,
|
|
63
|
+
paddingVertical: theme.Button.Common.buttonPaddingTopBottom,
|
|
64
|
+
height: theme.Button.Common.buttonHeight,
|
|
65
|
+
minHeight: theme.Button.Common.buttonHeight,
|
|
66
|
+
maxHeight: theme.Button.Common.buttonHeight,
|
|
67
|
+
gap: theme.General.inlineSpacing,
|
|
68
|
+
borderRadius: theme.General.borderRadiusXL,
|
|
69
|
+
},
|
|
70
|
+
small: {
|
|
71
|
+
paddingHorizontal: spacing.Padding['p-3'],
|
|
72
|
+
paddingVertical: theme.Button.Common.buttonPaddingTopBottom,
|
|
73
|
+
height: theme.Button.Common.buttonHeightSM,
|
|
74
|
+
minHeight: theme.Button.Common.buttonHeightSM,
|
|
75
|
+
maxHeight: theme.Button.Common.buttonHeightSM,
|
|
76
|
+
gap: theme.General.inlineSpacing,
|
|
77
|
+
borderRadius: theme.General.borderRadiusXL,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
shape: {
|
|
81
|
+
square: {},
|
|
82
|
+
circle: { borderRadius: border.Radius['rounded-full'] },
|
|
83
|
+
},
|
|
84
|
+
variant: {
|
|
85
|
+
primary: {
|
|
86
|
+
borderColor: theme.Button.Brand.buttonBorderColor,
|
|
87
|
+
backgroundColor: theme.Button.Brand.buttonBg,
|
|
88
|
+
},
|
|
89
|
+
secondary: {
|
|
90
|
+
borderColor: theme.Button.Primary.secondaryButtonBorderColor,
|
|
91
|
+
backgroundColor: theme.Button.Primary.secondaryButtonBg,
|
|
92
|
+
},
|
|
93
|
+
tertiary: {
|
|
94
|
+
borderColor: theme.Button.Secondary.helpButtonBorderColor,
|
|
95
|
+
backgroundColor: theme.Button.Secondary.helpButtonBg,
|
|
96
|
+
},
|
|
97
|
+
text: {
|
|
98
|
+
borderColor: theme.Button.Brand.buttonBorderColor,
|
|
99
|
+
backgroundColor: theme.Button.Text.textButtonBg,
|
|
100
|
+
},
|
|
101
|
+
link: {
|
|
102
|
+
paddingHorizontal: 0,
|
|
103
|
+
paddingVertical: spacing.Padding['p-1'],
|
|
104
|
+
height: 'auto',
|
|
105
|
+
minHeight: 'auto',
|
|
106
|
+
borderColor: theme.Button.Brand.buttonBorderColor,
|
|
107
|
+
backgroundColor: theme.Button.Text.textButtonBg,
|
|
108
|
+
},
|
|
109
|
+
basic: {
|
|
110
|
+
borderColor: theme.Button.Brand.buttonBorderColor,
|
|
111
|
+
backgroundColor: theme.Button.Brand.buttonBg,
|
|
112
|
+
},
|
|
113
|
+
outlined: {
|
|
114
|
+
borderColor: theme.Button.Brand.buttonBorderColor,
|
|
115
|
+
backgroundColor: theme.Button.Text.textButtonBg,
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
severity: { info: {}, success: {}, warning: {}, danger: {} },
|
|
119
|
+
pressed: { true: {}, false: {} },
|
|
120
|
+
disabled: {
|
|
121
|
+
true: {
|
|
122
|
+
backgroundColor: theme.Button.Disabled.disabledButtonBg,
|
|
123
|
+
borderColor: theme.Button.Disabled.disabledButtonBorderColor,
|
|
124
|
+
},
|
|
125
|
+
false: {},
|
|
126
|
+
},
|
|
127
|
+
iconOnly: { true: {}, false: {} },
|
|
128
|
+
},
|
|
129
|
+
compoundVariants: [
|
|
130
|
+
// basic button pressed
|
|
131
|
+
{
|
|
132
|
+
variant: 'primary',
|
|
133
|
+
pressed: 'true',
|
|
134
|
+
styles: {
|
|
135
|
+
borderColor: theme.Button.Brand.buttonBorderColor,
|
|
136
|
+
backgroundColor: theme.Button.Brand.buttonHoverBg,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
variant: 'secondary',
|
|
141
|
+
pressed: 'true',
|
|
142
|
+
styles: {
|
|
143
|
+
borderColor: theme.Button.Primary.secondaryButtonHoverBorderColor,
|
|
144
|
+
backgroundColor: theme.Button.Primary.secondaryButtonHoverBg,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
variant: 'tertiary',
|
|
149
|
+
pressed: 'true',
|
|
150
|
+
styles: {
|
|
151
|
+
borderColor: theme.Button.Secondary.helpButtonHoverBorderColor,
|
|
152
|
+
backgroundColor: theme.Button.Secondary.helpButtonHoverBg,
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
variant: 'text',
|
|
157
|
+
pressed: 'true',
|
|
158
|
+
styles: {
|
|
159
|
+
borderColor: theme.Button.Brand.buttonBorderColor,
|
|
160
|
+
backgroundColor: theme.Button.Text.textButtonHoverBg,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
// severity container (override placeholder variant styles)
|
|
164
|
+
{
|
|
165
|
+
variant: 'basic',
|
|
166
|
+
severity: 'info',
|
|
167
|
+
styles: {
|
|
168
|
+
borderColor: theme.Button.Severity.Info.Basic.infoButtonBorderColor,
|
|
169
|
+
backgroundColor: theme.Button.Severity.Info.Basic.infoButtonBg,
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
variant: 'outlined',
|
|
174
|
+
severity: 'info',
|
|
175
|
+
styles: {
|
|
176
|
+
borderColor: theme.Button.Severity.Info.Outlined.infoOutlinedButtonBorderColor,
|
|
177
|
+
backgroundColor: theme.Button.Severity.Info.Outlined.infoOutlinedButtonBg,
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
variant: 'text',
|
|
182
|
+
severity: 'info',
|
|
183
|
+
styles: {
|
|
184
|
+
borderColor: theme.Button.Severity.Info.Basic.infoButtonBorderColor,
|
|
185
|
+
backgroundColor: theme.Button.Severity.Info.Text.infoTextButtonBg,
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
variant: 'basic',
|
|
190
|
+
severity: 'success',
|
|
191
|
+
styles: {
|
|
192
|
+
borderColor: theme.Button.Severity.Success.Basic.successButtonBorderColor,
|
|
193
|
+
backgroundColor: theme.Button.Severity.Success.Basic.successButtonBg,
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
variant: 'outlined',
|
|
198
|
+
severity: 'success',
|
|
199
|
+
styles: {
|
|
200
|
+
borderColor: theme.Button.Severity.Success.Outlined
|
|
201
|
+
.successOutlinedButtonBorderColor,
|
|
202
|
+
backgroundColor: theme.Button.Severity.Success.Outlined.successOutlinedButtonBg,
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
variant: 'text',
|
|
207
|
+
severity: 'success',
|
|
208
|
+
styles: {
|
|
209
|
+
borderColor: theme.Button.Severity.Success.Basic.successButtonBorderColor,
|
|
210
|
+
backgroundColor: theme.Button.Severity.Success.Text.successTextButtonBg,
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
variant: 'basic',
|
|
215
|
+
severity: 'warning',
|
|
216
|
+
styles: {
|
|
217
|
+
borderColor: theme.Button.Severity.Warning.Basic.warningButtonBorderColor,
|
|
218
|
+
backgroundColor: theme.Button.Severity.Warning.Basic.warningButtonBg,
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
variant: 'outlined',
|
|
223
|
+
severity: 'warning',
|
|
224
|
+
styles: {
|
|
225
|
+
borderColor: theme.Button.Severity.Warning.Outlined
|
|
226
|
+
.warningOutlinedButtonBorderColor,
|
|
227
|
+
backgroundColor: theme.Button.Severity.Warning.Outlined.warningOutlinedButtonBg,
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
variant: 'text',
|
|
232
|
+
severity: 'warning',
|
|
233
|
+
styles: {
|
|
234
|
+
borderColor: theme.Button.Severity.Warning.Basic.warningButtonBorderColor,
|
|
235
|
+
backgroundColor: theme.Button.Severity.Warning.Text.warningTextButtonBg,
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
variant: 'basic',
|
|
240
|
+
severity: 'danger',
|
|
241
|
+
styles: {
|
|
242
|
+
borderColor: theme.Button.Severity.Danger.Basic.dangerButtonBorderColor,
|
|
243
|
+
backgroundColor: theme.Button.Severity.Danger.Basic.dangerButtonBg,
|
|
244
|
+
},
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
variant: 'outlined',
|
|
248
|
+
severity: 'danger',
|
|
249
|
+
styles: {
|
|
250
|
+
borderColor: theme.Button.Severity.Danger.Outlined
|
|
251
|
+
.dangerOutlinedButtonBorderColor,
|
|
252
|
+
backgroundColor: theme.Button.Severity.Danger.Outlined.dangerOutlinedButtonBg,
|
|
253
|
+
},
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
variant: 'text',
|
|
257
|
+
severity: 'danger',
|
|
258
|
+
styles: {
|
|
259
|
+
borderColor: theme.Button.Severity.Danger.Basic.dangerButtonBorderColor,
|
|
260
|
+
backgroundColor: theme.Button.Severity.Danger.Text.dangerTextButtonBg,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
// severity pressed
|
|
264
|
+
{
|
|
265
|
+
variant: 'basic',
|
|
266
|
+
severity: 'info',
|
|
267
|
+
pressed: 'true',
|
|
268
|
+
styles: {
|
|
269
|
+
borderColor: theme.Button.Severity.Info.Basic.infoButtonBorderColor,
|
|
270
|
+
backgroundColor: theme.Button.Severity.Info.Basic.infoButtonHoverBg,
|
|
271
|
+
},
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
variant: 'outlined',
|
|
275
|
+
severity: 'info',
|
|
276
|
+
pressed: 'true',
|
|
277
|
+
styles: {
|
|
278
|
+
borderColor: theme.Button.Severity.Info.Outlined
|
|
279
|
+
.infoOutlinedButtonHoverBorderColor,
|
|
280
|
+
backgroundColor: theme.Button.Severity.Info.Outlined.infoOutlinedButtonHoverBg,
|
|
281
|
+
},
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
variant: 'text',
|
|
285
|
+
severity: 'info',
|
|
286
|
+
pressed: 'true',
|
|
287
|
+
styles: {
|
|
288
|
+
borderColor: theme.Surface['surface-transparent'],
|
|
289
|
+
backgroundColor: theme.Button.Severity.Info.Text.infoTextButtonHoverBg,
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
variant: 'basic',
|
|
294
|
+
severity: 'success',
|
|
295
|
+
pressed: 'true',
|
|
296
|
+
styles: {
|
|
297
|
+
borderColor: theme.Button.Severity.Success.Basic.successButtonBorderColor,
|
|
298
|
+
backgroundColor: theme.Button.Severity.Success.Basic.successButtonHoverBg,
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
variant: 'outlined',
|
|
303
|
+
severity: 'success',
|
|
304
|
+
pressed: 'true',
|
|
305
|
+
styles: {
|
|
306
|
+
borderColor: theme.Button.Severity.Success.Outlined
|
|
307
|
+
.successOutlinedButtonHoverBorderColor,
|
|
308
|
+
backgroundColor: theme.Button.Severity.Success.Outlined
|
|
309
|
+
.successOutlinedButtonHoverBg,
|
|
310
|
+
},
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
variant: 'text',
|
|
314
|
+
severity: 'success',
|
|
315
|
+
pressed: 'true',
|
|
316
|
+
styles: {
|
|
317
|
+
borderColor: theme.Surface['surface-transparent'],
|
|
318
|
+
backgroundColor: theme.Button.Severity.Success.Text.successTextButtonHoverBg,
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
{
|
|
322
|
+
variant: 'basic',
|
|
323
|
+
severity: 'warning',
|
|
324
|
+
pressed: 'true',
|
|
325
|
+
styles: {
|
|
326
|
+
borderColor: theme.Button.Severity.Warning.Basic.warningButtonBorderColor,
|
|
327
|
+
backgroundColor: theme.Button.Severity.Warning.Basic.warningButtonHoverBg,
|
|
328
|
+
},
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
variant: 'outlined',
|
|
332
|
+
severity: 'warning',
|
|
333
|
+
pressed: 'true',
|
|
334
|
+
styles: {
|
|
335
|
+
borderColor: theme.Button.Severity.Warning.Outlined
|
|
336
|
+
.warningOutlinedButtonHoverBorderColor,
|
|
337
|
+
backgroundColor: theme.Button.Severity.Warning.Outlined
|
|
338
|
+
.warningOutlinedButtonHoverBg,
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
{
|
|
342
|
+
variant: 'text',
|
|
343
|
+
severity: 'warning',
|
|
344
|
+
pressed: 'true',
|
|
345
|
+
styles: {
|
|
346
|
+
borderColor: theme.Surface['surface-transparent'],
|
|
347
|
+
backgroundColor: theme.Button.Severity.Warning.Text.warningTextButtonHoverBg,
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
variant: 'basic',
|
|
352
|
+
severity: 'danger',
|
|
353
|
+
pressed: 'true',
|
|
354
|
+
styles: {
|
|
355
|
+
borderColor: theme.Button.Severity.Danger.Basic.dangerButtonBorderColor,
|
|
356
|
+
backgroundColor: theme.Button.Severity.Danger.Basic.dangerButtonHoverBg,
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
variant: 'outlined',
|
|
361
|
+
severity: 'danger',
|
|
362
|
+
pressed: 'true',
|
|
363
|
+
styles: {
|
|
364
|
+
borderColor: theme.Button.Severity.Danger.Outlined
|
|
365
|
+
.dangerOutlinedButtonHoverBorderColor,
|
|
366
|
+
backgroundColor: theme.Button.Severity.Danger.Outlined.dangerOutlinedButtonHoverBg,
|
|
367
|
+
},
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
variant: 'text',
|
|
371
|
+
severity: 'danger',
|
|
372
|
+
pressed: 'true',
|
|
373
|
+
styles: {
|
|
374
|
+
borderColor: theme.Surface['surface-transparent'],
|
|
375
|
+
backgroundColor: theme.Button.Severity.Danger.Text.dangerTextButtonHoverBg,
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
// link + iconOnly special sizes
|
|
379
|
+
{
|
|
380
|
+
variant: 'link',
|
|
381
|
+
iconOnly: 'true',
|
|
382
|
+
size: 'xlarge',
|
|
383
|
+
styles: {
|
|
384
|
+
paddingHorizontal: spacing.Gap['gap-1'],
|
|
385
|
+
paddingVertical: spacing.Gap['gap-1'],
|
|
386
|
+
height: sizing.Height['h-2'],
|
|
387
|
+
minHeight: sizing.Height['h-2'],
|
|
388
|
+
maxHeight: sizing.Height['h-2'],
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
variant: 'link',
|
|
393
|
+
iconOnly: 'true',
|
|
394
|
+
size: 'large',
|
|
395
|
+
styles: {
|
|
396
|
+
paddingHorizontal: spacing.Gap['gap-0'],
|
|
397
|
+
paddingVertical: spacing.Gap['gap-0'],
|
|
398
|
+
height: 24.5,
|
|
399
|
+
minHeight: 24.5,
|
|
400
|
+
maxHeight: 24.5,
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
variant: 'link',
|
|
405
|
+
iconOnly: 'true',
|
|
406
|
+
size: 'base',
|
|
407
|
+
styles: {
|
|
408
|
+
paddingHorizontal: spacing.Gap['gap-1'],
|
|
409
|
+
paddingVertical: spacing.Gap['gap-1'],
|
|
410
|
+
height: 21.5,
|
|
411
|
+
minHeight: 21.5,
|
|
412
|
+
maxHeight: 21.5,
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
variant: 'link',
|
|
417
|
+
iconOnly: 'true',
|
|
418
|
+
size: 'small',
|
|
419
|
+
styles: {
|
|
420
|
+
paddingHorizontal: spacing.Gap['gap-1'],
|
|
421
|
+
paddingVertical: spacing.Gap['gap-1'],
|
|
422
|
+
height: sizing.Height['h-1'],
|
|
423
|
+
minHeight: sizing.Height['h-2'],
|
|
424
|
+
maxHeight: sizing.Height['h-2'],
|
|
425
|
+
},
|
|
426
|
+
},
|
|
427
|
+
],
|
|
428
|
+
},
|
|
429
|
+
iconOnly: { aspectRatio: 1 },
|
|
430
|
+
}));
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type { BaseButtonProps,
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { BaseButtonProps, ButtonSize } from '../types';
|
|
2
|
+
export interface ButtonIconProps {
|
|
3
|
+
readonly size: ButtonSize;
|
|
4
|
+
readonly disabled: boolean;
|
|
5
|
+
readonly loading: boolean;
|
|
6
|
+
readonly Icon?: BaseButtonProps<never>['Icon'];
|
|
7
|
+
}
|
|
8
|
+
export declare const ButtonIcon: ({ size, disabled, loading, Icon, }: ButtonIconProps) => import("react").JSX.Element | null;
|
|
@@ -1,11 +1,154 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
1
3
|
import { SvgUniversal } from '../../../utils/SvgUniversal';
|
|
2
4
|
import { genericMemo } from '../../../utils/genericMemo';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
import { ButtonPressedContext } from './ButtonPressedContext';
|
|
6
|
+
import { ButtonVariantContext } from './ButtonVariantContext';
|
|
7
|
+
const ButtonIconComponent = ({ size, disabled, loading, Icon, }) => {
|
|
8
|
+
const pressed = useContext(ButtonPressedContext);
|
|
9
|
+
const { variant, severity } = useContext(ButtonVariantContext);
|
|
10
|
+
buttonIconStyles.useVariants({
|
|
11
|
+
size,
|
|
12
|
+
variant,
|
|
13
|
+
severity,
|
|
14
|
+
pressed: pressed ? 'true' : 'false',
|
|
15
|
+
disabled: disabled || loading ? 'true' : 'false',
|
|
16
|
+
});
|
|
6
17
|
if (!Icon) {
|
|
7
18
|
return null;
|
|
8
19
|
}
|
|
9
|
-
return (<SvgUniversal
|
|
20
|
+
return (<SvgUniversal {...buttonIconStyles.icon} source={Icon} testID='Button_Icon'/>);
|
|
10
21
|
};
|
|
11
22
|
export const ButtonIcon = genericMemo(ButtonIconComponent);
|
|
23
|
+
const buttonIconStyles = StyleSheet.create(({ theme, typography }) => ({
|
|
24
|
+
icon: {
|
|
25
|
+
variants: {
|
|
26
|
+
size: {
|
|
27
|
+
xlarge: {
|
|
28
|
+
height: typography.Size['text-2xl'],
|
|
29
|
+
width: typography.Size['text-2xl'],
|
|
30
|
+
},
|
|
31
|
+
large: {
|
|
32
|
+
height: typography.Size['text-2xl'],
|
|
33
|
+
width: typography.Size['text-2xl'],
|
|
34
|
+
},
|
|
35
|
+
base: {
|
|
36
|
+
height: typography.Size['text-xl'],
|
|
37
|
+
width: typography.Size['text-xl'],
|
|
38
|
+
},
|
|
39
|
+
small: {
|
|
40
|
+
height: typography.Size['text-base'],
|
|
41
|
+
width: typography.Size['text-base'],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
variant: {
|
|
45
|
+
primary: { color: theme.Button.Brand.buttonTextColor },
|
|
46
|
+
secondary: { color: theme.Button.Primary.secondaryButtonTextColor },
|
|
47
|
+
tertiary: { color: theme.Button.Secondary.helpButtonTextColor },
|
|
48
|
+
text: { color: theme.Button.Text.textButtonTextColor },
|
|
49
|
+
link: { color: theme.Button.Text.textButtonTextColor },
|
|
50
|
+
basic: { color: theme.Button.Brand.buttonTextColor },
|
|
51
|
+
outlined: { color: theme.Button.Brand.buttonTextColor },
|
|
52
|
+
},
|
|
53
|
+
severity: { info: {}, success: {}, warning: {}, danger: {} },
|
|
54
|
+
pressed: { true: {}, false: {} },
|
|
55
|
+
disabled: {
|
|
56
|
+
true: { color: theme.Button.Disabled.disabledButtonTextColor },
|
|
57
|
+
false: {},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
compoundVariants: [
|
|
61
|
+
// link pressed
|
|
62
|
+
{
|
|
63
|
+
variant: 'link',
|
|
64
|
+
pressed: 'true',
|
|
65
|
+
styles: { color: typography.Color.Common['text-color-secondary'] },
|
|
66
|
+
},
|
|
67
|
+
// severity icon colors
|
|
68
|
+
{
|
|
69
|
+
variant: 'basic',
|
|
70
|
+
severity: 'info',
|
|
71
|
+
styles: { color: theme.Button.Severity.Info.Basic.infoButtonTextColor },
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
variant: 'outlined',
|
|
75
|
+
severity: 'info',
|
|
76
|
+
styles: {
|
|
77
|
+
color: theme.Button.Severity.Info.Outlined.infoOutlinedButtonTextColor,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
variant: 'text',
|
|
82
|
+
severity: 'info',
|
|
83
|
+
styles: {
|
|
84
|
+
color: theme.Button.Severity.Info.Text.infoTextButtonTextColor,
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
variant: 'basic',
|
|
89
|
+
severity: 'success',
|
|
90
|
+
styles: {
|
|
91
|
+
color: theme.Button.Severity.Success.Basic.successButtonTextColor,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
variant: 'outlined',
|
|
96
|
+
severity: 'success',
|
|
97
|
+
styles: {
|
|
98
|
+
color: theme.Button.Severity.Success.Outlined
|
|
99
|
+
.successOutlinedButtonTextColor,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
variant: 'text',
|
|
104
|
+
severity: 'success',
|
|
105
|
+
styles: {
|
|
106
|
+
color: theme.Button.Severity.Success.Text.successTextButtonTextColor,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
variant: 'basic',
|
|
111
|
+
severity: 'warning',
|
|
112
|
+
styles: {
|
|
113
|
+
color: theme.Button.Severity.Warning.Basic.warningButtonTextColor,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
variant: 'outlined',
|
|
118
|
+
severity: 'warning',
|
|
119
|
+
styles: {
|
|
120
|
+
color: theme.Button.Severity.Warning.Outlined
|
|
121
|
+
.warningOutlinedButtonTextColor,
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
variant: 'text',
|
|
126
|
+
severity: 'warning',
|
|
127
|
+
styles: {
|
|
128
|
+
color: theme.Button.Severity.Warning.Text.warningTextButtonTextColor,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
variant: 'basic',
|
|
133
|
+
severity: 'danger',
|
|
134
|
+
styles: {
|
|
135
|
+
color: theme.Button.Severity.Danger.Basic.dangerButtonTextColor,
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
variant: 'outlined',
|
|
140
|
+
severity: 'danger',
|
|
141
|
+
styles: {
|
|
142
|
+
color: theme.Button.Severity.Danger.Outlined.dangerOutlinedButtonTextColor,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
variant: 'text',
|
|
147
|
+
severity: 'danger',
|
|
148
|
+
styles: {
|
|
149
|
+
color: theme.Button.Severity.Danger.Text.dangerTextButtonTextColor,
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
},
|
|
154
|
+
}));
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type { BaseButtonProps,
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import type { BaseButtonProps, ButtonSize } from '../types';
|
|
2
|
+
export interface ButtonLabelProps {
|
|
3
|
+
readonly iconOnly?: BaseButtonProps<never>['iconOnly'];
|
|
4
|
+
readonly label?: string;
|
|
5
|
+
readonly size: ButtonSize;
|
|
6
|
+
readonly disabled: boolean;
|
|
7
|
+
readonly loading: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare const ButtonLabel: ({ label, iconOnly, size, disabled, loading, }: ButtonLabelProps) => import("react").JSX.Element | null;
|