@hero-design/rn 8.105.4 → 8.106.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.
Files changed (54) hide show
  1. package/.turbo/turbo-build.log +3 -3
  2. package/CHANGELOG.md +18 -0
  3. package/es/index.js +2797 -2453
  4. package/lib/index.js +2800 -2456
  5. package/package.json +2 -2
  6. package/src/components/Button/Button.tsx +70 -44
  7. package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +12 -33
  8. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +4 -4
  9. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +12 -12
  10. package/src/components/Button/LoadingIndicator/index.tsx +4 -1
  11. package/src/components/Button/StyledButton.tsx +461 -313
  12. package/src/components/Button/__tests__/__snapshots__/Button.spec.tsx.snap +102 -86
  13. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +19 -18
  14. package/src/components/Chart/Line/__tests__/__snapshots__/index.spec.tsx.snap +2 -2
  15. package/src/components/Checkbox/{index.tsx → DefaultCheckBox.tsx} +6 -31
  16. package/src/components/Checkbox/InlineCheckBox.tsx +97 -0
  17. package/src/components/Checkbox/{StyledCheckbox.tsx → StyledDefaultCheckBox.tsx} +1 -0
  18. package/src/components/Checkbox/StyledInlineCheckBox.tsx +49 -0
  19. package/src/components/Checkbox/__tests__/{index.spec.tsx → DefaultCheckBox.spec.tsx} +21 -20
  20. package/src/components/Checkbox/__tests__/InlineCheckBox.spec.tsx +93 -0
  21. package/src/components/Checkbox/__tests__/{StyledCheckbox.spec.tsx → StyledDefaultCheckbox.spec.tsx} +2 -2
  22. package/src/components/Checkbox/__tests__/__snapshots__/{index.spec.tsx.snap → DefaultCheckBox.spec.tsx.snap} +6 -0
  23. package/src/components/Checkbox/__tests__/__snapshots__/InlineCheckBox.spec.tsx.snap +988 -0
  24. package/src/components/Checkbox/__tests__/__snapshots__/{StyledCheckbox.spec.tsx.snap → StyledDefaultCheckbox.spec.tsx.snap} +4 -0
  25. package/src/components/Checkbox/__tests__/utils.spec.ts +20 -0
  26. package/src/components/Checkbox/index.ts +9 -0
  27. package/src/components/Checkbox/utils.ts +25 -0
  28. package/src/components/DatePicker/__tests__/__snapshots__/DatePickerIOS.spec.tsx.snap +2 -2
  29. package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +11 -8
  30. package/src/components/Drawer/__tests__/index.spec.tsx +15 -1
  31. package/src/components/Drawer/index.tsx +5 -2
  32. package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +5 -5
  33. package/src/components/TimePicker/__tests__/__snapshots__/TimePickerIOS.spec.tsx.snap +1 -1
  34. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +59 -19
  35. package/src/theme/components/button.ts +52 -19
  36. package/src/theme/components/checkbox.ts +7 -0
  37. package/src/theme/components/drawer.ts +1 -1
  38. package/src/utils/__tests__/helpers.spec.ts +37 -1
  39. package/src/utils/helpers.ts +14 -0
  40. package/stats/8.106.0/rn-stats.html +4844 -0
  41. package/types/components/Button/Button.d.ts +5 -4
  42. package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +3 -4
  43. package/types/components/Button/LoadingIndicator/index.d.ts +1 -1
  44. package/types/components/Button/StyledButton.d.ts +8 -4
  45. package/types/components/Checkbox/DefaultCheckBox.d.ts +40 -0
  46. package/types/components/Checkbox/InlineCheckBox.d.ts +38 -0
  47. package/types/components/Checkbox/StyledInlineCheckBox.d.ts +45 -0
  48. package/types/components/Checkbox/index.d.ts +5 -45
  49. package/types/components/Checkbox/utils.d.ts +6 -0
  50. package/types/theme/components/button.d.ts +49 -15
  51. package/types/theme/components/checkbox.d.ts +6 -0
  52. package/types/theme/components/drawer.d.ts +1 -1
  53. package/types/utils/helpers.d.ts +2 -0
  54. /package/types/components/Checkbox/{StyledCheckbox.d.ts → StyledDefaultCheckBox.d.ts} +0 -0
@@ -5,162 +5,290 @@ import { TouchableHighlight, View } from 'react-native';
5
5
  import { scale } from '../../utils/scale';
6
6
  import Icon from '../Icon';
7
7
  import Typography from '../Typography';
8
+ import {
9
+ transformKebabCaseToCamelCase,
10
+ type CamelCase,
11
+ } from '../../utils/helpers';
8
12
 
9
- type Intent = 'primary' | 'secondary' | 'danger' | 'white';
13
+ type Intent = 'primary' | 'secondary' | 'danger' | 'white' | 'inverted';
10
14
 
11
15
  type ThemeVariant =
12
16
  | 'filled-primary'
13
17
  | 'filled-secondary'
14
18
  | 'filled-danger'
15
19
  | 'filled-white'
20
+ | 'filled-inverted'
16
21
  | 'outlined-primary'
17
22
  | 'outlined-secondary'
18
23
  | 'outlined-danger'
19
24
  | 'outlined-white'
25
+ | 'outlined-inverted'
20
26
  | 'text-primary'
21
27
  | 'text-secondary'
22
28
  | 'text-danger'
23
- | 'text-white';
24
-
25
- const getButtonHeight = (themeIsCompact: boolean) => {
26
- switch (themeIsCompact) {
27
- case true:
28
- return scale(36);
29
- default:
30
- return scale(60);
29
+ | 'text-white'
30
+ | 'text-inverted';
31
+
32
+ const getButtonSize = (themeIsCompact: boolean, themeIsMedium?: boolean) => {
33
+ if (themeIsCompact) return scale(36);
34
+
35
+ if (themeIsMedium) return scale(48);
36
+
37
+ return scale(60);
38
+ };
39
+
40
+ const getTextButtonPaddingVertical = (
41
+ theme: Theme,
42
+ themeInlineText: boolean,
43
+ themeIsCompact: boolean
44
+ ) => {
45
+ if (themeInlineText) {
46
+ return 0;
47
+ }
48
+ if (themeIsCompact) {
49
+ return theme.__hd__.button.space.compact.buttonPaddingVertical;
50
+ }
51
+ return theme.__hd__.button.space.default.textButtonPadding;
52
+ };
53
+
54
+ const getTextButtonPaddingHorizontal = (
55
+ theme: Theme,
56
+ themeInlineText: boolean,
57
+ themeIsCompact: boolean
58
+ ) => {
59
+ if (themeInlineText) {
60
+ return 0;
61
+ }
62
+ if (themeIsCompact) {
63
+ return theme.__hd__.button.space.compact.buttonPaddingHorizontal;
31
64
  }
65
+ return theme.__hd__.button.space.default.textButtonPadding;
66
+ };
67
+
68
+ const genDisabledStyles = (disabled: boolean, loading: boolean) => {
69
+ if (!disabled || loading) return;
70
+
71
+ return { opacity: 0.25 };
32
72
  };
33
73
 
34
74
  const genFilledContainerStyles = (
35
75
  theme: Theme,
36
- intent: Intent,
37
- disabled: boolean,
76
+ intent: Capitalize<Intent>,
38
77
  loading: boolean,
39
- compact: boolean
78
+ compact: boolean,
79
+ medium: boolean,
80
+ iconOnly: boolean
40
81
  ): ReactNativeStyle => {
41
82
  const backgroundColorStyling = () => {
42
- if (!loading && disabled) {
83
+ const colorKey = `filled${intent}` as const;
84
+ if (loading) {
85
+ return {
86
+ backgroundColor: theme.__hd__.button.colors.pressedBackground[colorKey],
87
+ };
88
+ }
89
+
90
+ return {
91
+ backgroundColor: theme.__hd__.button.colors.background[colorKey],
92
+ };
93
+ };
94
+
95
+ const paddingStyling = (): ReactNativeStyle => {
96
+ if (iconOnly)
97
+ return {
98
+ alignSelf: 'flex-start',
99
+ width: getButtonSize(compact, medium),
100
+ borderRadius: theme.__hd__.button.radii.rounded,
101
+ };
102
+
103
+ if (compact)
43
104
  return {
44
- backgroundColor: theme.__hd__.button.colors.disabledBorder,
105
+ alignSelf: 'flex-start',
106
+ paddingVertical:
107
+ theme.__hd__.button.space.compact.buttonPaddingVertical,
108
+ paddingHorizontal: theme.__hd__.button.space.default.buttonPadding,
109
+ borderRadius: theme.__hd__.button.radii.default,
110
+ };
111
+
112
+ if (medium) {
113
+ return {
114
+ alignSelf: 'flex-start',
115
+ borderRadius: theme.__hd__.button.radii.default,
116
+ paddingHorizontal: theme.__hd__.button.space.medium.buttonPadding,
45
117
  };
46
118
  }
47
119
 
48
- return { backgroundColor: theme.__hd__.button.colors[intent] };
120
+ return {
121
+ alignSelf: 'stretch',
122
+ padding: theme.__hd__.button.space.default.buttonPadding,
123
+ borderRadius: theme.__hd__.button.radii.default,
124
+ };
49
125
  };
50
126
 
51
127
  return {
52
- height: getButtonHeight(compact),
128
+ height: getButtonSize(compact, medium),
53
129
  flexDirection: 'row',
54
130
  justifyContent: 'center',
55
131
  alignItems: 'center',
56
- ...(compact
57
- ? {
58
- alignSelf: 'flex-start',
59
- paddingVertical:
60
- theme.__hd__.button.space.compact.buttonPaddingVertical,
61
- paddingHorizontal: theme.__hd__.button.space.default.buttonPadding,
62
- }
63
- : {
64
- alignSelf: 'stretch',
65
- padding: theme.__hd__.button.space.default.buttonPadding,
66
- }),
67
- borderRadius: theme.__hd__.button.radii.default,
132
+ ...paddingStyling(),
68
133
  ...backgroundColorStyling(),
69
134
  };
70
135
  };
71
136
 
72
137
  const genOutlineContainerStyles = (
73
138
  theme: Theme,
74
- intent: Intent,
75
- disabled: boolean,
139
+ intent: Capitalize<Intent>,
76
140
  loading: boolean,
77
- compact: boolean
141
+ compact: boolean,
142
+ medium: boolean,
143
+ iconOnly: boolean
78
144
  ): ReactNativeStyle => {
79
145
  const borderColorStyling = () => {
80
- if (!loading && disabled) {
146
+ const colorKey = `outlined${intent}` as const;
147
+ if (loading) {
148
+ return {
149
+ borderColor: theme.__hd__.button.colors.border[colorKey],
150
+ backgroundColor: theme.__hd__.button.colors.pressedBackground[colorKey],
151
+ };
152
+ }
153
+
154
+ return { borderColor: theme.__hd__.button.colors.border[colorKey] };
155
+ };
156
+
157
+ const paddingStyling = (): ReactNativeStyle => {
158
+ if (iconOnly)
159
+ return {
160
+ alignSelf: 'flex-start',
161
+ width: getButtonSize(compact, medium),
162
+ borderRadius: theme.__hd__.button.radii.rounded,
163
+ };
164
+
165
+ if (compact)
166
+ return {
167
+ alignSelf: 'flex-start',
168
+ paddingVertical:
169
+ theme.__hd__.button.space.compact.buttonPaddingVertical -
170
+ theme.__hd__.button.borderWidth.default,
171
+ paddingHorizontal:
172
+ theme.__hd__.button.space.default.buttonPadding -
173
+ theme.__hd__.button.borderWidth.default,
174
+ borderRadius: theme.__hd__.button.radii.default,
175
+ };
176
+
177
+ if (medium) {
81
178
  return {
82
- borderColor: theme.__hd__.button.colors.disabledBorder,
179
+ alignSelf: 'flex-start',
180
+ borderRadius: theme.__hd__.button.radii.default,
181
+ paddingHorizontal:
182
+ theme.__hd__.button.space.medium.buttonPaddingHorizontal -
183
+ theme.__hd__.button.borderWidth.default,
83
184
  };
84
185
  }
85
186
 
86
- return { borderColor: theme.__hd__.button.colors[intent] };
187
+ return {
188
+ alignSelf: 'stretch',
189
+ padding:
190
+ theme.__hd__.button.space.default.buttonPadding -
191
+ theme.__hd__.button.borderWidth.default,
192
+ borderRadius: theme.__hd__.button.radii.default,
193
+ };
87
194
  };
88
195
 
89
196
  return {
90
- height: getButtonHeight(compact),
197
+ height: getButtonSize(compact, medium),
91
198
  flexDirection: 'row',
92
199
  justifyContent: 'center',
93
200
  alignItems: 'center',
94
- ...(compact
95
- ? {
96
- alignSelf: 'flex-start',
97
- paddingVertical:
98
- theme.__hd__.button.space.compact.buttonPaddingVertical -
99
- theme.__hd__.button.borderWidth.default,
100
- paddingHorizontal:
101
- theme.__hd__.button.space.default.buttonPadding -
102
- theme.__hd__.button.borderWidth.default,
103
- }
104
- : {
105
- alignSelf: 'stretch',
106
- padding:
107
- theme.__hd__.button.space.default.buttonPadding -
108
- theme.__hd__.button.borderWidth.default,
109
- }),
201
+ ...paddingStyling(),
110
202
  borderWidth: theme.__hd__.button.borderWidth.default,
111
- borderRadius: theme.__hd__.button.radii.default,
112
203
  backgroundColor: 'transparent',
113
204
  ...borderColorStyling(),
114
205
  };
115
206
  };
116
207
 
117
- const getTextButtonPaddingVertical = (
208
+ const getTextContainerStyles = (
118
209
  theme: Theme,
119
- themeInlineText: boolean,
120
- themeIsCompact: boolean
121
- ) => {
122
- if (themeInlineText) {
123
- return 0;
124
- }
125
- if (themeIsCompact) {
126
- return theme.__hd__.button.space.compact.buttonPaddingVertical;
127
- }
128
- return theme.__hd__.button.space.default.textButtonPadding;
129
- };
210
+ intent: Capitalize<Intent>,
211
+ loading: boolean,
212
+ inlineText: boolean,
213
+ compact: boolean,
214
+ medium: boolean,
215
+ iconOnly: boolean
216
+ ): ReactNativeStyle => {
217
+ const colorKey = `text${intent}` as const;
130
218
 
131
- const getTextButtonPaddingHorizontal = (
132
- theme: Theme,
133
- themeInlineText: boolean,
134
- themeIsCompact: boolean
135
- ) => {
136
- if (themeInlineText) {
137
- return 0;
138
- }
139
- if (themeIsCompact) {
140
- return theme.__hd__.button.space.compact.buttonPaddingHorizontal;
141
- }
142
- return theme.__hd__.button.space.default.textButtonPadding;
219
+ const paddingStyles = (): ReactNativeStyle => {
220
+ if (iconOnly) {
221
+ return {
222
+ alignSelf: 'flex-start',
223
+ borderRadius: theme.__hd__.button.radii.rounded,
224
+ width: inlineText ? undefined : getButtonSize(compact, medium),
225
+ };
226
+ }
227
+
228
+ if (compact) {
229
+ return {
230
+ alignSelf: 'flex-start',
231
+ paddingVertical: getTextButtonPaddingVertical(
232
+ theme,
233
+ inlineText,
234
+ compact
235
+ ),
236
+ paddingHorizontal: getTextButtonPaddingHorizontal(
237
+ theme,
238
+ inlineText,
239
+ compact
240
+ ),
241
+ };
242
+ }
243
+
244
+ if (medium) {
245
+ return {
246
+ alignSelf: 'flex-start',
247
+ paddingHorizontal: inlineText
248
+ ? 0
249
+ : theme.__hd__.button.space.medium.textButtonPadding,
250
+ };
251
+ }
252
+
253
+ return {
254
+ padding: inlineText
255
+ ? 0
256
+ : theme.__hd__.button.space.default.textButtonPadding,
257
+ };
258
+ };
259
+
260
+ return {
261
+ height: inlineText ? undefined : getButtonSize(compact, medium),
262
+ borderRadius: theme.__hd__.button.radii.rounded,
263
+ flexDirection: 'row',
264
+ justifyContent: 'center',
265
+ alignItems: 'center',
266
+ backgroundColor:
267
+ !inlineText && loading
268
+ ? theme.__hd__.button.colors.pressedBackground[colorKey]
269
+ : 'transparent',
270
+ borderWidth: 0,
271
+ ...paddingStyles(),
272
+ };
143
273
  };
144
274
 
145
275
  const genTextStyles = (
146
276
  theme: Theme,
147
- intent: Intent,
148
- disabled?: boolean,
277
+ themeButtonVariant: CamelCase<ThemeVariant>,
278
+ intent?: Capitalize<Intent>,
149
279
  isPressed?: boolean
150
280
  ): ReactNativeStyle => {
151
- if (disabled) {
152
- return {
153
- color: theme.__hd__.button.colors.disabledText,
154
- };
155
- }
281
+ if (isPressed && intent) {
282
+ const colorKey = `inlineText${intent}` as const;
156
283
 
157
- if (isPressed) {
158
284
  return {
159
- color: theme.__hd__.button.colors.pressedText[intent],
285
+ color: theme.__hd__.button.colors.pressedText[colorKey],
160
286
  };
161
287
  }
162
288
 
163
- return { color: theme.__hd__.button.colors[intent] };
289
+ return {
290
+ color: theme.__hd__.button.colors.text[themeButtonVariant],
291
+ };
164
292
  };
165
293
 
166
294
  const StyledButtonContainer = styled(TouchableHighlight)<{
@@ -169,6 +297,8 @@ const StyledButtonContainer = styled(TouchableHighlight)<{
169
297
  loading?: boolean;
170
298
  themeInlineText?: boolean;
171
299
  themeIsCompact?: boolean;
300
+ themeIsMedium?: boolean;
301
+ themeIsIconOnly?: boolean;
172
302
  }>(
173
303
  ({
174
304
  disabled = false,
@@ -177,187 +307,209 @@ const StyledButtonContainer = styled(TouchableHighlight)<{
177
307
  themeInlineText = false,
178
308
  theme,
179
309
  themeIsCompact = false,
310
+ themeIsMedium = false,
311
+ themeIsIconOnly = false,
180
312
  }) => {
181
313
  switch (themeButtonVariant) {
182
314
  case 'filled-primary':
183
- return genFilledContainerStyles(
184
- theme,
185
- 'primary',
186
- disabled,
187
- loading,
188
- themeIsCompact
189
- );
315
+ return {
316
+ ...genFilledContainerStyles(
317
+ theme,
318
+ 'Primary',
319
+ loading,
320
+ themeIsCompact,
321
+ themeIsMedium,
322
+ themeIsIconOnly
323
+ ),
324
+ ...genDisabledStyles(disabled, loading),
325
+ };
190
326
  case 'filled-secondary':
191
- return genFilledContainerStyles(
192
- theme,
193
- 'secondary',
194
- disabled,
195
- loading,
196
- themeIsCompact
197
- );
327
+ return {
328
+ ...genFilledContainerStyles(
329
+ theme,
330
+ 'Secondary',
331
+ loading,
332
+ themeIsCompact,
333
+ themeIsMedium,
334
+ themeIsIconOnly
335
+ ),
336
+ ...genDisabledStyles(disabled, loading),
337
+ };
198
338
  case 'filled-danger':
199
- return genFilledContainerStyles(
200
- theme,
201
- 'danger',
202
- disabled,
203
- loading,
204
- themeIsCompact
205
- );
339
+ return {
340
+ ...genFilledContainerStyles(
341
+ theme,
342
+ 'Danger',
343
+ loading,
344
+ themeIsCompact,
345
+ themeIsMedium,
346
+ themeIsIconOnly
347
+ ),
348
+ ...genDisabledStyles(disabled, loading),
349
+ };
206
350
  case 'filled-white':
207
- return genFilledContainerStyles(
208
- theme,
209
- 'white',
210
- disabled,
211
- loading,
212
- themeIsCompact
213
- );
351
+ return {
352
+ ...genFilledContainerStyles(
353
+ theme,
354
+ 'White',
355
+ loading,
356
+ themeIsCompact,
357
+ themeIsMedium,
358
+ themeIsIconOnly
359
+ ),
360
+ ...genDisabledStyles(disabled, loading),
361
+ };
362
+ case 'filled-inverted':
363
+ return {
364
+ ...genFilledContainerStyles(
365
+ theme,
366
+ 'Inverted',
367
+ loading,
368
+ themeIsCompact,
369
+ themeIsMedium,
370
+ themeIsIconOnly
371
+ ),
372
+ ...genDisabledStyles(disabled, loading),
373
+ };
214
374
  case 'outlined-primary':
215
- return genOutlineContainerStyles(
216
- theme,
217
- 'primary',
218
- disabled,
219
- loading,
220
- themeIsCompact
221
- );
375
+ return {
376
+ ...genOutlineContainerStyles(
377
+ theme,
378
+ 'Primary',
379
+ loading,
380
+ themeIsCompact,
381
+ themeIsMedium,
382
+ themeIsIconOnly
383
+ ),
384
+ ...genDisabledStyles(disabled, loading),
385
+ };
222
386
  case 'outlined-secondary':
223
- return genOutlineContainerStyles(
224
- theme,
225
- 'secondary',
226
- disabled,
227
- loading,
228
- themeIsCompact
229
- );
387
+ return {
388
+ ...genOutlineContainerStyles(
389
+ theme,
390
+ 'Secondary',
391
+ loading,
392
+ themeIsCompact,
393
+ themeIsMedium,
394
+ themeIsIconOnly
395
+ ),
396
+ ...genDisabledStyles(disabled, loading),
397
+ };
230
398
  case 'outlined-danger':
231
- return genOutlineContainerStyles(
232
- theme,
233
- 'danger',
234
- disabled,
235
- loading,
236
- themeIsCompact
237
- );
399
+ return {
400
+ ...genOutlineContainerStyles(
401
+ theme,
402
+ 'Danger',
403
+ loading,
404
+ themeIsCompact,
405
+ themeIsMedium,
406
+ themeIsIconOnly
407
+ ),
408
+ ...genDisabledStyles(disabled, loading),
409
+ };
238
410
  case 'outlined-white':
239
- return genOutlineContainerStyles(
240
- theme,
241
- 'white',
242
- disabled,
243
- loading,
244
- themeIsCompact
245
- );
411
+ return {
412
+ ...genOutlineContainerStyles(
413
+ theme,
414
+ 'White',
415
+ loading,
416
+ themeIsCompact,
417
+ themeIsMedium,
418
+ themeIsIconOnly
419
+ ),
420
+ ...genDisabledStyles(disabled, loading),
421
+ };
422
+
423
+ case 'outlined-inverted':
424
+ return {
425
+ ...genOutlineContainerStyles(
426
+ theme,
427
+ 'Inverted',
428
+ loading,
429
+ themeIsCompact,
430
+ themeIsMedium,
431
+ themeIsIconOnly
432
+ ),
433
+ ...genDisabledStyles(disabled, loading),
434
+ };
246
435
  case 'text-primary':
436
+ return {
437
+ ...getTextContainerStyles(
438
+ theme,
439
+ 'Primary',
440
+ loading,
441
+ themeInlineText,
442
+ themeIsCompact,
443
+ themeIsMedium,
444
+ themeIsIconOnly
445
+ ),
446
+ ...genDisabledStyles(disabled, loading),
447
+ };
247
448
  case 'text-secondary':
449
+ return {
450
+ ...getTextContainerStyles(
451
+ theme,
452
+ 'Secondary',
453
+ loading,
454
+ themeInlineText,
455
+ themeIsCompact,
456
+ themeIsMedium,
457
+ themeIsIconOnly
458
+ ),
459
+ ...genDisabledStyles(disabled, loading),
460
+ };
248
461
  case 'text-danger':
249
- case 'text-white':
250
462
  return {
251
- height: themeInlineText ? undefined : getButtonHeight(themeIsCompact),
252
- borderRadius: theme.__hd__.button.radii.text,
253
- flexDirection: 'row',
254
- justifyContent: 'center',
255
- alignItems: 'center',
256
- ...(themeIsCompact
257
- ? {
258
- alignSelf: 'flex-start',
259
- paddingVertical: getTextButtonPaddingVertical(
260
- theme,
261
- themeInlineText,
262
- themeIsCompact
263
- ),
264
- paddingHorizontal: getTextButtonPaddingHorizontal(
265
- theme,
266
- themeInlineText,
267
- themeIsCompact
268
- ),
269
- }
270
- : {
271
- padding: themeInlineText
272
- ? 0
273
- : theme.__hd__.button.space.default.textButtonPadding,
274
- }),
275
-
276
- borderWidth: 0,
277
- backgroundColor:
278
- loading && !themeInlineText && themeButtonVariant !== 'text-white'
279
- ? theme.__hd__.button.colors.textLoadingBackground
280
- : 'transparent',
463
+ ...getTextContainerStyles(
464
+ theme,
465
+ 'Danger',
466
+ loading,
467
+ themeInlineText,
468
+ themeIsCompact,
469
+ themeIsMedium,
470
+ themeIsIconOnly
471
+ ),
472
+ ...genDisabledStyles(disabled, loading),
281
473
  };
282
- }
283
- }
284
- );
285
-
286
- const genWhiteTextStyles = ({
287
- variant,
288
- disabled,
289
- theme,
290
- }: {
291
- variant: ThemeVariant;
292
- disabled?: boolean;
293
- theme: Theme;
294
- }) => {
295
- if (disabled) {
296
- switch (variant) {
297
- case 'filled-white': {
474
+ case 'text-white':
298
475
  return {
299
- color: theme.__hd__.button.colors.invertedText,
476
+ ...getTextContainerStyles(
477
+ theme,
478
+ 'White',
479
+ loading,
480
+ themeInlineText,
481
+ themeIsCompact,
482
+ themeIsMedium,
483
+ themeIsIconOnly
484
+ ),
485
+ ...genDisabledStyles(disabled, loading),
300
486
  };
301
- }
302
- case 'outlined-white':
303
- case 'text-white': {
487
+ case 'text-inverted':
304
488
  return {
305
- color: theme.__hd__.button.colors.disabledText,
489
+ ...getTextContainerStyles(
490
+ theme,
491
+ 'Inverted',
492
+ loading,
493
+ themeInlineText,
494
+ themeIsCompact,
495
+ themeIsMedium,
496
+ themeIsIconOnly
497
+ ),
498
+ ...genDisabledStyles(disabled, loading),
306
499
  };
307
- }
308
500
  }
309
501
  }
310
-
311
- switch (variant) {
312
- case 'filled-white': {
313
- return {
314
- color: theme.__hd__.button.colors.primary,
315
- };
316
- }
317
-
318
- case 'outlined-white':
319
- case 'text-white': {
320
- return {
321
- color: theme.__hd__.button.colors.invertedText,
322
- };
323
- }
324
- }
325
- };
502
+ );
326
503
 
327
504
  const StyledButtonText = styled(Typography.Title)<{
328
505
  disabled?: boolean;
329
506
  themeButtonVariant: ThemeVariant;
330
- }>(({ disabled, themeButtonVariant, theme }) => {
507
+ }>(({ themeButtonVariant, theme }) => {
331
508
  const themeStyling = () => {
332
- switch (themeButtonVariant) {
333
- case 'filled-primary':
334
- case 'filled-secondary':
335
- case 'filled-danger':
336
- return {
337
- color: theme.__hd__.button.colors.invertedText,
338
- };
339
- case 'outlined-primary':
340
- return genTextStyles(theme, 'primary', disabled);
341
- case 'outlined-secondary':
342
- return genTextStyles(theme, 'secondary', disabled);
343
- case 'outlined-danger':
344
- return genTextStyles(theme, 'danger', disabled);
509
+ const camelCaseThemeVariant =
510
+ transformKebabCaseToCamelCase(themeButtonVariant);
345
511
 
346
- case 'text-primary':
347
- return genTextStyles(theme, 'primary', disabled);
348
- case 'text-secondary':
349
- return genTextStyles(theme, 'secondary', disabled);
350
- case 'text-danger':
351
- return genTextStyles(theme, 'danger', disabled);
352
- case 'filled-white':
353
- case 'outlined-white':
354
- case 'text-white':
355
- return genWhiteTextStyles({
356
- variant: themeButtonVariant,
357
- disabled,
358
- theme,
359
- });
360
- }
512
+ return genTextStyles(theme, camelCaseThemeVariant);
361
513
  };
362
514
  return {
363
515
  flexShrink: 1,
@@ -380,44 +532,46 @@ const StyledButtonTitleOfVariantText = styled(Typography.Body)<{
380
532
  | 'text-primary'
381
533
  | 'text-secondary'
382
534
  | 'text-danger'
383
- | 'text-white';
535
+ | 'text-white'
536
+ | 'text-inverted';
384
537
  themeIsPressed?: boolean;
385
538
  themeIsCompact: boolean;
386
- }>(
387
- ({ disabled, themeButtonVariant, themeIsPressed, theme, themeIsCompact }) => {
388
- const themeStyling = () => {
389
- switch (themeButtonVariant) {
390
- case 'text-primary':
391
- return genTextStyles(theme, 'primary', disabled, themeIsPressed);
392
- case 'text-secondary':
393
- return genTextStyles(theme, 'secondary', disabled, themeIsPressed);
394
- case 'text-danger':
395
- return genTextStyles(theme, 'danger', disabled, themeIsPressed);
396
- case 'text-white':
397
- return genWhiteTextStyles({
398
- variant: 'text-white',
399
- disabled,
400
- theme,
401
- });
402
- }
403
- };
404
- return {
405
- flexShrink: 1,
406
- lineHeight:
407
- theme.__hd__.button.lineHeights.titleOfTextVariant[
408
- themeIsCompact ? 'compact' : 'default'
409
- ],
410
- textAlign: 'center',
411
- textAlignVertical: 'center',
412
- ...themeStyling(),
413
- };
414
- }
415
- );
539
+ }>(({ themeButtonVariant, themeIsPressed, theme, themeIsCompact }) => {
540
+ const themeStyling = () => {
541
+ const themeVariant = transformKebabCaseToCamelCase(themeButtonVariant);
542
+ switch (themeButtonVariant) {
543
+ case 'text-primary':
544
+ return genTextStyles(theme, themeVariant, 'Primary', themeIsPressed);
545
+ case 'text-secondary':
546
+ return genTextStyles(theme, themeVariant, 'Secondary', themeIsPressed);
547
+ case 'text-danger':
548
+ return genTextStyles(theme, themeVariant, 'Danger', themeIsPressed);
549
+ case 'text-white':
550
+ return genTextStyles(theme, themeVariant, 'White', themeIsPressed);
551
+ case 'text-inverted':
552
+ return genTextStyles(theme, themeVariant, 'Inverted', themeIsPressed);
553
+ }
554
+ };
555
+
556
+ return {
557
+ flexShrink: 1,
558
+ lineHeight:
559
+ theme.__hd__.button.lineHeights.titleOfTextVariant[
560
+ themeIsCompact ? 'compact' : 'default'
561
+ ],
562
+ textAlign: 'center',
563
+ textAlignVertical: 'center',
564
+ ...themeStyling(),
565
+ };
566
+ });
416
567
 
417
568
  const StyledButtonIconWrapper = styled(View)<{
418
569
  themePosition: 'left' | 'right';
419
570
  themeIsCompact?: boolean;
420
- }>(({ themePosition, theme, themeIsCompact }) => {
571
+ themeIsIconOnly?: boolean;
572
+ }>(({ themePosition, theme, themeIsCompact, themeIsIconOnly }) => {
573
+ if (themeIsIconOnly) return {};
574
+
421
575
  switch (themePosition) {
422
576
  case 'left':
423
577
  return {
@@ -439,47 +593,41 @@ const StyledButtonIcon = styled(Icon)<{
439
593
  themeButtonVariant: ThemeVariant;
440
594
  themeIsPressed?: boolean;
441
595
  themeIsCompact?: boolean;
442
- }>(
443
- ({ disabled, themeButtonVariant, themeIsPressed, theme, themeIsCompact }) => {
444
- const themeStyling = () => {
445
- switch (themeButtonVariant) {
446
- case 'filled-primary':
447
- case 'filled-secondary':
448
- case 'filled-danger':
449
- return {
450
- color: theme.__hd__.button.colors.invertedText,
451
- };
452
- case 'outlined-primary':
453
- return genTextStyles(theme, 'primary', disabled);
454
- case 'outlined-secondary':
455
- return genTextStyles(theme, 'secondary', disabled);
456
- case 'outlined-danger':
457
- return genTextStyles(theme, 'danger', disabled);
458
- case 'text-primary':
459
- return genTextStyles(theme, 'primary', disabled, themeIsPressed);
460
- case 'text-secondary':
461
- return genTextStyles(theme, 'secondary', disabled, themeIsPressed);
462
- case 'text-danger':
463
- return genTextStyles(theme, 'danger', disabled, themeIsPressed);
464
- case 'filled-white':
465
- case 'outlined-white':
466
- case 'text-white':
467
- return genWhiteTextStyles({
468
- variant: themeButtonVariant,
469
- disabled,
470
- theme,
471
- });
472
- }
473
- };
596
+ }>(({ themeButtonVariant, themeIsPressed, theme, themeIsCompact }) => {
597
+ const themeStyling = () => {
598
+ const themeVariant = transformKebabCaseToCamelCase(themeButtonVariant);
474
599
 
475
- return {
476
- fontSize: themeIsCompact
477
- ? theme.__hd__.button.sizes.iconSize.compact
478
- : theme.__hd__.button.sizes.iconSize.default,
479
- ...themeStyling(),
480
- };
481
- }
482
- );
600
+ switch (themeButtonVariant) {
601
+ case 'filled-primary':
602
+ case 'outlined-primary':
603
+ case 'text-primary':
604
+ return genTextStyles(theme, themeVariant, 'Primary', themeIsPressed);
605
+ case 'filled-secondary':
606
+ case 'outlined-secondary':
607
+ case 'text-secondary':
608
+ return genTextStyles(theme, themeVariant, 'Secondary', themeIsPressed);
609
+ case 'filled-danger':
610
+ case 'outlined-danger':
611
+ case 'text-danger':
612
+ return genTextStyles(theme, themeVariant, 'Danger', themeIsPressed);
613
+ case 'filled-white':
614
+ case 'outlined-white':
615
+ case 'text-white':
616
+ return genTextStyles(theme, themeVariant, 'White', themeIsPressed);
617
+ case 'filled-inverted':
618
+ case 'outlined-inverted':
619
+ case 'text-inverted':
620
+ return genTextStyles(theme, themeVariant, 'Inverted', themeIsPressed);
621
+ }
622
+ };
623
+
624
+ return {
625
+ fontSize: themeIsCompact
626
+ ? theme.__hd__.button.sizes.iconSize.compact
627
+ : theme.__hd__.button.sizes.iconSize.default,
628
+ ...themeStyling(),
629
+ };
630
+ });
483
631
 
484
632
  export {
485
633
  StyledButtonContainer,
@@ -489,4 +637,4 @@ export {
489
637
  StyledButtonTitleOfVariantText,
490
638
  StyledSmallButtonText,
491
639
  };
492
- export type { Intent, ThemeVariant };
640
+ export type { Intent, ThemeVariant, CamelCase };