@hero-design/rn 7.0.4 → 7.1.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/.expo/packager-info.json +1 -1
- package/babel.config.js +1 -1
- package/es/index.js +170 -49
- package/lib/assets/fonts/hero-icons.ttf +0 -0
- package/lib/index.js +169 -46
- package/package.json +6 -4
- package/playground/components/Card.tsx +75 -92
- package/playground/components/FAB.tsx +49 -0
- package/playground/index.tsx +3 -1
- package/rollup.config.js +11 -2
- package/src/components/Badge/index.tsx +12 -6
- package/src/components/Card/__tests__/__snapshots__/Card.spec.tsx.snap +4 -4
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +4 -4
- package/src/components/Card/index.tsx +16 -3
- package/src/components/Divider/StyledDivider.tsx +1 -1
- package/src/components/Divider/index.tsx +20 -2
- package/src/components/FAB/AnimatedFABIcon.tsx +47 -0
- package/src/components/FAB/StyledFABContainer.tsx +14 -0
- package/src/components/FAB/StyledFABIcon.tsx +9 -0
- package/src/components/FAB/__tests__/AnimatedFABIcon.spec.tsx +20 -0
- package/src/components/FAB/__tests__/StyledFABContainer.spec.tsx +18 -0
- package/src/components/FAB/__tests__/StyledFABIcon.spec.tsx +16 -0
- package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +71 -0
- package/src/components/FAB/__tests__/__snapshots__/StyledFABContainer.spec.tsx.snap +46 -0
- package/src/components/FAB/__tests__/__snapshots__/StyledFABIcon.spec.tsx.snap +21 -0
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +120 -0
- package/src/components/FAB/__tests__/index.spec.tsx +58 -0
- package/src/components/FAB/index.tsx +56 -0
- package/src/components/Icon/index.tsx +8 -8
- package/src/components/Typography/Text/{__test__ → __tests__}/StyledText.spec.tsx +0 -0
- package/src/components/Typography/Text/{__test__ → __tests__}/__snapshots__/StyledText.spec.tsx.snap +0 -0
- package/src/components/Typography/Text/{__test__ → __tests__}/index.spec.tsx +0 -0
- package/src/components/Typography/Text/index.tsx +13 -1
- package/src/index.ts +4 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +15 -2
- package/src/theme/components/card.ts +1 -1
- package/src/theme/components/divider.ts +2 -2
- package/src/theme/components/fab.ts +21 -0
- package/src/theme/global/space.ts +11 -9
- package/src/theme/global/typography.ts +11 -9
- package/src/theme/index.ts +3 -0
- package/src/utils/__tests__/scale.spec.ts +26 -0
- package/src/utils/scale.ts +10 -0
- package/testUtils/setup.ts +4 -0
- package/types/components/Card/StyledCard.d.ts +3 -0
- package/types/components/Card/__tests__/Card.spec.d.ts +1 -0
- package/types/components/Card/__tests__/StyledCard.spec.d.ts +1 -0
- package/types/components/Card/index.d.ts +5 -0
- package/types/components/Divider/StyledDivider.d.ts +7 -0
- package/types/components/Divider/__tests__/StyledDivider.spec.d.ts +1 -0
- package/types/components/Divider/index.d.ts +12 -0
- package/types/index.d.ts +4 -3
- package/types/playground/components/FAB.d.ts +2 -0
- package/types/src/components/Badge/index.d.ts +6 -6
- package/types/src/components/Card/index.d.ts +14 -1
- package/types/src/components/Divider/index.d.ts +11 -2
- package/types/src/components/FAB/AnimatedFABIcon.d.ts +6 -0
- package/types/src/components/FAB/StyledFABContainer.d.ts +3 -0
- package/types/src/components/FAB/StyledFABIcon.d.ts +3 -0
- package/types/src/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts +1 -0
- package/types/src/components/FAB/__tests__/StyledFABContainer.spec.d.ts +1 -0
- package/types/src/components/FAB/__tests__/StyledFABIcon.spec.d.ts +1 -0
- package/types/src/components/FAB/__tests__/index.spec.d.ts +1 -0
- package/types/src/components/FAB/index.d.ts +30 -0
- package/types/src/components/Icon/index.d.ts +8 -8
- package/types/src/components/Typography/Text/__tests__/StyledText.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/__tests__/index.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/index.d.ts +9 -1
- package/types/src/index.d.ts +3 -1
- package/types/src/theme/components/divider.d.ts +1 -1
- package/types/src/theme/components/fab.d.ts +15 -0
- package/types/src/theme/index.d.ts +2 -0
- package/types/src/utils/__tests__/scale.spec.d.ts +1 -0
- package/types/src/utils/scale.d.ts +2 -0
- package/types/theme/__tests__/index.spec.d.ts +1 -0
- package/types/theme/components/card.d.ts +10 -0
- package/types/theme/components/divider.d.ts +17 -0
- package/types/theme/global/borders.d.ts +4 -0
- package/types/theme/global/colors.d.ts +2 -0
- package/types/theme/global/index.d.ts +5 -0
- package/types/theme/index.d.ts +4 -2
- package/types/theme/colors.d.ts +0 -24
- package/types/theme/components/demoStyle.d.ts +0 -11
- package/types/theme/space.d.ts +0 -12
- package/types/theme/typography.d.ts +0 -21
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import React, { ComponentProps } from 'react';
|
|
2
2
|
import { View, ViewProps, StyleSheet } from 'react-native';
|
|
3
3
|
import { palette } from '@hero-design/colors';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{...props}
|
|
13
|
-
/>
|
|
14
|
-
);
|
|
4
|
+
import {
|
|
5
|
+
useTheme,
|
|
6
|
+
scale,
|
|
7
|
+
Card,
|
|
8
|
+
Typography,
|
|
9
|
+
Icon,
|
|
10
|
+
Divider,
|
|
11
|
+
} from '../../src/index';
|
|
15
12
|
|
|
16
13
|
const Screen = View;
|
|
14
|
+
|
|
17
15
|
type DashboardCardProps = ViewProps & {
|
|
18
16
|
icon: ComponentProps<typeof Icon>['icon'];
|
|
19
17
|
title: string;
|
|
@@ -25,19 +23,28 @@ const DashboardCard = ({
|
|
|
25
23
|
icon,
|
|
26
24
|
title,
|
|
27
25
|
subtitle,
|
|
28
|
-
}: DashboardCardProps) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
}: DashboardCardProps) => {
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
return (
|
|
29
|
+
<Card style={style}>
|
|
30
|
+
<View style={{ flex: 1, alignItems: 'flex-end' }}>
|
|
31
|
+
<Icon icon={icon} />
|
|
32
|
+
</View>
|
|
33
|
+
<View
|
|
34
|
+
style={{
|
|
35
|
+
flex: 1,
|
|
36
|
+
justifyContent: 'flex-end',
|
|
37
|
+
margin: theme.space.small,
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<Typography.Text fontSize="xlarge" fontWeight="semi-bold">
|
|
41
|
+
{title}
|
|
42
|
+
</Typography.Text>
|
|
43
|
+
<Typography.Text fontSize="medium">{subtitle}</Typography.Text>
|
|
44
|
+
</View>
|
|
45
|
+
</Card>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
41
48
|
|
|
42
49
|
const InductionCard = (props: ViewProps) => (
|
|
43
50
|
<DashboardCard
|
|
@@ -59,13 +66,13 @@ const PoliciesCard = (props: ViewProps) => (
|
|
|
59
66
|
const CertificationsCard = (props: ViewProps) => (
|
|
60
67
|
<DashboardCard
|
|
61
68
|
icon="file-certified"
|
|
62
|
-
title="
|
|
69
|
+
title="Certifications"
|
|
63
70
|
subtitle="1 to update"
|
|
64
71
|
{...props}
|
|
65
72
|
/>
|
|
66
73
|
);
|
|
67
74
|
|
|
68
|
-
const
|
|
75
|
+
const RostersCard = (props: ViewProps) => {
|
|
69
76
|
const theme = useTheme();
|
|
70
77
|
const { style, ...otherProps } = props;
|
|
71
78
|
return (
|
|
@@ -74,39 +81,30 @@ const Payslip = (props: ViewProps) => {
|
|
|
74
81
|
style={StyleSheet.flatten([
|
|
75
82
|
{
|
|
76
83
|
flexDirection: 'row',
|
|
77
|
-
alignItems: '
|
|
78
|
-
backgroundColor: palette.
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
backgroundColor: palette.greyLight90,
|
|
79
86
|
},
|
|
80
87
|
style,
|
|
81
88
|
])}
|
|
82
89
|
>
|
|
83
|
-
<View>
|
|
90
|
+
<View style={{ padding: theme.space.small }}>
|
|
84
91
|
<View
|
|
85
92
|
style={{
|
|
86
93
|
padding: theme.space.small,
|
|
87
|
-
backgroundColor:
|
|
94
|
+
backgroundColor: theme.colors.infoLight,
|
|
88
95
|
borderRadius: 999,
|
|
89
|
-
alignContent: 'stretch',
|
|
90
96
|
}}
|
|
91
97
|
>
|
|
92
|
-
<Icon icon="
|
|
98
|
+
<Icon icon="calendar-clock" />
|
|
93
99
|
</View>
|
|
94
100
|
</View>
|
|
95
101
|
<View style={{ flex: 1, marginLeft: theme.space.small }}>
|
|
96
|
-
<Typography.Text fontSize="
|
|
102
|
+
<Typography.Text fontSize="xlarge" fontWeight="semi-bold">
|
|
97
103
|
Rosters
|
|
98
104
|
</Typography.Text>
|
|
99
|
-
<Typography.Text fontSize="
|
|
100
|
-
</View>
|
|
101
|
-
<View
|
|
102
|
-
style={{
|
|
103
|
-
alignItems: 'center',
|
|
104
|
-
alignContent: 'center',
|
|
105
|
-
justifyContent: 'center',
|
|
106
|
-
}}
|
|
107
|
-
>
|
|
108
|
-
<Icon icon="arrow-right" />
|
|
105
|
+
<Typography.Text fontSize="large">3 shifts this week</Typography.Text>
|
|
109
106
|
</View>
|
|
107
|
+
<Icon icon="arrow-right" />
|
|
110
108
|
</Card>
|
|
111
109
|
);
|
|
112
110
|
};
|
|
@@ -129,58 +127,53 @@ const MyLeaveCard = (props: ViewProps) => {
|
|
|
129
127
|
])}
|
|
130
128
|
>
|
|
131
129
|
<View
|
|
132
|
-
testID="header"
|
|
133
130
|
style={{
|
|
134
|
-
|
|
135
|
-
marginTop: theme.space.small,
|
|
131
|
+
padding: theme.space.medium,
|
|
136
132
|
justifyContent: 'space-between',
|
|
137
133
|
flexDirection: 'row',
|
|
138
134
|
}}
|
|
139
135
|
>
|
|
140
|
-
<Typography.Text fontSize="
|
|
136
|
+
<Typography.Text fontSize="xlarge" fontWeight="semi-bold">
|
|
141
137
|
My Leave
|
|
142
138
|
</Typography.Text>
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
140
|
+
<Typography.Text fontSize="large" fontWeight="semi-bold">
|
|
141
|
+
Add / view
|
|
142
|
+
</Typography.Text>
|
|
146
143
|
<Icon
|
|
147
144
|
icon="circle-add-outlined"
|
|
148
145
|
size="xsmall"
|
|
149
|
-
style={{
|
|
146
|
+
style={{ marginLeft: theme.space.small }}
|
|
150
147
|
/>
|
|
151
148
|
</View>
|
|
152
149
|
</View>
|
|
153
|
-
<Divider
|
|
154
|
-
<View
|
|
155
|
-
<Typography.Text
|
|
150
|
+
<Divider />
|
|
151
|
+
<View style={{ padding: theme.space.medium }}>
|
|
152
|
+
<Typography.Text
|
|
153
|
+
fontSize="large"
|
|
154
|
+
fontWeight="semi-bold"
|
|
155
|
+
style={{ marginBottom: theme.space.small }}
|
|
156
|
+
>
|
|
156
157
|
Leave Balances
|
|
157
158
|
</Typography.Text>
|
|
158
|
-
<View
|
|
159
|
-
|
|
160
|
-
style={{ flexDirection: 'row', justifyContent: 'space-between' }}
|
|
161
|
-
>
|
|
162
|
-
<Typography.Text>Jury Duty</Typography.Text>
|
|
159
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
160
|
+
<Typography.Text fontSize="large">Jury Duty</Typography.Text>
|
|
163
161
|
<Typography.Text fontWeight="semi-bold">12.06 hrs</Typography.Text>
|
|
164
162
|
</View>
|
|
165
|
-
<View
|
|
166
|
-
|
|
167
|
-
style={{ flexDirection: 'row', justifyContent: 'space-between' }}
|
|
168
|
-
>
|
|
169
|
-
<Typography.Text>Annual Leave</Typography.Text>
|
|
163
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
164
|
+
<Typography.Text fontSize="large">Annual Leave</Typography.Text>
|
|
170
165
|
<Typography.Text fontWeight="semi-bold">12.06 hrs</Typography.Text>
|
|
171
166
|
</View>
|
|
172
|
-
<View
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
<Typography.Text>Values Champion Award</Typography.Text>
|
|
167
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
168
|
+
<Typography.Text fontSize="large">
|
|
169
|
+
Values Champion Award
|
|
170
|
+
</Typography.Text>
|
|
177
171
|
<Typography.Text fontWeight="semi-bold">12.06 hrs</Typography.Text>
|
|
178
172
|
</View>
|
|
179
|
-
<View
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
<Typography.Text>Family and Domestic</Typography.Text>
|
|
173
|
+
<View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
|
|
174
|
+
<Typography.Text fontSize="large">
|
|
175
|
+
Family and Domestic
|
|
176
|
+
</Typography.Text>
|
|
184
177
|
<Typography.Text fontWeight="semi-bold">12.06 hrs</Typography.Text>
|
|
185
178
|
</View>
|
|
186
179
|
</View>
|
|
@@ -191,13 +184,12 @@ const MyLeaveCard = (props: ViewProps) => {
|
|
|
191
184
|
const CardPlayground = () => {
|
|
192
185
|
const theme = useTheme();
|
|
193
186
|
return (
|
|
194
|
-
<Screen>
|
|
195
|
-
<View style={{ flexDirection: 'row', height:
|
|
196
|
-
<View style={{ flex: 1 }}>
|
|
187
|
+
<Screen style={{ padding: theme.space.medium }}>
|
|
188
|
+
<View style={{ flexDirection: 'row', height: scale(216) }}>
|
|
189
|
+
<View style={{ flex: 1, marginRight: theme.space.medium }}>
|
|
197
190
|
<InductionCard
|
|
198
191
|
style={{
|
|
199
192
|
flex: 1,
|
|
200
|
-
margin: theme.space.small,
|
|
201
193
|
backgroundColor: theme.colors.primaryLight,
|
|
202
194
|
}}
|
|
203
195
|
/>
|
|
@@ -206,31 +198,22 @@ const CardPlayground = () => {
|
|
|
206
198
|
<PoliciesCard
|
|
207
199
|
style={{
|
|
208
200
|
flex: 1,
|
|
209
|
-
backgroundColor:
|
|
210
|
-
|
|
201
|
+
backgroundColor: theme.colors.infoLight,
|
|
202
|
+
marginBottom: theme.space.medium,
|
|
211
203
|
}}
|
|
212
204
|
testID="policies"
|
|
213
205
|
/>
|
|
214
206
|
<CertificationsCard
|
|
215
207
|
style={{
|
|
216
208
|
flex: 1,
|
|
217
|
-
|
|
218
|
-
backgroundColor: palette.dodgerBlueLight75,
|
|
209
|
+
backgroundColor: theme.colors.infoLight,
|
|
219
210
|
}}
|
|
220
211
|
testID="certifications"
|
|
221
212
|
/>
|
|
222
213
|
</View>
|
|
223
214
|
</View>
|
|
224
|
-
<
|
|
225
|
-
|
|
226
|
-
margin: theme.space.small,
|
|
227
|
-
}}
|
|
228
|
-
/>
|
|
229
|
-
<MyLeaveCard
|
|
230
|
-
style={{
|
|
231
|
-
margin: theme.space.small,
|
|
232
|
-
}}
|
|
233
|
-
/>
|
|
215
|
+
<RostersCard style={{ marginTop: theme.space.medium }} />
|
|
216
|
+
<MyLeaveCard style={{ marginTop: theme.space.medium }} />
|
|
234
217
|
</Screen>
|
|
235
218
|
);
|
|
236
219
|
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
|
+
import {
|
|
4
|
+
SafeAreaProvider,
|
|
5
|
+
SafeAreaView,
|
|
6
|
+
useSafeAreaInsets,
|
|
7
|
+
} from 'react-native-safe-area-context';
|
|
8
|
+
import { FAB, useTheme } from '../../src/index';
|
|
9
|
+
|
|
10
|
+
const FABPlayground = (): JSX.Element => {
|
|
11
|
+
const [active, setActive] = useState(false);
|
|
12
|
+
const insets = useSafeAreaInsets();
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<SafeAreaProvider>
|
|
17
|
+
<SafeAreaView style={{ flex: 1 }} edges={['right', 'left']}>
|
|
18
|
+
<FAB
|
|
19
|
+
icon="add"
|
|
20
|
+
onPress={() => {
|
|
21
|
+
setActive(!active);
|
|
22
|
+
}}
|
|
23
|
+
animated
|
|
24
|
+
active={active}
|
|
25
|
+
style={{
|
|
26
|
+
position: 'absolute',
|
|
27
|
+
bottom: Math.max(insets.bottom, theme.space.large),
|
|
28
|
+
right: theme.space.large,
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
|
|
32
|
+
<FAB
|
|
33
|
+
icon="share-1"
|
|
34
|
+
onPress={() => {
|
|
35
|
+
alert('button pressed');
|
|
36
|
+
}}
|
|
37
|
+
style={{
|
|
38
|
+
backgroundColor: theme.colors.primary,
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
bottom: Math.max(insets.bottom, theme.space.large),
|
|
41
|
+
left: theme.space.large,
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
</SafeAreaView>
|
|
45
|
+
</SafeAreaProvider>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default FABPlayground;
|
package/playground/index.tsx
CHANGED
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
NativeStackScreenProps,
|
|
7
7
|
} from '@react-navigation/native-stack';
|
|
8
8
|
import { useFonts } from 'expo-font';
|
|
9
|
-
/* eslint-enable import/no-extraneous-dependencies */
|
|
10
9
|
import { SafeAreaView, FlatList, Text } from 'react-native';
|
|
11
10
|
import { ThemeProvider, theme, useTheme } from '../src/index';
|
|
12
11
|
import BadgePlayground from './components/Badge';
|
|
@@ -14,6 +13,7 @@ import CardPlayground from './components/Card';
|
|
|
14
13
|
import DividerPlayground from './components/Divider';
|
|
15
14
|
import IconPlayground from './components/Icon';
|
|
16
15
|
import TypographyPlayground from './components/Typography';
|
|
16
|
+
import FABPlayground from './components/FAB';
|
|
17
17
|
|
|
18
18
|
const heroIconFontPath = require('../assets/fonts/hero-icons.ttf');
|
|
19
19
|
|
|
@@ -24,6 +24,7 @@ type RootStackParamList = {
|
|
|
24
24
|
Divider: undefined;
|
|
25
25
|
Icon: undefined;
|
|
26
26
|
Typography: undefined;
|
|
27
|
+
FAB: undefined;
|
|
27
28
|
};
|
|
28
29
|
|
|
29
30
|
type Navigation = NativeStackScreenProps<RootStackParamList>;
|
|
@@ -36,6 +37,7 @@ const components = [
|
|
|
36
37
|
{ name: 'Divider', component: DividerPlayground },
|
|
37
38
|
{ name: 'Icon', component: IconPlayground },
|
|
38
39
|
{ name: 'Typography', component: TypographyPlayground },
|
|
40
|
+
{ name: 'FAB', component: FABPlayground },
|
|
39
41
|
] as const;
|
|
40
42
|
|
|
41
43
|
const ComponentItem = ({
|
package/rollup.config.js
CHANGED
|
@@ -4,6 +4,7 @@ import { babel } from '@rollup/plugin-babel';
|
|
|
4
4
|
import typescript from '@rollup/plugin-typescript';
|
|
5
5
|
import json from '@rollup/plugin-json';
|
|
6
6
|
import replace from '@rollup/plugin-replace';
|
|
7
|
+
import copy from 'rollup-plugin-copy';
|
|
7
8
|
|
|
8
9
|
import pkg from './package.json';
|
|
9
10
|
|
|
@@ -23,13 +24,21 @@ export default {
|
|
|
23
24
|
],
|
|
24
25
|
external: ['react', 'react-native'],
|
|
25
26
|
plugins: [
|
|
26
|
-
replace(
|
|
27
|
+
replace({
|
|
27
28
|
'process.env.NODE_ENV': JSON.stringify('production'),
|
|
28
|
-
})
|
|
29
|
+
}),
|
|
29
30
|
nodeResolve({ extensions, browser: true }),
|
|
30
31
|
commonjs(),
|
|
31
32
|
json(),
|
|
32
33
|
typescript(),
|
|
33
34
|
babel({ extensions, babelHelpers: 'bundled' }),
|
|
35
|
+
copy({
|
|
36
|
+
targets: [
|
|
37
|
+
{
|
|
38
|
+
src: 'assets/fonts/hero-icons.ttf',
|
|
39
|
+
dest: 'lib/assets/fonts',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
}),
|
|
34
43
|
],
|
|
35
44
|
};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { StyleProp, ViewStyle } from 'react-native';
|
|
1
|
+
import { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
2
2
|
import React, { ReactElement } from 'react';
|
|
3
3
|
import { StyledView, StyledText } from './StyledBadge';
|
|
4
4
|
|
|
5
|
-
interface BadgeProps {
|
|
5
|
+
interface BadgeProps extends ViewProps {
|
|
6
6
|
/**
|
|
7
|
-
* Content of the
|
|
7
|
+
* Content of the Badge.
|
|
8
8
|
*/
|
|
9
9
|
content: string;
|
|
10
10
|
/**
|
|
11
|
-
* Visual intent color to apply to
|
|
11
|
+
* Visual intent color to apply to Badge.
|
|
12
12
|
*/
|
|
13
13
|
intent?: 'success' | 'warning' | 'danger' | 'info';
|
|
14
14
|
/**
|
|
15
|
-
* Addditional style
|
|
15
|
+
* Addditional style.
|
|
16
16
|
*/
|
|
17
17
|
style?: StyleProp<ViewStyle>;
|
|
18
18
|
/**
|
|
@@ -26,8 +26,14 @@ const Badge = ({
|
|
|
26
26
|
intent = 'info',
|
|
27
27
|
style,
|
|
28
28
|
testID,
|
|
29
|
+
...nativeProps
|
|
29
30
|
}: BadgeProps): ReactElement => (
|
|
30
|
-
<StyledView
|
|
31
|
+
<StyledView
|
|
32
|
+
themeIntent={intent}
|
|
33
|
+
style={style}
|
|
34
|
+
testID={testID}
|
|
35
|
+
{...nativeProps}
|
|
36
|
+
>
|
|
31
37
|
<StyledText themeIntent={intent}>{content}</StyledText>
|
|
32
38
|
</StyledView>
|
|
33
39
|
);
|
|
@@ -20,10 +20,10 @@ exports[`Card renders correct 1`] = `
|
|
|
20
20
|
"borderBottomRightRadius": 12,
|
|
21
21
|
"borderTopLeftRadius": 12,
|
|
22
22
|
"borderTopRightRadius": 12,
|
|
23
|
-
"paddingBottom":
|
|
24
|
-
"paddingLeft":
|
|
25
|
-
"paddingRight":
|
|
26
|
-
"paddingTop":
|
|
23
|
+
"paddingBottom": 8,
|
|
24
|
+
"paddingLeft": 8,
|
|
25
|
+
"paddingRight": 8,
|
|
26
|
+
"paddingTop": 8,
|
|
27
27
|
},
|
|
28
28
|
Object {
|
|
29
29
|
"backgroundColor": "#292a2b",
|
|
@@ -8,10 +8,10 @@ exports[`StyledCard renders correct style 1`] = `
|
|
|
8
8
|
"borderBottomRightRadius": 12,
|
|
9
9
|
"borderTopLeftRadius": 12,
|
|
10
10
|
"borderTopRightRadius": 12,
|
|
11
|
-
"paddingBottom":
|
|
12
|
-
"paddingLeft":
|
|
13
|
-
"paddingRight":
|
|
14
|
-
"paddingTop":
|
|
11
|
+
"paddingBottom": 8,
|
|
12
|
+
"paddingLeft": 8,
|
|
13
|
+
"paddingRight": 8,
|
|
14
|
+
"paddingTop": 8,
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
/>
|
|
@@ -1,8 +1,21 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { ViewProps } from 'react-native';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
3
3
|
import { StyledCard } from './StyledCard';
|
|
4
4
|
|
|
5
|
-
interface CardProps extends ViewProps {
|
|
5
|
+
interface CardProps extends ViewProps {
|
|
6
|
+
/**
|
|
7
|
+
* Card's content.
|
|
8
|
+
*/
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Addditional style.
|
|
12
|
+
*/
|
|
13
|
+
style?: StyleProp<ViewStyle>;
|
|
14
|
+
/**
|
|
15
|
+
* Testing id of the component.
|
|
16
|
+
*/
|
|
17
|
+
testID?: string;
|
|
18
|
+
}
|
|
6
19
|
|
|
7
20
|
const Card = (props: CardProps): JSX.Element => <StyledCard {...props} />;
|
|
8
21
|
|
|
@@ -8,7 +8,7 @@ const StyledDivider = styled(View)<{
|
|
|
8
8
|
themeMarginVertical?: MarginSize;
|
|
9
9
|
}>`
|
|
10
10
|
border-bottom-width: ${({ theme }) =>
|
|
11
|
-
theme.__hd__.divider.
|
|
11
|
+
theme.__hd__.divider.borderWidths.default};
|
|
12
12
|
border-bottom-color: ${({ theme }) => theme.__hd__.divider.colors.default};
|
|
13
13
|
max-width: 100%;
|
|
14
14
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
2
3
|
import { StyledDivider } from './StyledDivider';
|
|
3
4
|
|
|
4
|
-
interface DividerProps {
|
|
5
|
+
interface DividerProps extends ViewProps {
|
|
5
6
|
/**
|
|
6
7
|
* Horizontal margin size. There is no margin by default.
|
|
7
8
|
*/
|
|
@@ -10,12 +11,29 @@ interface DividerProps {
|
|
|
10
11
|
* Vertical margin size. There is no margin by default.
|
|
11
12
|
*/
|
|
12
13
|
marginVertical?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
|
|
14
|
+
/**
|
|
15
|
+
* Addditional style.
|
|
16
|
+
*/
|
|
17
|
+
style?: StyleProp<ViewStyle>;
|
|
18
|
+
/**
|
|
19
|
+
* Testing id of the component.
|
|
20
|
+
*/
|
|
21
|
+
testID?: string;
|
|
13
22
|
}
|
|
14
23
|
|
|
15
|
-
const Divider = ({
|
|
24
|
+
const Divider = ({
|
|
25
|
+
marginHorizontal,
|
|
26
|
+
marginVertical,
|
|
27
|
+
style,
|
|
28
|
+
testID,
|
|
29
|
+
...nativeProps
|
|
30
|
+
}: DividerProps) => (
|
|
16
31
|
<StyledDivider
|
|
17
32
|
themeMarginHorizontal={marginHorizontal}
|
|
18
33
|
themeMarginVertical={marginVertical}
|
|
34
|
+
style={style}
|
|
35
|
+
testID={testID}
|
|
36
|
+
{...nativeProps}
|
|
19
37
|
/>
|
|
20
38
|
);
|
|
21
39
|
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated, StyleSheet } from 'react-native';
|
|
3
|
+
import { IconProps } from '../Icon';
|
|
4
|
+
import { StyledFABIcon } from './StyledFABIcon';
|
|
5
|
+
|
|
6
|
+
const AnimatedIcons = Animated.createAnimatedComponent(StyledFABIcon);
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
active?: boolean;
|
|
10
|
+
} & IconProps;
|
|
11
|
+
|
|
12
|
+
const AnimatedFABIcon = ({ active, ...iconProps }: Props) => {
|
|
13
|
+
const rotateAnimation = useRef<Animated.Value>(
|
|
14
|
+
new Animated.Value(active ? 1 : 0)
|
|
15
|
+
);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
const animation = Animated.timing(rotateAnimation.current, {
|
|
18
|
+
toValue: active ? 1 : 0,
|
|
19
|
+
useNativeDriver: true,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
animation.start();
|
|
23
|
+
|
|
24
|
+
return () => {
|
|
25
|
+
animation.stop();
|
|
26
|
+
};
|
|
27
|
+
}, [active]);
|
|
28
|
+
|
|
29
|
+
const interpolatedRotateAnimation = rotateAnimation.current.interpolate({
|
|
30
|
+
inputRange: [0, 1],
|
|
31
|
+
outputRange: ['0deg', '-45deg'],
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Animated.View
|
|
36
|
+
style={StyleSheet.flatten([
|
|
37
|
+
{
|
|
38
|
+
transform: [{ rotate: interpolatedRotateAnimation }],
|
|
39
|
+
},
|
|
40
|
+
])}
|
|
41
|
+
>
|
|
42
|
+
<AnimatedIcons {...iconProps} />
|
|
43
|
+
</Animated.View>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { AnimatedFABIcon };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { TouchableHighlight, TouchableHighlightProps } from 'react-native';
|
|
2
|
+
import styled from 'styled-components-native';
|
|
3
|
+
|
|
4
|
+
const StyledFABContainer = styled(TouchableHighlight)<TouchableHighlightProps>`
|
|
5
|
+
height: ${({ theme }) => theme.__hd__.fab.sizes.height};
|
|
6
|
+
width: ${({ theme }) => theme.__hd__.fab.sizes.width};
|
|
7
|
+
background-color: ${({ theme }) => theme.__hd__.fab.colors.buttonBackground};
|
|
8
|
+
border-radius: 999px;
|
|
9
|
+
align-items: center;
|
|
10
|
+
justify-content: center;
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export { StyledFABContainer };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import styled from 'styled-components-native';
|
|
2
|
+
import Icon, { IconProps } from '../Icon';
|
|
3
|
+
|
|
4
|
+
const StyledFABIcon = styled(Icon)<IconProps>`
|
|
5
|
+
color: ${({ theme }) => theme.__hd__.fab.colors.icon};
|
|
6
|
+
font-size: ${({ theme }) => theme.__hd__.fab.fontSizes.default};
|
|
7
|
+
`;
|
|
8
|
+
|
|
9
|
+
export { StyledFABIcon };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme } from '../../../index';
|
|
4
|
+
import { AnimatedFABIcon } from '../AnimatedFABIcon';
|
|
5
|
+
|
|
6
|
+
describe('AnimatedFABIcon', () => {
|
|
7
|
+
it.each`
|
|
8
|
+
active
|
|
9
|
+
${true}
|
|
10
|
+
${false}
|
|
11
|
+
`('renders correctly when isActive is $active', ({ active }) => {
|
|
12
|
+
const { toJSON } = render(
|
|
13
|
+
<ThemeProvider theme={theme}>
|
|
14
|
+
<AnimatedFABIcon active={active} icon="add" />
|
|
15
|
+
</ThemeProvider>
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
expect(toJSON()).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme, Typography } from '../../../index';
|
|
4
|
+
import { StyledFABContainer } from '../StyledFABContainer';
|
|
5
|
+
|
|
6
|
+
describe('StyledFABContainer', () => {
|
|
7
|
+
it('renders correctly', () => {
|
|
8
|
+
const { toJSON } = render(
|
|
9
|
+
<ThemeProvider theme={theme}>
|
|
10
|
+
<StyledFABContainer>
|
|
11
|
+
<Typography.Text> button </Typography.Text>
|
|
12
|
+
</StyledFABContainer>
|
|
13
|
+
</ThemeProvider>
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
expect(toJSON()).toMatchSnapshot();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme } from '../../../index';
|
|
4
|
+
import { StyledFABIcon } from '../StyledFABIcon';
|
|
5
|
+
|
|
6
|
+
describe('StyledFABIcon', () => {
|
|
7
|
+
it('renders correctly', () => {
|
|
8
|
+
const { toJSON } = render(
|
|
9
|
+
<ThemeProvider theme={theme}>
|
|
10
|
+
<StyledFABIcon icon="add" />
|
|
11
|
+
</ThemeProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
expect(toJSON()).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
});
|