@hero-design/rn 8.0.0-4 → 8.0.0-5
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/.turbo/turbo-build.log +9 -9
- package/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/es/index.js +378 -552
- package/lib/assets/fonts/hero-icons-mobile.ttf +0 -0
- package/lib/index.js +378 -552
- package/package.json +5 -5
- package/src/components/Alert/StyledAlert.tsx +2 -3
- package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +6 -12
- package/src/components/Alert/index.tsx +3 -23
- package/src/components/Box/__tests__/__snapshots__/index.spec.tsx.snap +4 -26
- package/src/components/Button/Button.tsx +7 -16
- package/src/components/Button/StyledButton.tsx +0 -46
- package/src/components/Button/__tests__/Button.spec.tsx +10 -11
- package/src/components/Button/__tests__/StyledButton.spec.tsx +0 -3
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +0 -91
- package/src/components/Card/StyledCard.tsx +2 -11
- package/src/components/Card/__tests__/StyledCard.spec.tsx +2 -14
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +0 -32
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +0 -4
- package/src/components/Card/__tests__/index.spec.tsx +1 -13
- package/src/components/Card/index.tsx +5 -26
- package/src/components/Icon/HeroIcon/glyphMap.json +1 -1
- package/src/components/Icon/IconList.ts +0 -8
- package/src/components/List/__tests__/__snapshots__/ListItem.spec.tsx.snap +5 -7
- package/src/components/Select/MultiSelect/index.tsx +1 -20
- package/src/components/Select/SingleSelect/index.tsx +5 -24
- package/src/components/Select/types.ts +1 -11
- package/src/components/Switch/StyledSwitch.tsx +7 -12
- package/src/components/Switch/__tests__/StyledSwitch.spec.tsx +2 -2
- package/src/components/Switch/__tests__/__snapshots__/StyledSwitch.spec.tsx.snap +10 -15
- package/src/components/Switch/__tests__/__snapshots__/index.spec.tsx.snap +8 -12
- package/src/components/Switch/index.tsx +6 -22
- package/src/components/Tabs/ScrollableTabs.tsx +1 -6
- package/src/components/Tabs/TabWithBadge.tsx +1 -15
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +3 -1
- package/src/components/Tabs/__tests__/TabWithBadge.spec.tsx +4 -1
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +4 -3
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +2 -32
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +1 -2
- package/src/components/Tabs/__tests__/index.spec.tsx +3 -1
- package/src/components/Tabs/index.tsx +12 -24
- package/src/components/Tag/StyledTag.tsx +0 -1
- package/src/components/Tag/__tests__/Tag.spec.tsx +0 -9
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +0 -40
- package/src/components/Tag/index.tsx +3 -16
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +4 -63
- package/src/theme/components/switch.ts +4 -14
- package/src/theme/components/tag.ts +0 -2
- package/src/theme/global/colors/swag.ts +1 -20
- package/src/theme/global/colors/types.ts +1 -58
- package/src/utils/hooks.ts +1 -1
- package/types/components/Alert/StyledAlert.d.ts +0 -1
- package/types/components/Alert/index.d.ts +1 -6
- package/types/components/Button/Button.d.ts +2 -3
- package/types/components/Button/StyledButton.d.ts +1 -1
- package/types/components/Card/StyledCard.d.ts +1 -8
- package/types/components/Card/index.d.ts +2 -8
- package/types/components/Icon/IconList.d.ts +1 -1
- package/types/components/Icon/index.d.ts +1 -1
- package/types/components/Icon/utils.d.ts +1 -1
- package/types/components/Select/MultiSelect/index.d.ts +1 -1
- package/types/components/Select/SingleSelect/index.d.ts +1 -1
- package/types/components/Select/index.d.ts +1 -1
- package/types/components/Select/types.d.ts +1 -11
- package/types/components/Switch/StyledSwitch.d.ts +0 -4
- package/types/components/Switch/index.d.ts +1 -6
- package/types/components/Tabs/TabWithBadge.d.ts +1 -2
- package/types/components/Tabs/index.d.ts +2 -3
- package/types/components/Tag/StyledTag.d.ts +1 -1
- package/types/components/Tag/index.d.ts +2 -2
- package/types/theme/components/switch.d.ts +4 -14
- package/types/theme/components/tag.d.ts +0 -2
- package/types/theme/global/colors/types.d.ts +1 -52
- package/types/theme/global/index.d.ts +0 -47
- package/src/theme/__tests__/ensureCompatibleWithV7.spec.tsx +0 -13
- package/src/theme/global/colors/legacySystemPalette.ts +0 -53
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.0.0-
|
|
3
|
+
"version": "8.0.0-5",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.0.0-
|
|
24
|
+
"@hero-design/colors": "8.0.0-5",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.12"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@babel/preset-typescript": "^7.17.12",
|
|
45
45
|
"@babel/runtime": "^7.18.9",
|
|
46
46
|
"@emotion/jest": "^11.9.3",
|
|
47
|
-
"@hero-design/eslint-plugin": "8.0.0-
|
|
47
|
+
"@hero-design/eslint-plugin": "8.0.0-5",
|
|
48
48
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
49
49
|
"@react-native-community/slider": "4.1.12",
|
|
50
50
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"@types/react-native": "^0.67.7",
|
|
61
61
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
62
62
|
"babel-plugin-inline-import": "^3.0.0",
|
|
63
|
-
"eslint-config-hd": "8.0.0-
|
|
63
|
+
"eslint-config-hd": "8.0.0-5",
|
|
64
64
|
"jest": "^27.3.1",
|
|
65
|
-
"prettier-config-hd": "8.0.0-
|
|
65
|
+
"prettier-config-hd": "8.0.0-5",
|
|
66
66
|
"react": "17.0.2",
|
|
67
67
|
"react-native": "0.65.1",
|
|
68
68
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -4,10 +4,9 @@ import type { ComponentProps } from 'react';
|
|
|
4
4
|
import type { ViewProps } from 'react-native';
|
|
5
5
|
|
|
6
6
|
const Container = styled(View)<{
|
|
7
|
-
themeVariant: 'default' | 'round';
|
|
8
7
|
themeIntent: 'success' | 'info' | 'warning' | 'error' | 'notification';
|
|
9
|
-
}>(({ theme,
|
|
10
|
-
borderRadius:
|
|
8
|
+
}>(({ theme, themeIntent }) => ({
|
|
9
|
+
borderRadius: theme.__hd__.alert.radii.default,
|
|
11
10
|
backgroundColor: theme.__hd__.alert.colors[themeIntent],
|
|
12
11
|
minHeight: theme.__hd__.alert.sizes.height,
|
|
13
12
|
flexDirection: 'row',
|
|
@@ -6,7 +6,7 @@ exports[`Alert Icon render custom icon correctly 1`] = `
|
|
|
6
6
|
Array [
|
|
7
7
|
Object {
|
|
8
8
|
"backgroundColor": "#b5c3fd",
|
|
9
|
-
"borderRadius":
|
|
9
|
+
"borderRadius": 16,
|
|
10
10
|
"flexDirection": "row",
|
|
11
11
|
"minHeight": 48,
|
|
12
12
|
},
|
|
@@ -14,7 +14,6 @@ exports[`Alert Icon render custom icon correctly 1`] = `
|
|
|
14
14
|
]
|
|
15
15
|
}
|
|
16
16
|
themeIntent="info"
|
|
17
|
-
themeVariant="default"
|
|
18
17
|
>
|
|
19
18
|
<View
|
|
20
19
|
showDivider={false}
|
|
@@ -100,7 +99,7 @@ exports[`Alert renders correctly when intent is error 1`] = `
|
|
|
100
99
|
Array [
|
|
101
100
|
Object {
|
|
102
101
|
"backgroundColor": "#f46363",
|
|
103
|
-
"borderRadius":
|
|
102
|
+
"borderRadius": 16,
|
|
104
103
|
"flexDirection": "row",
|
|
105
104
|
"minHeight": 48,
|
|
106
105
|
},
|
|
@@ -108,7 +107,6 @@ exports[`Alert renders correctly when intent is error 1`] = `
|
|
|
108
107
|
]
|
|
109
108
|
}
|
|
110
109
|
themeIntent="error"
|
|
111
|
-
themeVariant="default"
|
|
112
110
|
>
|
|
113
111
|
<View
|
|
114
112
|
showDivider={true}
|
|
@@ -250,7 +248,7 @@ exports[`Alert renders correctly when intent is info 1`] = `
|
|
|
250
248
|
Array [
|
|
251
249
|
Object {
|
|
252
250
|
"backgroundColor": "#b5c3fd",
|
|
253
|
-
"borderRadius":
|
|
251
|
+
"borderRadius": 16,
|
|
254
252
|
"flexDirection": "row",
|
|
255
253
|
"minHeight": 48,
|
|
256
254
|
},
|
|
@@ -258,7 +256,6 @@ exports[`Alert renders correctly when intent is info 1`] = `
|
|
|
258
256
|
]
|
|
259
257
|
}
|
|
260
258
|
themeIntent="info"
|
|
261
|
-
themeVariant="default"
|
|
262
259
|
>
|
|
263
260
|
<View
|
|
264
261
|
showDivider={true}
|
|
@@ -400,7 +397,7 @@ exports[`Alert renders correctly when intent is notification 1`] = `
|
|
|
400
397
|
Array [
|
|
401
398
|
Object {
|
|
402
399
|
"backgroundColor": "#ffffff",
|
|
403
|
-
"borderRadius":
|
|
400
|
+
"borderRadius": 16,
|
|
404
401
|
"flexDirection": "row",
|
|
405
402
|
"minHeight": 48,
|
|
406
403
|
},
|
|
@@ -408,7 +405,6 @@ exports[`Alert renders correctly when intent is notification 1`] = `
|
|
|
408
405
|
]
|
|
409
406
|
}
|
|
410
407
|
themeIntent="notification"
|
|
411
|
-
themeVariant="default"
|
|
412
408
|
>
|
|
413
409
|
<View
|
|
414
410
|
showDivider={true}
|
|
@@ -523,7 +519,7 @@ exports[`Alert renders correctly when intent is success 1`] = `
|
|
|
523
519
|
Array [
|
|
524
520
|
Object {
|
|
525
521
|
"backgroundColor": "#5ace7d",
|
|
526
|
-
"borderRadius":
|
|
522
|
+
"borderRadius": 16,
|
|
527
523
|
"flexDirection": "row",
|
|
528
524
|
"minHeight": 48,
|
|
529
525
|
},
|
|
@@ -531,7 +527,6 @@ exports[`Alert renders correctly when intent is success 1`] = `
|
|
|
531
527
|
]
|
|
532
528
|
}
|
|
533
529
|
themeIntent="success"
|
|
534
|
-
themeVariant="default"
|
|
535
530
|
>
|
|
536
531
|
<View
|
|
537
532
|
showDivider={true}
|
|
@@ -673,7 +668,7 @@ exports[`Alert renders correctly when intent is warning 1`] = `
|
|
|
673
668
|
Array [
|
|
674
669
|
Object {
|
|
675
670
|
"backgroundColor": "#ffbe71",
|
|
676
|
-
"borderRadius":
|
|
671
|
+
"borderRadius": 16,
|
|
677
672
|
"flexDirection": "row",
|
|
678
673
|
"minHeight": 48,
|
|
679
674
|
},
|
|
@@ -681,7 +676,6 @@ exports[`Alert renders correctly when intent is warning 1`] = `
|
|
|
681
676
|
]
|
|
682
677
|
}
|
|
683
678
|
themeIntent="warning"
|
|
684
|
-
themeVariant="default"
|
|
685
679
|
>
|
|
686
680
|
<View
|
|
687
681
|
showDivider={true}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ReactElement } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import type { IconName } from '../Icon';
|
|
4
5
|
import Icon from '../Icon';
|
|
5
6
|
import Typography from '../Typography';
|
|
6
7
|
import {
|
|
@@ -10,8 +11,6 @@ import {
|
|
|
10
11
|
IconContainer,
|
|
11
12
|
TextContainer,
|
|
12
13
|
} from './StyledAlert';
|
|
13
|
-
import type { IconName } from '../Icon';
|
|
14
|
-
import { useDeprecation } from '../../utils/hooks';
|
|
15
14
|
|
|
16
15
|
const getIntentIcon = (
|
|
17
16
|
intent: 'success' | 'info' | 'warning' | 'error' | 'notification'
|
|
@@ -61,11 +60,6 @@ interface AlertProps {
|
|
|
61
60
|
* Closing callback. When onClose is available, an X button will be rendered on the right side of alert. The callback will be called when user clicks on X button.
|
|
62
61
|
*/
|
|
63
62
|
onClose?: () => void;
|
|
64
|
-
/**
|
|
65
|
-
* @deprecated
|
|
66
|
-
* Use rounded variant.
|
|
67
|
-
*/
|
|
68
|
-
variant?: 'default' | 'round';
|
|
69
63
|
/**
|
|
70
64
|
* Addtional style.
|
|
71
65
|
*/
|
|
@@ -82,25 +76,11 @@ const Alert = ({
|
|
|
82
76
|
title,
|
|
83
77
|
intent = 'info',
|
|
84
78
|
onClose,
|
|
85
|
-
variant: _variant,
|
|
86
79
|
style,
|
|
87
80
|
testID,
|
|
88
81
|
}: AlertProps): JSX.Element => {
|
|
89
|
-
const variant: AlertProps['variant'] =
|
|
90
|
-
_variant === undefined ? 'default' : _variant;
|
|
91
|
-
|
|
92
|
-
useDeprecation(
|
|
93
|
-
"Alert's variant prop will be removed in the next major release. Rounded will be the only variant available.",
|
|
94
|
-
_variant !== undefined
|
|
95
|
-
);
|
|
96
|
-
|
|
97
82
|
return (
|
|
98
|
-
<Container
|
|
99
|
-
themeVariant={variant}
|
|
100
|
-
themeIntent={intent}
|
|
101
|
-
style={style}
|
|
102
|
-
testID={testID}
|
|
103
|
-
>
|
|
83
|
+
<Container themeIntent={intent} style={style} testID={testID}>
|
|
104
84
|
<ContentContainer showDivider={!!onClose}>
|
|
105
85
|
{icon !== null ? (
|
|
106
86
|
<AlertIcon icon={icon || getIntentIcon(intent)} />
|
|
@@ -74,16 +74,7 @@ exports[`Box map prop to valid property and correct color from theme 2`] = `
|
|
|
74
74
|
borderTopColor="danger"
|
|
75
75
|
style={
|
|
76
76
|
Array [
|
|
77
|
-
Object {
|
|
78
|
-
"backgroundColor": "#de350b",
|
|
79
|
-
"borderBottomColor": "#de350b",
|
|
80
|
-
"borderColor": "#de350b",
|
|
81
|
-
"borderEndColor": "#de350b",
|
|
82
|
-
"borderLeftColor": "#de350b",
|
|
83
|
-
"borderRightColor": "#de350b",
|
|
84
|
-
"borderStartColor": "#de350b",
|
|
85
|
-
"borderTopColor": "#de350b",
|
|
86
|
-
},
|
|
77
|
+
Object {},
|
|
87
78
|
undefined,
|
|
88
79
|
]
|
|
89
80
|
}
|
|
@@ -130,16 +121,7 @@ exports[`Box map prop to valid property and correct color from theme 4`] = `
|
|
|
130
121
|
borderTopColor="backgroundDark"
|
|
131
122
|
style={
|
|
132
123
|
Array [
|
|
133
|
-
Object {
|
|
134
|
-
"backgroundColor": "#001f23",
|
|
135
|
-
"borderBottomColor": "#001f23",
|
|
136
|
-
"borderColor": "#001f23",
|
|
137
|
-
"borderEndColor": "#001f23",
|
|
138
|
-
"borderLeftColor": "#001f23",
|
|
139
|
-
"borderRightColor": "#001f23",
|
|
140
|
-
"borderStartColor": "#001f23",
|
|
141
|
-
"borderTopColor": "#001f23",
|
|
142
|
-
},
|
|
124
|
+
Object {},
|
|
143
125
|
undefined,
|
|
144
126
|
]
|
|
145
127
|
}
|
|
@@ -551,9 +533,7 @@ exports[`Box map prop with shortcut name to valid property and correct color fro
|
|
|
551
533
|
bgColor="danger"
|
|
552
534
|
style={
|
|
553
535
|
Array [
|
|
554
|
-
Object {
|
|
555
|
-
"backgroundColor": "#de350b",
|
|
556
|
-
},
|
|
536
|
+
Object {},
|
|
557
537
|
undefined,
|
|
558
538
|
]
|
|
559
539
|
}
|
|
@@ -579,9 +559,7 @@ exports[`Box map prop with shortcut name to valid property and correct color fro
|
|
|
579
559
|
bgColor="backgroundDark"
|
|
580
560
|
style={
|
|
581
561
|
Array [
|
|
582
|
-
Object {
|
|
583
|
-
"backgroundColor": "#001f23",
|
|
584
|
-
},
|
|
562
|
+
Object {},
|
|
585
563
|
undefined,
|
|
586
564
|
]
|
|
587
565
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
1
|
import type { ReactChild } from 'react';
|
|
2
|
+
import React from 'react';
|
|
3
3
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
4
|
+
import type { IconName } from '../Icon';
|
|
4
5
|
import LoadingIndicator from './LoadingIndicator';
|
|
6
|
+
import type { Intent, ThemeVariant } from './StyledButton';
|
|
5
7
|
import {
|
|
6
8
|
StyledButtonContainer,
|
|
7
|
-
StyledButtonText,
|
|
8
|
-
StyledButtonIconWrapper,
|
|
9
9
|
StyledButtonIcon,
|
|
10
|
+
StyledButtonIconWrapper,
|
|
11
|
+
StyledButtonText,
|
|
10
12
|
} from './StyledButton';
|
|
11
|
-
import type { IconName } from '../Icon';
|
|
12
|
-
import type { Intent, ThemeVariant } from './StyledButton';
|
|
13
|
-
import { useDeprecation } from '../../utils/hooks';
|
|
14
13
|
|
|
15
14
|
export interface ButtonProps {
|
|
16
15
|
/**
|
|
@@ -59,9 +58,8 @@ export interface ButtonProps {
|
|
|
59
58
|
text: ReactChild;
|
|
60
59
|
/**
|
|
61
60
|
* Button type.
|
|
62
|
-
* basic-transparent is deprecated and will be removed in the next major release.
|
|
63
61
|
*/
|
|
64
|
-
variant?: '
|
|
62
|
+
variant?: 'filled' | 'outlined' | 'text';
|
|
65
63
|
}
|
|
66
64
|
|
|
67
65
|
const FILLED_VARIANTS = {
|
|
@@ -83,12 +81,10 @@ const TEXT_VARIANTS = {
|
|
|
83
81
|
} as const;
|
|
84
82
|
|
|
85
83
|
export const getThemeVariant = (
|
|
86
|
-
variant: '
|
|
84
|
+
variant: 'filled' | 'outlined' | 'text',
|
|
87
85
|
intent: Intent
|
|
88
86
|
): ThemeVariant => {
|
|
89
87
|
switch (variant) {
|
|
90
|
-
case 'basic-transparent':
|
|
91
|
-
return variant;
|
|
92
88
|
case 'filled':
|
|
93
89
|
return FILLED_VARIANTS[intent];
|
|
94
90
|
case 'outlined':
|
|
@@ -114,11 +110,6 @@ const Button = ({
|
|
|
114
110
|
}: ButtonProps): JSX.Element => {
|
|
115
111
|
const themeVariant = getThemeVariant(variant, intent);
|
|
116
112
|
|
|
117
|
-
useDeprecation(
|
|
118
|
-
"Button's basic-transparent variant is deprecated and will be removed in the next major release.\nPlease use other variants instead.",
|
|
119
|
-
variant === 'basic-transparent'
|
|
120
|
-
);
|
|
121
|
-
|
|
122
113
|
return (
|
|
123
114
|
<StyledButtonContainer
|
|
124
115
|
accessibilityHint={accessibilityHint}
|
|
@@ -8,7 +8,6 @@ import Typography from '../Typography';
|
|
|
8
8
|
type Intent = 'primary' | 'secondary' | 'danger';
|
|
9
9
|
|
|
10
10
|
type ThemeVariant =
|
|
11
|
-
| 'basic-transparent'
|
|
12
11
|
| 'filled-primary'
|
|
13
12
|
| 'filled-secondary'
|
|
14
13
|
| 'filled-danger'
|
|
@@ -19,35 +18,6 @@ type ThemeVariant =
|
|
|
19
18
|
| 'text-secondary'
|
|
20
19
|
| 'text-danger';
|
|
21
20
|
|
|
22
|
-
const genBasicTransparentContainerStyles = (
|
|
23
|
-
theme: Theme,
|
|
24
|
-
disabled: boolean
|
|
25
|
-
): ReactNativeStyle => {
|
|
26
|
-
const borderColorStyling = () => {
|
|
27
|
-
if (disabled) {
|
|
28
|
-
return {
|
|
29
|
-
borderColor: theme.__hd__.button.colors.disabledBorder,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return { borderColor: theme.__hd__.button.colors.invertedText };
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
return {
|
|
37
|
-
width: '100%',
|
|
38
|
-
flexDirection: 'row',
|
|
39
|
-
justifyContent: 'center',
|
|
40
|
-
alignItems: 'center',
|
|
41
|
-
padding:
|
|
42
|
-
theme.__hd__.button.space.buttonPadding -
|
|
43
|
-
theme.__hd__.button.borderWidth.default,
|
|
44
|
-
borderWidth: theme.__hd__.button.borderWidth.default,
|
|
45
|
-
borderRadius: theme.__hd__.button.radii.default,
|
|
46
|
-
backgroundColor: 'transparent',
|
|
47
|
-
...borderColorStyling(),
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
|
|
51
21
|
const genFilledContainerStyles = (
|
|
52
22
|
theme: Theme,
|
|
53
23
|
intent: Intent,
|
|
@@ -153,8 +123,6 @@ const StyledButtonContainer = styled(TouchableOpacity)<{
|
|
|
153
123
|
themeVariant: ThemeVariant;
|
|
154
124
|
}>(({ disabled = false, themeVariant, theme }) => {
|
|
155
125
|
switch (themeVariant) {
|
|
156
|
-
case 'basic-transparent':
|
|
157
|
-
return genBasicTransparentContainerStyles(theme, disabled);
|
|
158
126
|
case 'filled-primary':
|
|
159
127
|
return genFilledContainerStyles(theme, 'primary', disabled);
|
|
160
128
|
case 'filled-secondary':
|
|
@@ -186,14 +154,6 @@ const StyledButtonText = styled(Typography.Text)<{
|
|
|
186
154
|
}>(({ disabled, themeVariant, theme }) => {
|
|
187
155
|
const themeStyling = () => {
|
|
188
156
|
switch (themeVariant) {
|
|
189
|
-
case 'basic-transparent':
|
|
190
|
-
return {
|
|
191
|
-
fontSize: theme.__hd__.button.fontSize.default,
|
|
192
|
-
lineHeight: theme.__hd__.button.lineHeight.default,
|
|
193
|
-
color: disabled
|
|
194
|
-
? theme.__hd__.button.colors.disabledText
|
|
195
|
-
: theme.__hd__.button.colors.invertedText,
|
|
196
|
-
};
|
|
197
157
|
case 'filled-primary':
|
|
198
158
|
case 'filled-secondary':
|
|
199
159
|
case 'filled-danger':
|
|
@@ -241,12 +201,6 @@ const StyledButtonIcon = styled(Icon)<{
|
|
|
241
201
|
}>(({ disabled, themeVariant, theme }) => {
|
|
242
202
|
const themeStyling = () => {
|
|
243
203
|
switch (themeVariant) {
|
|
244
|
-
case 'basic-transparent':
|
|
245
|
-
return {
|
|
246
|
-
color: disabled
|
|
247
|
-
? theme.__hd__.button.colors.disabledText
|
|
248
|
-
: theme.__hd__.button.colors.invertedText,
|
|
249
|
-
};
|
|
250
204
|
case 'filled-primary':
|
|
251
205
|
case 'filled-secondary':
|
|
252
206
|
case 'filled-danger':
|
|
@@ -79,17 +79,16 @@ describe('Button', () => {
|
|
|
79
79
|
|
|
80
80
|
describe('getThemeVariant', () => {
|
|
81
81
|
it.each`
|
|
82
|
-
variant
|
|
83
|
-
${'
|
|
84
|
-
${'filled'}
|
|
85
|
-
${'filled'}
|
|
86
|
-
${'
|
|
87
|
-
${'outlined'}
|
|
88
|
-
${'outlined'}
|
|
89
|
-
${'
|
|
90
|
-
${'text'}
|
|
91
|
-
${'text'}
|
|
92
|
-
${'text'} | ${'danger'} | ${'text-danger'}
|
|
82
|
+
variant | intent | themeVariant
|
|
83
|
+
${'filled'} | ${'primary'} | ${'filled-primary'}
|
|
84
|
+
${'filled'} | ${'secondary'} | ${'filled-secondary'}
|
|
85
|
+
${'filled'} | ${'danger'} | ${'filled-danger'}
|
|
86
|
+
${'outlined'} | ${'primary'} | ${'outlined-primary'}
|
|
87
|
+
${'outlined'} | ${'secondary'} | ${'outlined-secondary'}
|
|
88
|
+
${'outlined'} | ${'danger'} | ${'outlined-danger'}
|
|
89
|
+
${'text'} | ${'primary'} | ${'text-primary'}
|
|
90
|
+
${'text'} | ${'secondary'} | ${'text-secondary'}
|
|
91
|
+
${'text'} | ${'danger'} | ${'text-danger'}
|
|
93
92
|
`('returns $themeVariant', ({ variant, intent, themeVariant }) => {
|
|
94
93
|
expect(getThemeVariant(variant, intent)).toBe(themeVariant);
|
|
95
94
|
});
|
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
describe('StyledButtonContainer', () => {
|
|
14
14
|
it.each`
|
|
15
15
|
themeVariant
|
|
16
|
-
${'basic-transparent'}
|
|
17
16
|
${'filled-primary'}
|
|
18
17
|
${'filled-secondary'}
|
|
19
18
|
${'filled-danger'}
|
|
@@ -47,7 +46,6 @@ describe('StyledButtonContainer', () => {
|
|
|
47
46
|
describe('StyledButtonText', () => {
|
|
48
47
|
it.each`
|
|
49
48
|
themeVariant
|
|
50
|
-
${'basic-transparent'}
|
|
51
49
|
${'filled-primary'}
|
|
52
50
|
${'filled-secondary'}
|
|
53
51
|
${'filled-danger'}
|
|
@@ -93,7 +91,6 @@ describe('StyledButtonIconWrapper', () => {
|
|
|
93
91
|
describe('StyledButtonIcon', () => {
|
|
94
92
|
it.each`
|
|
95
93
|
themeVariant
|
|
96
|
-
${'basic-transparent'}
|
|
97
94
|
${'filled-primary'}
|
|
98
95
|
${'filled-secondary'}
|
|
99
96
|
${'filled-danger'}
|
|
@@ -1,39 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`StyledButtonContainer has basic-transparent style 1`] = `
|
|
4
|
-
<View
|
|
5
|
-
accessible={true}
|
|
6
|
-
collapsable={false}
|
|
7
|
-
focusable={false}
|
|
8
|
-
nativeID="animatedComponent"
|
|
9
|
-
onClick={[Function]}
|
|
10
|
-
onResponderGrant={[Function]}
|
|
11
|
-
onResponderMove={[Function]}
|
|
12
|
-
onResponderRelease={[Function]}
|
|
13
|
-
onResponderTerminate={[Function]}
|
|
14
|
-
onResponderTerminationRequest={[Function]}
|
|
15
|
-
onStartShouldSetResponder={[Function]}
|
|
16
|
-
style={
|
|
17
|
-
Object {
|
|
18
|
-
"alignItems": "center",
|
|
19
|
-
"backgroundColor": "transparent",
|
|
20
|
-
"borderColor": "#ffffff",
|
|
21
|
-
"borderRadius": 32,
|
|
22
|
-
"borderWidth": 2,
|
|
23
|
-
"flexDirection": "row",
|
|
24
|
-
"justifyContent": "center",
|
|
25
|
-
"opacity": 1,
|
|
26
|
-
"padding": 14,
|
|
27
|
-
"width": "100%",
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
>
|
|
31
|
-
<Text>
|
|
32
|
-
Title
|
|
33
|
-
</Text>
|
|
34
|
-
</View>
|
|
35
|
-
`;
|
|
36
|
-
|
|
37
3
|
exports[`StyledButtonContainer has filled-danger style 1`] = `
|
|
38
4
|
<View
|
|
39
5
|
accessible={true}
|
|
@@ -354,29 +320,6 @@ exports[`StyledButtonContainer renders disabled correctly 1`] = `
|
|
|
354
320
|
</View>
|
|
355
321
|
`;
|
|
356
322
|
|
|
357
|
-
exports[`StyledButtonIcon has basic-transparent style 1`] = `
|
|
358
|
-
<HeroIcon
|
|
359
|
-
name="bell"
|
|
360
|
-
style={
|
|
361
|
-
Array [
|
|
362
|
-
Object {
|
|
363
|
-
"color": "#001f23",
|
|
364
|
-
"fontSize": 24,
|
|
365
|
-
},
|
|
366
|
-
Array [
|
|
367
|
-
Object {
|
|
368
|
-
"color": "#ffffff",
|
|
369
|
-
"fontSize": 20,
|
|
370
|
-
},
|
|
371
|
-
undefined,
|
|
372
|
-
],
|
|
373
|
-
]
|
|
374
|
-
}
|
|
375
|
-
themeIntent="text"
|
|
376
|
-
themeSize="medium"
|
|
377
|
-
/>
|
|
378
|
-
`;
|
|
379
|
-
|
|
380
323
|
exports[`StyledButtonIcon has filled-danger style 1`] = `
|
|
381
324
|
<HeroIcon
|
|
382
325
|
name="bell"
|
|
@@ -641,40 +584,6 @@ exports[`StyledButtonIconWrapper has right style 1`] = `
|
|
|
641
584
|
/>
|
|
642
585
|
`;
|
|
643
586
|
|
|
644
|
-
exports[`StyledButtonText has basic-transparent style 1`] = `
|
|
645
|
-
<Text
|
|
646
|
-
style={
|
|
647
|
-
Array [
|
|
648
|
-
Object {
|
|
649
|
-
"color": "#001f23",
|
|
650
|
-
"fontFamily": "BeVietnamPro-Regular",
|
|
651
|
-
"fontSize": 14,
|
|
652
|
-
"letterSpacing": 0.42,
|
|
653
|
-
"lineHeight": 22,
|
|
654
|
-
},
|
|
655
|
-
Array [
|
|
656
|
-
Object {
|
|
657
|
-
"color": "#ffffff",
|
|
658
|
-
"flexShrink": 1,
|
|
659
|
-
"fontFamily": "BeVietnamPro-SemiBold",
|
|
660
|
-
"fontSize": 18,
|
|
661
|
-
"lineHeight": 24,
|
|
662
|
-
"textAlign": "center",
|
|
663
|
-
},
|
|
664
|
-
undefined,
|
|
665
|
-
],
|
|
666
|
-
]
|
|
667
|
-
}
|
|
668
|
-
themeFontSize="medium"
|
|
669
|
-
themeFontWeight="regular"
|
|
670
|
-
themeIntent="body"
|
|
671
|
-
themeTypeface="neutral"
|
|
672
|
-
themeVariant="basic-transparent"
|
|
673
|
-
>
|
|
674
|
-
Example
|
|
675
|
-
</Text>
|
|
676
|
-
`;
|
|
677
|
-
|
|
678
587
|
exports[`StyledButtonText has filled-danger style 1`] = `
|
|
679
588
|
<Text
|
|
680
589
|
style={
|
|
@@ -2,10 +2,8 @@ import { View } from 'react-native';
|
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
3
|
|
|
4
4
|
const StyledCard = styled(View)<{
|
|
5
|
-
themeVariant: 'basic' | 'data';
|
|
6
5
|
themeIntent?: 'primary' | 'success' | 'warning';
|
|
7
|
-
}>(({
|
|
8
|
-
...(themeVariant === 'data' && { flexDirection: 'row' }),
|
|
6
|
+
}>(({ theme, themeIntent }) => ({
|
|
9
7
|
...(themeIntent !== undefined && {
|
|
10
8
|
backgroundColor: theme.__hd__.card.colors[themeIntent],
|
|
11
9
|
}),
|
|
@@ -13,11 +11,4 @@ const StyledCard = styled(View)<{
|
|
|
13
11
|
overflow: 'hidden',
|
|
14
12
|
}));
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
const LeftDataCard = styled(View)(({ theme }) => ({
|
|
18
|
-
backgroundColor: theme.__hd__.card.colors.dataCardIndicator,
|
|
19
|
-
width: theme.__hd__.card.sizes.indicatorWidth,
|
|
20
|
-
height: '100%',
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
|
-
export { StyledCard, LeftDataCard };
|
|
14
|
+
export { StyledCard };
|
|
@@ -1,22 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
-
import { StyledCard
|
|
3
|
+
import { StyledCard } from '../StyledCard';
|
|
4
4
|
|
|
5
5
|
describe('StyledCard', () => {
|
|
6
6
|
it('renders correct basic style', () => {
|
|
7
|
-
const { toJSON } = renderWithTheme(<StyledCard
|
|
8
|
-
expect(toJSON()).toMatchSnapshot();
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it('renders correct data style', () => {
|
|
12
|
-
const { toJSON } = renderWithTheme(<StyledCard themeVariant="data" />);
|
|
13
|
-
expect(toJSON()).toMatchSnapshot();
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
describe('LeftDataCard', () => {
|
|
18
|
-
it('renders correctly', () => {
|
|
19
|
-
const { toJSON } = renderWithTheme(<LeftDataCard />);
|
|
7
|
+
const { toJSON } = renderWithTheme(<StyledCard />);
|
|
20
8
|
expect(toJSON()).toMatchSnapshot();
|
|
21
9
|
});
|
|
22
10
|
});
|
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`LeftDataCard renders correctly 1`] = `
|
|
4
|
-
<View
|
|
5
|
-
style={
|
|
6
|
-
Array [
|
|
7
|
-
Object {
|
|
8
|
-
"backgroundColor": "#401960",
|
|
9
|
-
"height": "100%",
|
|
10
|
-
"width": 16,
|
|
11
|
-
},
|
|
12
|
-
undefined,
|
|
13
|
-
]
|
|
14
|
-
}
|
|
15
|
-
/>
|
|
16
|
-
`;
|
|
17
|
-
|
|
18
3
|
exports[`StyledCard renders correct basic style 1`] = `
|
|
19
4
|
<View
|
|
20
5
|
style={
|
|
@@ -26,22 +11,5 @@ exports[`StyledCard renders correct basic style 1`] = `
|
|
|
26
11
|
undefined,
|
|
27
12
|
]
|
|
28
13
|
}
|
|
29
|
-
themeVariant="basic"
|
|
30
|
-
/>
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
exports[`StyledCard renders correct data style 1`] = `
|
|
34
|
-
<View
|
|
35
|
-
style={
|
|
36
|
-
Array [
|
|
37
|
-
Object {
|
|
38
|
-
"borderRadius": 12,
|
|
39
|
-
"flexDirection": "row",
|
|
40
|
-
"overflow": "hidden",
|
|
41
|
-
},
|
|
42
|
-
undefined,
|
|
43
|
-
]
|
|
44
|
-
}
|
|
45
|
-
themeVariant="data"
|
|
46
14
|
/>
|
|
47
15
|
`;
|