@hero-design/rn 7.19.0 → 7.20.1
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/.eslintrc.json +6 -1
- package/.turbo/turbo-build.log +2 -2
- package/es/index.js +612 -242
- package/lib/index.js +612 -241
- package/package.json +4 -4
- package/src/components/Alert/StyledAlert.tsx +5 -5
- package/src/components/Alert/__tests__/__snapshots__/index.spec.tsx.snap +140 -19
- package/src/components/Alert/__tests__/index.spec.tsx +21 -0
- package/src/components/Alert/index.tsx +13 -6
- package/src/components/Avatar/StyledAvatar.tsx +2 -1
- package/src/components/Avatar/index.tsx +2 -1
- package/src/components/Box/StyledBox.tsx +54 -0
- package/src/components/Box/__tests__/__snapshots__/index.spec.tsx.snap +605 -0
- package/src/components/Box/__tests__/helpers.spec.ts +14 -0
- package/src/components/Box/__tests__/index.spec.tsx +155 -0
- package/src/components/Box/config.ts +201 -0
- package/src/components/Box/helpers.ts +10 -0
- package/src/components/Box/index.tsx +13 -0
- package/src/components/Box/types.ts +38 -0
- package/src/components/Calendar/__tests__/index.spec.tsx +13 -17
- package/src/components/Card/DataCard/StyledDataCard.tsx +8 -2
- package/src/components/Card/DataCard/__tests__/StyledDataCard.spec.tsx +1 -0
- package/src/components/Card/DataCard/__tests__/__snapshots__/StyledDataCard.spec.tsx.snap +16 -0
- package/src/components/Card/DataCard/index.tsx +1 -1
- package/src/components/Card/StyledCard.tsx +12 -19
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +147 -0
- package/src/components/Card/__tests__/index.spec.tsx +18 -0
- package/src/components/Card/index.tsx +6 -1
- package/src/components/Drawer/DragableDrawer/helpers.ts +3 -4
- package/src/components/FAB/ActionGroup/index.tsx +6 -8
- package/src/components/RichTextEditor/EditorToolbar.tsx +19 -18
- package/src/components/RichTextEditor/RichTextEditor.tsx +7 -2
- package/src/components/RichTextEditor/StyledRichTextEditor.ts +0 -2
- package/src/components/RichTextEditor/__tests__/RichTextEditor.spec.tsx +11 -12
- package/src/components/RichTextEditor/__tests__/__snapshots__/RichTextEditor.spec.tsx.snap +2 -10
- package/src/components/RichTextEditor/constants.ts +0 -11
- package/src/components/RichTextEditor/index.tsx +0 -3
- package/src/components/RichTextEditor/types.ts +9 -0
- package/src/components/SectionHeading/__tests__/__snapshots__/StyledHeading.spec.tsx.snap +1 -1
- package/src/components/SectionHeading/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +22 -20
- package/src/components/Select/MultiSelect/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/OptionList.spec.tsx.snap +22 -20
- package/src/components/Select/SingleSelect/__tests__/__snapshots__/index.spec.tsx.snap +4 -4
- package/src/components/Spinner/AnimatedSpinner.tsx +7 -7
- package/src/components/Spinner/StyledSpinner.tsx +24 -19
- package/src/components/Spinner/__tests__/AnimatedSpinner.spec.tsx +1 -1
- package/src/components/Spinner/__tests__/StyledSpinner.spec.tsx +32 -16
- package/src/components/Spinner/__tests__/__snapshots__/AnimatedSpinner.spec.tsx.snap +14 -12
- package/src/components/Spinner/__tests__/__snapshots__/StyledSpinner.spec.tsx.snap +273 -31
- package/src/components/Spinner/__tests__/__snapshots__/index.spec.tsx.snap +14 -12
- package/src/components/Spinner/index.tsx +10 -2
- package/src/components/Tabs/ScrollableTabs.tsx +9 -4
- package/src/components/Tabs/StyledScrollableTabs.tsx +6 -5
- package/src/components/Tabs/StyledTabs.tsx +6 -0
- package/src/components/Tabs/TabWithBadge.tsx +68 -0
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +13 -0
- package/src/components/Tabs/__tests__/TabWithBadge.spec.tsx +48 -0
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +205 -43
- package/src/components/Tabs/__tests__/__snapshots__/TabWithBadge.spec.tsx.snap +165 -0
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +135 -34
- package/src/components/Tabs/__tests__/index.spec.tsx +12 -0
- package/src/components/Tabs/index.tsx +11 -4
- package/src/components/Tag/StyledTag.tsx +1 -11
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +4 -4
- package/src/components/Tag/index.tsx +2 -2
- package/src/components/TextInput/__tests__/index.spec.tsx +10 -14
- package/src/components/Toast/StyledToast.tsx +13 -7
- package/src/components/Toast/Toast.tsx +34 -9
- package/src/components/Toast/ToastProvider.tsx +15 -12
- package/src/components/Toast/__tests__/Toast.spec.tsx +17 -0
- package/src/components/Toast/__tests__/__snapshots__/Toast.spec.tsx.snap +299 -19
- package/src/components/Toast/types.ts +15 -1
- package/src/components/Typography/Text/StyledText.tsx +7 -1
- package/src/components/Typography/Text/__tests__/StyledText.spec.tsx +1 -0
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +22 -0
- package/src/components/Typography/Text/index.tsx +7 -1
- package/src/index.ts +2 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +76 -23
- package/src/theme/components/.eslintrc.json +10 -0
- package/src/theme/components/alert.ts +5 -1
- package/src/theme/components/avatar.ts +2 -0
- package/src/theme/components/card.ts +6 -7
- package/src/theme/components/sectionHeading.ts +1 -1
- package/src/theme/components/spinner.ts +19 -7
- package/src/theme/components/tabs.ts +3 -2
- package/src/theme/components/tag.ts +13 -13
- package/src/theme/components/toast.ts +17 -3
- package/src/theme/components/typography.ts +2 -0
- package/src/theme/global/colors/swag.ts +23 -0
- package/src/theme/global/colors/types.ts +23 -0
- package/src/theme/global/colors/work.ts +5 -0
- package/src/types.ts +0 -2
- package/tsconfig.json +4 -15
- package/types/components/Accordion/StyledAccordion.d.ts +14 -14
- package/types/components/Alert/StyledAlert.d.ts +16 -16
- package/types/components/Alert/index.d.ts +1 -1
- package/types/components/Avatar/StyledAvatar.d.ts +16 -16
- package/types/components/Avatar/index.d.ts +2 -2
- package/types/components/Badge/StyledBadge.d.ts +7 -7
- package/types/components/BottomNavigation/StyledBottomNavigation.d.ts +21 -21
- package/types/components/BottomSheet/Header.d.ts +1 -1
- package/types/components/BottomSheet/StyledBottomSheet.d.ts +19 -19
- package/types/components/Box/StyledBox.d.ts +15 -0
- package/types/components/Box/__tests__/helpers.spec.d.ts +1 -0
- package/types/components/Box/__tests__/index.spec.d.ts +1 -0
- package/types/components/Box/config.d.ts +170 -0
- package/types/components/Box/helpers.d.ts +1 -0
- package/types/components/Box/index.d.ts +5 -0
- package/types/components/Box/types.d.ts +31 -0
- package/types/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +7 -7
- package/types/components/Button/StyledButton.d.ts +16 -16
- package/types/components/Button/UtilityButton/StyledUtilityButton.d.ts +8 -8
- package/types/components/Calendar/StyledCalendar.d.ts +25 -25
- package/types/components/Calendar/helpers.d.ts +2 -2
- package/types/components/Card/DataCard/StyledDataCard.d.ts +7 -7
- package/types/components/Card/DataCard/index.d.ts +1 -1
- package/types/components/Card/StyledCard.d.ts +7 -6
- package/types/components/Card/index.d.ts +5 -1
- package/types/components/Checkbox/StyledCheckbox.d.ts +10 -10
- package/types/components/Collapse/StyledCollapse.d.ts +8 -8
- package/types/components/ContentNavigator/StyledContentNavigator.d.ts +5 -5
- package/types/components/DatePicker/StyledDatePicker.d.ts +3 -3
- package/types/components/Divider/StyledDivider.d.ts +5 -5
- package/types/components/Drawer/StyledDrawer.d.ts +19 -19
- package/types/components/Empty/StyledEmpty.d.ts +12 -12
- package/types/components/FAB/ActionGroup/StyledActionGroup.d.ts +11 -11
- package/types/components/FAB/ActionGroup/StyledActionItem.d.ts +7 -7
- package/types/components/FAB/StyledFAB.d.ts +8 -8
- package/types/components/Icon/HeroIcon/index.d.ts +3 -3
- package/types/components/List/StyledBasicListItem.d.ts +14 -14
- package/types/components/List/StyledListItem.d.ts +23 -23
- package/types/components/PinInput/StyledPinInput.d.ts +30 -30
- package/types/components/Progress/StyledProgressBar.d.ts +5 -5
- package/types/components/Progress/StyledProgressCircle.d.ts +18 -18
- package/types/components/Radio/StyledRadio.d.ts +9 -9
- package/types/components/RichTextEditor/EditorToolbar.d.ts +2 -2
- package/types/components/RichTextEditor/MentionList.d.ts +1 -1
- package/types/components/RichTextEditor/RichTextEditor.d.ts +4 -0
- package/types/components/RichTextEditor/StyledRichTextEditor.d.ts +6 -6
- package/types/components/RichTextEditor/StyledToolbar.d.ts +9 -9
- package/types/components/RichTextEditor/constants.d.ts +0 -10
- package/types/components/RichTextEditor/index.d.ts +2 -4
- package/types/components/RichTextEditor/types.d.ts +1 -0
- package/types/components/SectionHeading/StyledHeading.d.ts +9 -9
- package/types/components/Select/MultiSelect/Option.d.ts +1 -1
- package/types/components/Select/SingleSelect/Option.d.ts +1 -1
- package/types/components/Select/StyledSelect.d.ts +11 -11
- package/types/components/Select/helpers.d.ts +1 -1
- package/types/components/Spinner/AnimatedSpinner.d.ts +3 -1
- package/types/components/Spinner/StyledSpinner.d.ts +14 -12
- package/types/components/Spinner/index.d.ts +5 -1
- package/types/components/Switch/StyledSwitch.d.ts +5 -5
- package/types/components/Tabs/StyledScrollableTabs.d.ts +24 -22
- package/types/components/Tabs/StyledTabs.d.ts +26 -20
- package/types/components/Tabs/TabWithBadge.d.ts +17 -0
- package/types/components/Tabs/__tests__/TabWithBadge.spec.d.ts +1 -0
- package/types/components/Tabs/index.d.ts +3 -1
- package/types/components/Tag/StyledTag.d.ts +6 -6
- package/types/components/Tag/index.d.ts +1 -1
- package/types/components/TextInput/StyledTextInput.d.ts +44 -44
- package/types/components/TextInput/index.d.ts +5 -5
- package/types/components/TimePicker/StyledTimePicker.d.ts +3 -3
- package/types/components/Toast/StyledToast.d.ts +19 -18
- package/types/components/Toast/types.d.ts +2 -1
- package/types/components/Toolbar/StyledToolbar.d.ts +9 -9
- package/types/components/Typography/Text/StyledText.d.ts +4 -4
- package/types/components/Typography/Text/index.d.ts +1 -1
- package/types/index.d.ts +2 -1
- package/types/testHelpers/renderWithTheme.d.ts +1 -1
- package/types/theme/ThemeSwitcher.d.ts +1 -1
- package/types/theme/components/alert.d.ts +5 -1
- package/types/theme/components/avatar.d.ts +2 -0
- package/types/theme/components/card.d.ts +6 -7
- package/types/theme/components/spinner.d.ts +17 -5
- package/types/theme/components/tabs.d.ts +1 -0
- package/types/theme/components/tag.d.ts +2 -2
- package/types/theme/components/toast.d.ts +18 -2
- package/types/theme/components/typography.d.ts +2 -0
- package/types/theme/global/colors/types.d.ts +17 -0
- package/types/theme/global/index.d.ts +17 -0
- package/types/types.d.ts +1 -2
- package/types/utils/hooks.d.ts +1 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Text } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
5
|
+
import Box from '..';
|
|
6
|
+
|
|
7
|
+
describe('Box', () => {
|
|
8
|
+
it('renders content correctly', () => {
|
|
9
|
+
const { toJSON, getByTestId, getByText } = renderWithTheme(
|
|
10
|
+
<Box testID="box-test-id">
|
|
11
|
+
<Text>Box Content</Text>
|
|
12
|
+
</Box>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
expect(toJSON()).toMatchSnapshot();
|
|
16
|
+
expect(getByTestId('box-test-id')).toBeTruthy();
|
|
17
|
+
expect(getByText('Box Content')).toBeTruthy();
|
|
18
|
+
});
|
|
19
|
+
it.each`
|
|
20
|
+
color
|
|
21
|
+
${'warning'}
|
|
22
|
+
${'danger'}
|
|
23
|
+
${'success'}
|
|
24
|
+
${'backgroundDark'}
|
|
25
|
+
`('map prop to valid property and correct color from theme', ({ color }) => {
|
|
26
|
+
const { toJSON } = renderWithTheme(
|
|
27
|
+
<Box
|
|
28
|
+
backgroundColor={color}
|
|
29
|
+
borderColor={color}
|
|
30
|
+
borderTopColor={color}
|
|
31
|
+
borderBottomColor={color}
|
|
32
|
+
borderStartColor={color}
|
|
33
|
+
borderEndColor={color}
|
|
34
|
+
borderLeftColor={color}
|
|
35
|
+
borderRightColor={color}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
expect(toJSON()).toMatchSnapshot();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it.each`
|
|
43
|
+
color
|
|
44
|
+
${'warning'}
|
|
45
|
+
${'danger'}
|
|
46
|
+
${'success'}
|
|
47
|
+
${'backgroundDark'}
|
|
48
|
+
`(
|
|
49
|
+
'map prop with shortcut name to valid property and correct color from theme',
|
|
50
|
+
({ color }) => {
|
|
51
|
+
const { toJSON } = renderWithTheme(<Box bgColor={color} />);
|
|
52
|
+
|
|
53
|
+
expect(toJSON()).toMatchSnapshot();
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
it.each`
|
|
58
|
+
space
|
|
59
|
+
${'large'}
|
|
60
|
+
${'medium'}
|
|
61
|
+
${'small'}
|
|
62
|
+
${'xlarge'}
|
|
63
|
+
`('map prop to valid property and correct space from theme', ({ space }) => {
|
|
64
|
+
const { toJSON } = renderWithTheme(
|
|
65
|
+
<Box
|
|
66
|
+
margin={space}
|
|
67
|
+
marginBottom={space}
|
|
68
|
+
marginEnd={space}
|
|
69
|
+
marginHorizontal={space}
|
|
70
|
+
marginLeft={space}
|
|
71
|
+
marginRight={space}
|
|
72
|
+
marginStart={space}
|
|
73
|
+
marginTop={space}
|
|
74
|
+
marginVertical={space}
|
|
75
|
+
padding={space}
|
|
76
|
+
paddingBottom={space}
|
|
77
|
+
paddingEnd={space}
|
|
78
|
+
paddingHorizontal={space}
|
|
79
|
+
paddingLeft={space}
|
|
80
|
+
paddingRight={space}
|
|
81
|
+
paddingStart={space}
|
|
82
|
+
paddingTop={space}
|
|
83
|
+
paddingVertical={space}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
expect(toJSON()).toMatchSnapshot();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it.each`
|
|
91
|
+
radii
|
|
92
|
+
${'base'}
|
|
93
|
+
${'large'}
|
|
94
|
+
${'medium'}
|
|
95
|
+
${'xlarge'}
|
|
96
|
+
${'rounded'}
|
|
97
|
+
`('map prop to valid property and correct radius from theme', ({ radii }) => {
|
|
98
|
+
const { toJSON } = renderWithTheme(
|
|
99
|
+
<Box
|
|
100
|
+
borderBottomEndRadius={radii}
|
|
101
|
+
borderBottomLeftRadius={radii}
|
|
102
|
+
borderBottomRightRadius={radii}
|
|
103
|
+
borderBottomStartRadius={radii}
|
|
104
|
+
borderTopEndRadius={radii}
|
|
105
|
+
borderTopLeftRadius={radii}
|
|
106
|
+
borderTopRightRadius={radii}
|
|
107
|
+
borderTopStartRadius={radii}
|
|
108
|
+
borderRadius={radii}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
expect(toJSON()).toMatchSnapshot();
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it.each`
|
|
116
|
+
width
|
|
117
|
+
${'base'}
|
|
118
|
+
${'medium'}
|
|
119
|
+
`(
|
|
120
|
+
'map prop to valid property and correctborderWidth from theme',
|
|
121
|
+
({ width }) => {
|
|
122
|
+
const { toJSON } = renderWithTheme(
|
|
123
|
+
<Box
|
|
124
|
+
borderWidth={width}
|
|
125
|
+
borderBottomWidth={width}
|
|
126
|
+
borderTopWidth={width}
|
|
127
|
+
borderLeftWidth={width}
|
|
128
|
+
borderRightWidth={width}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
expect(toJSON()).toMatchSnapshot();
|
|
133
|
+
}
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
it('allows flex props', () => {
|
|
137
|
+
const { toJSON } = renderWithTheme(
|
|
138
|
+
<Box
|
|
139
|
+
alignContent="center"
|
|
140
|
+
alignItems="flex-end"
|
|
141
|
+
alignSelf="baseline"
|
|
142
|
+
display="flex"
|
|
143
|
+
flex={1}
|
|
144
|
+
flexBasis={20}
|
|
145
|
+
flexDirection="row"
|
|
146
|
+
flexGrow={3}
|
|
147
|
+
flexShrink={5}
|
|
148
|
+
flexWrap="wrap"
|
|
149
|
+
justifyContent="space-around"
|
|
150
|
+
/>
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
expect(toJSON()).toMatchSnapshot();
|
|
154
|
+
});
|
|
155
|
+
});
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
const colors = {
|
|
2
|
+
backgroundColor: {
|
|
3
|
+
property: 'backgroundColor',
|
|
4
|
+
scale: 'colors',
|
|
5
|
+
},
|
|
6
|
+
bgColor: {
|
|
7
|
+
property: 'backgroundColor',
|
|
8
|
+
scale: 'colors',
|
|
9
|
+
},
|
|
10
|
+
borderColor: {
|
|
11
|
+
property: 'borderColor',
|
|
12
|
+
scale: 'colors',
|
|
13
|
+
},
|
|
14
|
+
borderTopColor: {
|
|
15
|
+
property: 'borderTopColor',
|
|
16
|
+
scale: 'colors',
|
|
17
|
+
},
|
|
18
|
+
borderBottomColor: {
|
|
19
|
+
property: 'borderBottomColor',
|
|
20
|
+
scale: 'colors',
|
|
21
|
+
},
|
|
22
|
+
borderStartColor: {
|
|
23
|
+
property: 'borderStartColor',
|
|
24
|
+
scale: 'colors',
|
|
25
|
+
},
|
|
26
|
+
borderEndColor: {
|
|
27
|
+
property: 'borderEndColor',
|
|
28
|
+
scale: 'colors',
|
|
29
|
+
},
|
|
30
|
+
borderLeftColor: {
|
|
31
|
+
property: 'borderLeftColor',
|
|
32
|
+
scale: 'colors',
|
|
33
|
+
},
|
|
34
|
+
borderRightColor: {
|
|
35
|
+
property: 'borderRightColor',
|
|
36
|
+
scale: 'colors',
|
|
37
|
+
},
|
|
38
|
+
} as const;
|
|
39
|
+
|
|
40
|
+
const space = {
|
|
41
|
+
margin: {
|
|
42
|
+
property: 'margin',
|
|
43
|
+
scale: 'space',
|
|
44
|
+
},
|
|
45
|
+
marginBottom: {
|
|
46
|
+
property: 'marginBottom',
|
|
47
|
+
scale: 'space',
|
|
48
|
+
},
|
|
49
|
+
marginEnd: {
|
|
50
|
+
property: 'marginEnd',
|
|
51
|
+
scale: 'space',
|
|
52
|
+
},
|
|
53
|
+
marginHorizontal: {
|
|
54
|
+
property: 'marginHorizontal',
|
|
55
|
+
scale: 'space',
|
|
56
|
+
},
|
|
57
|
+
marginLeft: {
|
|
58
|
+
property: 'marginLeft',
|
|
59
|
+
scale: 'space',
|
|
60
|
+
},
|
|
61
|
+
marginRight: {
|
|
62
|
+
property: 'marginRight',
|
|
63
|
+
scale: 'space',
|
|
64
|
+
},
|
|
65
|
+
marginStart: {
|
|
66
|
+
property: 'marginStart',
|
|
67
|
+
scale: 'space',
|
|
68
|
+
},
|
|
69
|
+
marginTop: {
|
|
70
|
+
property: 'marginTop',
|
|
71
|
+
scale: 'space',
|
|
72
|
+
},
|
|
73
|
+
marginVertical: {
|
|
74
|
+
property: 'marginVertical',
|
|
75
|
+
scale: 'space',
|
|
76
|
+
},
|
|
77
|
+
padding: {
|
|
78
|
+
property: 'padding',
|
|
79
|
+
scale: 'space',
|
|
80
|
+
},
|
|
81
|
+
paddingBottom: {
|
|
82
|
+
property: 'paddingBottom',
|
|
83
|
+
scale: 'space',
|
|
84
|
+
},
|
|
85
|
+
paddingEnd: {
|
|
86
|
+
property: 'paddingEnd',
|
|
87
|
+
scale: 'space',
|
|
88
|
+
},
|
|
89
|
+
paddingHorizontal: {
|
|
90
|
+
property: 'paddingHorizontal',
|
|
91
|
+
scale: 'space',
|
|
92
|
+
},
|
|
93
|
+
paddingLeft: {
|
|
94
|
+
property: 'paddingLeft',
|
|
95
|
+
scale: 'space',
|
|
96
|
+
},
|
|
97
|
+
paddingRight: {
|
|
98
|
+
property: 'paddingRight',
|
|
99
|
+
scale: 'space',
|
|
100
|
+
},
|
|
101
|
+
paddingStart: {
|
|
102
|
+
property: 'paddingStart',
|
|
103
|
+
scale: 'space',
|
|
104
|
+
},
|
|
105
|
+
paddingTop: {
|
|
106
|
+
property: 'paddingTop',
|
|
107
|
+
scale: 'space',
|
|
108
|
+
},
|
|
109
|
+
paddingVertical: {
|
|
110
|
+
property: 'paddingVertical',
|
|
111
|
+
scale: 'space',
|
|
112
|
+
},
|
|
113
|
+
} as const;
|
|
114
|
+
|
|
115
|
+
const radii = {
|
|
116
|
+
borderBottomEndRadius: {
|
|
117
|
+
property: 'borderBottomEndRadius',
|
|
118
|
+
scale: 'radii',
|
|
119
|
+
},
|
|
120
|
+
borderBottomLeftRadius: {
|
|
121
|
+
property: 'borderBottomLeftRadius',
|
|
122
|
+
scale: 'radii',
|
|
123
|
+
},
|
|
124
|
+
borderBottomRightRadius: {
|
|
125
|
+
property: 'borderBottomRightRadius',
|
|
126
|
+
scale: 'radii',
|
|
127
|
+
},
|
|
128
|
+
borderBottomStartRadius: {
|
|
129
|
+
property: 'borderBottomStartRadius',
|
|
130
|
+
scale: 'radii',
|
|
131
|
+
},
|
|
132
|
+
borderTopEndRadius: {
|
|
133
|
+
property: 'borderTopEndRadius',
|
|
134
|
+
scale: 'radii',
|
|
135
|
+
},
|
|
136
|
+
borderTopLeftRadius: {
|
|
137
|
+
property: 'borderTopLeftRadius',
|
|
138
|
+
scale: 'radii',
|
|
139
|
+
},
|
|
140
|
+
borderTopRightRadius: {
|
|
141
|
+
property: 'borderTopRightRadius',
|
|
142
|
+
scale: 'radii',
|
|
143
|
+
},
|
|
144
|
+
borderTopStartRadius: {
|
|
145
|
+
property: 'borderTopStartRadius',
|
|
146
|
+
scale: 'radii',
|
|
147
|
+
},
|
|
148
|
+
borderRadius: {
|
|
149
|
+
property: 'borderRadius',
|
|
150
|
+
scale: 'radii',
|
|
151
|
+
},
|
|
152
|
+
} as const;
|
|
153
|
+
|
|
154
|
+
const borderWidths = {
|
|
155
|
+
borderWidth: {
|
|
156
|
+
property: 'borderWidth',
|
|
157
|
+
scale: 'borderWidths',
|
|
158
|
+
},
|
|
159
|
+
borderBottomWidth: {
|
|
160
|
+
property: 'borderBottomWidth',
|
|
161
|
+
scale: 'borderWidths',
|
|
162
|
+
},
|
|
163
|
+
borderTopWidth: {
|
|
164
|
+
property: 'borderTopWidth',
|
|
165
|
+
scale: 'borderWidths',
|
|
166
|
+
},
|
|
167
|
+
borderLeftWidth: {
|
|
168
|
+
property: 'borderLeftWidth',
|
|
169
|
+
scale: 'borderWidths',
|
|
170
|
+
},
|
|
171
|
+
borderRightWidth: {
|
|
172
|
+
property: 'borderRightWidth',
|
|
173
|
+
scale: 'borderWidths',
|
|
174
|
+
},
|
|
175
|
+
} as const;
|
|
176
|
+
|
|
177
|
+
const config = {
|
|
178
|
+
...colors,
|
|
179
|
+
...space,
|
|
180
|
+
...radii,
|
|
181
|
+
...borderWidths,
|
|
182
|
+
} as const;
|
|
183
|
+
|
|
184
|
+
export const flexPropsKey = [
|
|
185
|
+
'alignContent',
|
|
186
|
+
'alignItems',
|
|
187
|
+
'alignSelf',
|
|
188
|
+
'display',
|
|
189
|
+
'flex',
|
|
190
|
+
'flexBasis',
|
|
191
|
+
'flexDirection',
|
|
192
|
+
'flexGrow',
|
|
193
|
+
'flexShrink',
|
|
194
|
+
'flexWrap',
|
|
195
|
+
'justifyContent',
|
|
196
|
+
] as const;
|
|
197
|
+
|
|
198
|
+
export type ConfigType = typeof config;
|
|
199
|
+
export type FlexPropsKeyType = typeof flexPropsKey[number];
|
|
200
|
+
|
|
201
|
+
export default config;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyledBox } from './StyledBox';
|
|
3
|
+
import type { BoxViewProps, FlexStyleProps, StyleProps } from './types';
|
|
4
|
+
|
|
5
|
+
export interface BoxProps extends StyleProps, FlexStyleProps, BoxViewProps {}
|
|
6
|
+
|
|
7
|
+
const Box = ({ children, style, testID, ...otherProps }: BoxProps) => (
|
|
8
|
+
<StyledBox {...otherProps} style={style} testID={testID}>
|
|
9
|
+
{children}
|
|
10
|
+
</StyledBox>
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export default Box;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import { SystemPalette } from '../../theme/global';
|
|
4
|
+
import { BorderWidths, Radii } from '../../theme/global/borders';
|
|
5
|
+
import { Space } from '../../theme/global/space';
|
|
6
|
+
import { ConfigType, FlexPropsKeyType } from './config';
|
|
7
|
+
|
|
8
|
+
export interface ThemeScale {
|
|
9
|
+
colors: keyof SystemPalette;
|
|
10
|
+
space: keyof Space;
|
|
11
|
+
radii: keyof Radii;
|
|
12
|
+
borderWidths: keyof BorderWidths;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type ConfigKeyType = keyof ConfigType;
|
|
16
|
+
|
|
17
|
+
export type StyleProps = {
|
|
18
|
+
[key in ConfigKeyType]?: ThemeScale[ConfigType[key]['scale']];
|
|
19
|
+
};
|
|
20
|
+
export type FlexStyleProps = Pick<
|
|
21
|
+
Omit<ViewStyle, keyof StyleProps>,
|
|
22
|
+
FlexPropsKeyType
|
|
23
|
+
>;
|
|
24
|
+
|
|
25
|
+
export interface BoxViewProps extends ViewProps {
|
|
26
|
+
/**
|
|
27
|
+
* Box's content.
|
|
28
|
+
*/
|
|
29
|
+
children?: React.ReactNode;
|
|
30
|
+
/**
|
|
31
|
+
* Addtional styles.
|
|
32
|
+
*/
|
|
33
|
+
style?: StyleProp<ViewStyle>;
|
|
34
|
+
/**
|
|
35
|
+
* Testing id of the component.
|
|
36
|
+
*/
|
|
37
|
+
testID?: string;
|
|
38
|
+
}
|
|
@@ -60,23 +60,19 @@ describe('Calendar', () => {
|
|
|
60
60
|
const onTitlePress = jest.fn();
|
|
61
61
|
const onPreviousPress = jest.fn();
|
|
62
62
|
const onNextPress = jest.fn();
|
|
63
|
-
const {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
minDate={new Date(2022, 10, 3)}
|
|
77
|
-
maxDate={new Date(2022, 10, 27)}
|
|
78
|
-
/>
|
|
79
|
-
);
|
|
63
|
+
const { getByText, queryByText, queryAllByTestId, queryByTestId } =
|
|
64
|
+
renderWithTheme(
|
|
65
|
+
<Calendar
|
|
66
|
+
value={new Date(2022, 10, 5)}
|
|
67
|
+
visibleDate={new Date(2022, 10, 5)}
|
|
68
|
+
onChange={onChange}
|
|
69
|
+
onTitlePress={onTitlePress}
|
|
70
|
+
onPreviousPress={onPreviousPress}
|
|
71
|
+
onNextPress={onNextPress}
|
|
72
|
+
minDate={new Date(2022, 10, 3)}
|
|
73
|
+
maxDate={new Date(2022, 10, 27)}
|
|
74
|
+
/>
|
|
75
|
+
);
|
|
80
76
|
|
|
81
77
|
expect(queryAllByTestId('calendar-date-cell')).toHaveLength(25);
|
|
82
78
|
expect(queryAllByTestId('calendar-disabled-cell')).toHaveLength(17);
|
|
@@ -8,9 +8,15 @@ const StyledDataCard = styled(View)(({ theme }) => ({
|
|
|
8
8
|
}));
|
|
9
9
|
|
|
10
10
|
const Indicator = styled(View)<{
|
|
11
|
-
themeIntent:
|
|
11
|
+
themeIntent:
|
|
12
|
+
| 'success'
|
|
13
|
+
| 'info'
|
|
14
|
+
| 'warning'
|
|
15
|
+
| 'danger'
|
|
16
|
+
| 'archived'
|
|
17
|
+
| 'primary';
|
|
12
18
|
}>(({ theme, themeIntent }) => ({
|
|
13
|
-
backgroundColor: theme.__hd__.card.colors
|
|
19
|
+
backgroundColor: theme.__hd__.card.colors[themeIntent],
|
|
14
20
|
width: theme.__hd__.card.sizes.indicatorWidth,
|
|
15
21
|
height: '100%',
|
|
16
22
|
}));
|
|
@@ -48,6 +48,22 @@ exports[`Indicator renders correctly when intent is info 1`] = `
|
|
|
48
48
|
/>
|
|
49
49
|
`;
|
|
50
50
|
|
|
51
|
+
exports[`Indicator renders correctly when intent is primary 1`] = `
|
|
52
|
+
<View
|
|
53
|
+
style={
|
|
54
|
+
Array [
|
|
55
|
+
Object {
|
|
56
|
+
"backgroundColor": "#c38cee",
|
|
57
|
+
"height": "100%",
|
|
58
|
+
"width": 16,
|
|
59
|
+
},
|
|
60
|
+
undefined,
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
themeIntent="primary"
|
|
64
|
+
/>
|
|
65
|
+
`;
|
|
66
|
+
|
|
51
67
|
exports[`Indicator renders correctly when intent is success 1`] = `
|
|
52
68
|
<View
|
|
53
69
|
style={
|
|
@@ -11,7 +11,7 @@ export interface DataCardProps extends ViewProps {
|
|
|
11
11
|
/**
|
|
12
12
|
* Visual intent color to apply to card.
|
|
13
13
|
*/
|
|
14
|
-
intent?: '
|
|
14
|
+
intent?: 'primary' | 'info' | 'success' | 'warning' | 'danger' | 'archived';
|
|
15
15
|
/**
|
|
16
16
|
* Additional style.
|
|
17
17
|
*/
|
|
@@ -1,26 +1,19 @@
|
|
|
1
1
|
import { View } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
3
|
|
|
4
|
-
const StyledCard = styled(View)<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
switch (themeVariant) {
|
|
16
|
-
case 'basic':
|
|
17
|
-
return sharedStyles;
|
|
18
|
-
case 'data':
|
|
19
|
-
return { ...sharedStyles, ...dataStyles };
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
);
|
|
4
|
+
const StyledCard = styled(View)<{
|
|
5
|
+
themeVariant: 'basic' | 'data';
|
|
6
|
+
themeIntent?: 'primary' | 'success' | 'warning';
|
|
7
|
+
}>(({ themeVariant, theme, themeIntent }) => ({
|
|
8
|
+
...(themeVariant === 'data' && { flexDirection: 'row' }),
|
|
9
|
+
...(themeIntent !== undefined && {
|
|
10
|
+
backgroundColor: theme.__hd__.card.colors[themeIntent],
|
|
11
|
+
}),
|
|
12
|
+
borderRadius: theme.__hd__.card.radii.default,
|
|
13
|
+
overflow: 'hidden',
|
|
14
|
+
}));
|
|
23
15
|
|
|
16
|
+
// DEPRECATED
|
|
24
17
|
const LeftDataCard = styled(View)(({ theme }) => ({
|
|
25
18
|
backgroundColor: theme.__hd__.card.colors.dataCardIndicator,
|
|
26
19
|
width: theme.__hd__.card.sizes.indicatorWidth,
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Card renders correctly when intent is info 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Array [
|
|
7
|
+
Object {
|
|
8
|
+
"backgroundColor": "#b5c3fd",
|
|
9
|
+
"borderRadius": 12,
|
|
10
|
+
"overflow": "hidden",
|
|
11
|
+
},
|
|
12
|
+
undefined,
|
|
13
|
+
]
|
|
14
|
+
}
|
|
15
|
+
themeIntent="info"
|
|
16
|
+
themeVariant="basic"
|
|
17
|
+
>
|
|
18
|
+
<Text
|
|
19
|
+
style={
|
|
20
|
+
Array [
|
|
21
|
+
Object {
|
|
22
|
+
"color": "#001f23",
|
|
23
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
24
|
+
"fontSize": 14,
|
|
25
|
+
"letterSpacing": 0.42,
|
|
26
|
+
"lineHeight": 22,
|
|
27
|
+
},
|
|
28
|
+
undefined,
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
themeFontSize="medium"
|
|
32
|
+
themeFontWeight="regular"
|
|
33
|
+
themeIntent="body"
|
|
34
|
+
>
|
|
35
|
+
Card Content
|
|
36
|
+
</Text>
|
|
37
|
+
</View>
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
exports[`Card renders correctly when intent is primary 1`] = `
|
|
41
|
+
<View
|
|
42
|
+
style={
|
|
43
|
+
Array [
|
|
44
|
+
Object {
|
|
45
|
+
"backgroundColor": "#c38cee",
|
|
46
|
+
"borderRadius": 12,
|
|
47
|
+
"overflow": "hidden",
|
|
48
|
+
},
|
|
49
|
+
undefined,
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
themeIntent="primary"
|
|
53
|
+
themeVariant="basic"
|
|
54
|
+
>
|
|
55
|
+
<Text
|
|
56
|
+
style={
|
|
57
|
+
Array [
|
|
58
|
+
Object {
|
|
59
|
+
"color": "#001f23",
|
|
60
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
61
|
+
"fontSize": 14,
|
|
62
|
+
"letterSpacing": 0.42,
|
|
63
|
+
"lineHeight": 22,
|
|
64
|
+
},
|
|
65
|
+
undefined,
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
themeFontSize="medium"
|
|
69
|
+
themeFontWeight="regular"
|
|
70
|
+
themeIntent="body"
|
|
71
|
+
>
|
|
72
|
+
Card Content
|
|
73
|
+
</Text>
|
|
74
|
+
</View>
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
exports[`Card renders correctly when intent is success 1`] = `
|
|
78
|
+
<View
|
|
79
|
+
style={
|
|
80
|
+
Array [
|
|
81
|
+
Object {
|
|
82
|
+
"backgroundColor": "#5ace7d",
|
|
83
|
+
"borderRadius": 12,
|
|
84
|
+
"overflow": "hidden",
|
|
85
|
+
},
|
|
86
|
+
undefined,
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
themeIntent="success"
|
|
90
|
+
themeVariant="basic"
|
|
91
|
+
>
|
|
92
|
+
<Text
|
|
93
|
+
style={
|
|
94
|
+
Array [
|
|
95
|
+
Object {
|
|
96
|
+
"color": "#001f23",
|
|
97
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
98
|
+
"fontSize": 14,
|
|
99
|
+
"letterSpacing": 0.42,
|
|
100
|
+
"lineHeight": 22,
|
|
101
|
+
},
|
|
102
|
+
undefined,
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
themeFontSize="medium"
|
|
106
|
+
themeFontWeight="regular"
|
|
107
|
+
themeIntent="body"
|
|
108
|
+
>
|
|
109
|
+
Card Content
|
|
110
|
+
</Text>
|
|
111
|
+
</View>
|
|
112
|
+
`;
|
|
113
|
+
|
|
114
|
+
exports[`Card renders correctly when intent is undefined 1`] = `
|
|
115
|
+
<View
|
|
116
|
+
style={
|
|
117
|
+
Array [
|
|
118
|
+
Object {
|
|
119
|
+
"borderRadius": 12,
|
|
120
|
+
"overflow": "hidden",
|
|
121
|
+
},
|
|
122
|
+
undefined,
|
|
123
|
+
]
|
|
124
|
+
}
|
|
125
|
+
themeVariant="basic"
|
|
126
|
+
>
|
|
127
|
+
<Text
|
|
128
|
+
style={
|
|
129
|
+
Array [
|
|
130
|
+
Object {
|
|
131
|
+
"color": "#001f23",
|
|
132
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
133
|
+
"fontSize": 14,
|
|
134
|
+
"letterSpacing": 0.42,
|
|
135
|
+
"lineHeight": 22,
|
|
136
|
+
},
|
|
137
|
+
undefined,
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
themeFontSize="medium"
|
|
141
|
+
themeFontWeight="regular"
|
|
142
|
+
themeIntent="body"
|
|
143
|
+
>
|
|
144
|
+
Card Content
|
|
145
|
+
</Text>
|
|
146
|
+
</View>
|
|
147
|
+
`;
|