@hero-design/rn 6.8.0 → 7.0.2
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 +1 -0
- package/.expo/README.md +15 -0
- package/.expo/packager-info.json +10 -0
- package/.expo/settings.json +10 -0
- package/app.json +4 -0
- package/assets/fonts/hero-icons.ttf +0 -0
- package/es/index.js +10053 -131
- package/jest.config.js +5 -0
- package/lib/index.js +10057 -130
- package/package.json +24 -4
- package/playground/components/Badge.tsx +50 -0
- package/playground/components/Card.tsx +52 -0
- package/playground/components/Icon.tsx +140 -0
- package/playground/components/Typography.tsx +21 -0
- package/playground/index.tsx +42 -9
- package/react-native.config.js +5 -0
- package/src/components/Badge/StyledBadge.tsx +34 -0
- package/src/components/Badge/__tests__/Badge.spec.tsx +50 -0
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +161 -0
- package/src/components/Badge/index.tsx +35 -0
- package/src/components/Card/StyledCard.tsx +9 -0
- package/src/components/Card/__tests__/Card.spec.tsx +36 -0
- package/src/components/Card/__tests__/StyledCard.spec.tsx +15 -0
- package/src/components/Card/__tests__/__snapshots__/Card.spec.tsx.snap +39 -0
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +18 -0
- package/src/components/Card/index.tsx +9 -0
- package/src/components/Icon/HeroIcon/index.tsx +30 -0
- package/src/components/Icon/HeroIcon/selection.json +1 -0
- package/src/components/Icon/IconList.ts +298 -0
- package/src/components/Icon/__tests__/Icon.spec.tsx +36 -0
- package/src/components/Icon/__tests__/__snapshots__/Icon.spec.tsx.snap +43 -0
- package/src/components/Icon/index.tsx +47 -0
- package/src/components/Typography/Text/StyledText.tsx +69 -0
- package/src/components/Typography/Text/__test__/StyledText.spec.tsx +62 -0
- package/src/components/Typography/Text/__test__/__snapshots__/StyledText.spec.tsx.snap +172 -0
- package/src/components/Typography/Text/__test__/index.spec.tsx +11 -0
- package/src/components/Typography/Text/index.tsx +41 -0
- package/src/components/Typography/index.tsx +11 -0
- package/src/index.ts +15 -1
- package/src/testHelpers/renderWithTheme.tsx +8 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +79 -0
- package/src/theme/components/badge.ts +38 -0
- package/src/theme/components/card.ts +15 -0
- package/src/theme/components/icon.ts +24 -0
- package/src/theme/components/typography.ts +32 -0
- package/src/theme/global/typography.ts +4 -0
- package/src/theme/index.ts +12 -0
- package/testUtils/setup.ts +3 -0
- package/tsconfig.json +2 -6
- package/types/components/ExampleComponent/StyledView.d.ts +7 -0
- package/types/components/{Divider/__tests__/StyledDivider.spec.d.ts → ExampleComponent/__tests__/StyledView.spec.d.ts} +0 -0
- package/types/components/ExampleComponent/index.d.ts +16 -0
- package/types/index.d.ts +3 -3
- package/types/playground/components/Badge.d.ts +2 -0
- package/types/playground/components/Card.d.ts +2 -0
- package/types/playground/components/Divider.d.ts +2 -0
- package/types/playground/components/Icon.d.ts +2 -0
- package/types/playground/components/Typography.d.ts +2 -0
- package/types/playground/index.d.ts +2 -0
- package/types/src/components/Badge/StyledBadge.d.ts +9 -0
- package/types/{theme/__tests__/index.spec.d.ts → src/components/Badge/__tests__/Badge.spec.d.ts} +0 -0
- package/types/src/components/Badge/index.d.ts +22 -0
- package/types/src/components/Card/StyledCard.d.ts +3 -0
- package/types/src/components/Card/__tests__/Card.spec.d.ts +1 -0
- package/types/src/components/Card/__tests__/StyledCard.spec.d.ts +1 -0
- package/types/src/components/Card/index.d.ts +5 -0
- package/types/{components → src/components}/Divider/StyledDivider.d.ts +0 -0
- package/types/src/components/Divider/__tests__/StyledDivider.spec.d.ts +1 -0
- package/types/{components → src/components}/Divider/index.d.ts +0 -0
- package/types/src/components/Icon/HeroIcon/index.d.ts +7 -0
- package/types/src/components/Icon/IconList.d.ts +2 -0
- package/types/src/components/Icon/__tests__/Icon.spec.d.ts +1 -0
- package/types/src/components/Icon/index.d.ts +27 -0
- package/types/src/components/Typography/Text/StyledText.d.ts +7 -0
- package/types/src/components/Typography/Text/__test__/StyledText.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/__test__/index.spec.d.ts +1 -0
- package/types/src/components/Typography/Text/index.d.ts +22 -0
- package/types/src/components/Typography/index.d.ts +6 -0
- package/types/src/index.d.ts +8 -0
- package/types/src/styled-components.d.ts +6 -0
- package/types/src/testHelpers/renderWithTheme.d.ts +3 -0
- package/types/src/theme/__tests__/index.spec.d.ts +1 -0
- package/types/src/theme/components/badge.d.ts +29 -0
- package/types/src/theme/components/card.d.ts +10 -0
- package/types/{theme → src/theme}/components/divider.d.ts +0 -0
- package/types/src/theme/components/icon.d.ts +19 -0
- package/types/src/theme/components/typography.d.ts +25 -0
- package/types/{theme → src/theme}/global/borders.d.ts +0 -0
- package/types/src/theme/global/colors.d.ts +26 -0
- package/types/src/theme/global/index.d.ts +67 -0
- package/types/src/theme/global/space.d.ts +12 -0
- package/types/src/theme/global/typography.d.ts +25 -0
- package/types/src/theme/index.d.ts +19 -0
- package/types/theme/colors.d.ts +24 -0
- package/types/theme/components/demoStyle.d.ts +11 -0
- package/types/theme/components/exampleComponent.d.ts +14 -0
- package/types/theme/global/colors.d.ts +0 -2
- package/types/theme/global/index.d.ts +0 -5
- package/types/theme/index.d.ts +2 -2
- package/types/theme/space.d.ts +12 -0
- package/types/theme/typography.d.ts +21 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -9,19 +9,21 @@
|
|
|
9
9
|
"lint": "eslint src playground --ext .js,.jsx,.ts,.tsx --ignore-path ../../.gitignore",
|
|
10
10
|
"type-check": "tsc --noEmit",
|
|
11
11
|
"dev": "expo start",
|
|
12
|
-
"test": "jest --runInBand",
|
|
12
|
+
"test": "jest --runInBand --watch",
|
|
13
|
+
"test:ci": "jest --runInBand --logHeapUsage",
|
|
13
14
|
"build:js": "rollup -c",
|
|
14
15
|
"build:types": "tsc --noEmit false --emitDeclarationOnly",
|
|
15
16
|
"build": "yarn build:js && yarn build:types",
|
|
16
17
|
"publish:npm": "yarn publish --access public"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@hero-design/colors": "
|
|
20
|
+
"@hero-design/colors": "7.0.2",
|
|
20
21
|
"styled-components": "6.0.0-alpha.5"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
24
|
"react": "17.0.2",
|
|
24
|
-
"react-native": "0.65.1"
|
|
25
|
+
"react-native": "0.65.1",
|
|
26
|
+
"react-native-vector-icons": "^9.1.0"
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|
|
27
29
|
"@babel/core": "^7.17.5",
|
|
@@ -41,6 +43,7 @@
|
|
|
41
43
|
"@types/jest": "^27.0.2",
|
|
42
44
|
"@types/react": "^17.0.39",
|
|
43
45
|
"@types/react-native": "^0.66.16",
|
|
46
|
+
"@types/react-native-vector-icons": "^6.4.10",
|
|
44
47
|
"@types/styled-components": "^5.1.24",
|
|
45
48
|
"@types/styled-components-react-native": "^5.1.3",
|
|
46
49
|
"@typescript-eslint/eslint-plugin": "^5.12.1",
|
|
@@ -61,6 +64,7 @@
|
|
|
61
64
|
"react-native": "0.65.1",
|
|
62
65
|
"react-native-safe-area-context": "^4.2.5",
|
|
63
66
|
"react-native-screens": "^3.13.1",
|
|
67
|
+
"react-native-vector-icons": "^9.1.0",
|
|
64
68
|
"react-test-renderer": "17.0.2",
|
|
65
69
|
"rollup": "^2.68.0",
|
|
66
70
|
"ts-jest": "^27.0.7",
|
|
@@ -77,6 +81,22 @@
|
|
|
77
81
|
]
|
|
78
82
|
},
|
|
79
83
|
"lint": {
|
|
84
|
+
"dependsOn": [
|
|
85
|
+
{
|
|
86
|
+
"target": "build:js",
|
|
87
|
+
"projects": "dependencies"
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
"test:ci": {
|
|
92
|
+
"dependsOn": [
|
|
93
|
+
{
|
|
94
|
+
"target": "build",
|
|
95
|
+
"projects": "dependencies"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"dev": {
|
|
80
100
|
"dependsOn": [
|
|
81
101
|
{
|
|
82
102
|
"target": "build",
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Badge, useTheme } from '../../src/index';
|
|
4
|
+
|
|
5
|
+
const BadgePlayground = () => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<View
|
|
10
|
+
style={{
|
|
11
|
+
marginVertical: theme.space.medium,
|
|
12
|
+
marginHorizontal: theme.space.medium,
|
|
13
|
+
}}
|
|
14
|
+
>
|
|
15
|
+
<View
|
|
16
|
+
style={{
|
|
17
|
+
display: 'flex',
|
|
18
|
+
flexDirection: 'row',
|
|
19
|
+
marginBottom: theme.space.small,
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
<Badge
|
|
23
|
+
content="APPROVED"
|
|
24
|
+
intent="success"
|
|
25
|
+
style={{ marginEnd: theme.space.small }}
|
|
26
|
+
/>
|
|
27
|
+
<Badge
|
|
28
|
+
content="PENDING"
|
|
29
|
+
intent="warning"
|
|
30
|
+
style={{ marginEnd: theme.space.small }}
|
|
31
|
+
/>
|
|
32
|
+
</View>
|
|
33
|
+
<View
|
|
34
|
+
style={{
|
|
35
|
+
display: 'flex',
|
|
36
|
+
flexDirection: 'row',
|
|
37
|
+
}}
|
|
38
|
+
>
|
|
39
|
+
<Badge
|
|
40
|
+
content="DECLINED"
|
|
41
|
+
intent="danger"
|
|
42
|
+
style={{ marginEnd: theme.space.small }}
|
|
43
|
+
/>
|
|
44
|
+
<Badge content="SUBMITTED" style={{ marginEnd: theme.space.small }} />
|
|
45
|
+
</View>
|
|
46
|
+
</View>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export default BadgePlayground;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Card, useTheme } from '../../src/index';
|
|
4
|
+
|
|
5
|
+
const CardPlayground = () => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
return (
|
|
8
|
+
<View
|
|
9
|
+
style={{
|
|
10
|
+
flex: 1,
|
|
11
|
+
marginVertical: theme.space.xxxxlarge,
|
|
12
|
+
marginHorizontal: theme.space.xxxxlarge,
|
|
13
|
+
}}
|
|
14
|
+
>
|
|
15
|
+
<Card
|
|
16
|
+
style={{
|
|
17
|
+
flex: 1,
|
|
18
|
+
backgroundColor: theme.colors.backgroundDark,
|
|
19
|
+
padding: theme.space.medium,
|
|
20
|
+
}}
|
|
21
|
+
>
|
|
22
|
+
<Card
|
|
23
|
+
style={{ flex: 1, backgroundColor: theme.colors.backgroundLight }}
|
|
24
|
+
/>
|
|
25
|
+
<Card
|
|
26
|
+
style={{ flex: 1, backgroundColor: theme.colors.infoBackground }}
|
|
27
|
+
/>
|
|
28
|
+
<Card style={{ flex: 1, backgroundColor: theme.colors.primaryLight }} />
|
|
29
|
+
</Card>
|
|
30
|
+
|
|
31
|
+
<Card
|
|
32
|
+
style={{
|
|
33
|
+
flex: 1,
|
|
34
|
+
backgroundColor: theme.colors.backgroundDark,
|
|
35
|
+
padding: theme.space.medium,
|
|
36
|
+
flexDirection: 'row',
|
|
37
|
+
marginTop: theme.space.large,
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<Card
|
|
41
|
+
style={{ flex: 1, backgroundColor: theme.colors.backgroundLight }}
|
|
42
|
+
/>
|
|
43
|
+
<Card
|
|
44
|
+
style={{ flex: 1, backgroundColor: theme.colors.infoBackground }}
|
|
45
|
+
/>
|
|
46
|
+
<Card style={{ flex: 1, backgroundColor: theme.colors.primaryLight }} />
|
|
47
|
+
</Card>
|
|
48
|
+
</View>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export default CardPlayground;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScrollView, View } from 'react-native';
|
|
3
|
+
import { Typography, Icon, useTheme } from '../../src/index';
|
|
4
|
+
|
|
5
|
+
const IconPlayground = () => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<ScrollView
|
|
10
|
+
contentContainerStyle={{
|
|
11
|
+
padding: theme.space.medium,
|
|
12
|
+
}}
|
|
13
|
+
>
|
|
14
|
+
<Typography.Text style={{ marginBottom: theme.space.xsmall }}>
|
|
15
|
+
Bottom nav - active
|
|
16
|
+
</Typography.Text>
|
|
17
|
+
<View style={{ flexDirection: 'row', marginBottom: theme.space.large }}>
|
|
18
|
+
<Icon icon="home" style={{ marginEnd: theme.space.medium }} />
|
|
19
|
+
<Icon icon="speaker" style={{ marginEnd: theme.space.medium }} />
|
|
20
|
+
<Icon icon="bell" style={{ marginEnd: theme.space.medium }} />
|
|
21
|
+
<Icon icon="user" />
|
|
22
|
+
</View>
|
|
23
|
+
|
|
24
|
+
<Typography.Text style={{ marginBottom: theme.space.xsmall }}>
|
|
25
|
+
Bottom nav - inactive
|
|
26
|
+
</Typography.Text>
|
|
27
|
+
<View style={{ flexDirection: 'row', marginBottom: theme.space.large }}>
|
|
28
|
+
<Icon icon="home-outlined" style={{ marginEnd: theme.space.medium }} />
|
|
29
|
+
<Icon
|
|
30
|
+
icon="speaker-outlined"
|
|
31
|
+
style={{ marginEnd: theme.space.medium }}
|
|
32
|
+
/>
|
|
33
|
+
<Icon icon="bell-outlined" style={{ marginEnd: theme.space.medium }} />
|
|
34
|
+
<Icon icon="user-outlined" />
|
|
35
|
+
</View>
|
|
36
|
+
|
|
37
|
+
<Typography.Text style={{ marginBottom: theme.space.xsmall }}>
|
|
38
|
+
Dashboard - widgets
|
|
39
|
+
</Typography.Text>
|
|
40
|
+
<View style={{ flexDirection: 'row', marginBottom: theme.space.large }}>
|
|
41
|
+
<Icon icon="coin" style={{ marginEnd: theme.space.medium }} />
|
|
42
|
+
<Icon icon="calendar-clock" style={{ marginEnd: theme.space.medium }} />
|
|
43
|
+
<Icon icon="file-certified" style={{ marginEnd: theme.space.medium }} />
|
|
44
|
+
<Icon icon="file-secured" style={{ marginEnd: theme.space.medium }} />
|
|
45
|
+
<Icon icon="file-verified" />
|
|
46
|
+
</View>
|
|
47
|
+
|
|
48
|
+
<Typography.Text style={{ marginBottom: theme.space.xsmall }}>
|
|
49
|
+
Top nav
|
|
50
|
+
</Typography.Text>
|
|
51
|
+
<View style={{ flexDirection: 'row', marginBottom: theme.space.large }}>
|
|
52
|
+
<Icon icon="suitcase" style={{ marginEnd: theme.space.medium }} />
|
|
53
|
+
<Icon icon="credit-card" />
|
|
54
|
+
</View>
|
|
55
|
+
|
|
56
|
+
<Typography.Text style={{ marginBottom: theme.space.xsmall }}>
|
|
57
|
+
FAB icons
|
|
58
|
+
</Typography.Text>
|
|
59
|
+
<View style={{ flexDirection: 'row', marginBottom: theme.space.large }}>
|
|
60
|
+
<Icon icon="plane" style={{ marginEnd: theme.space.medium }} />
|
|
61
|
+
<Icon icon="reply" style={{ marginEnd: theme.space.medium }} />
|
|
62
|
+
<Icon icon="health-bag" style={{ marginEnd: theme.space.medium }} />
|
|
63
|
+
<Icon icon="clock" style={{ marginEnd: theme.space.medium }} />
|
|
64
|
+
<Icon icon="target" style={{ marginEnd: theme.space.medium }} />
|
|
65
|
+
<Icon icon="speaker" />
|
|
66
|
+
</View>
|
|
67
|
+
|
|
68
|
+
<Typography.Text style={{ marginBottom: theme.space.xsmall }}>
|
|
69
|
+
Icon with colors
|
|
70
|
+
</Typography.Text>
|
|
71
|
+
<View style={{ flexDirection: 'row', marginBottom: theme.space.large }}>
|
|
72
|
+
<Icon
|
|
73
|
+
icon="plane"
|
|
74
|
+
intent="text"
|
|
75
|
+
style={{ marginEnd: theme.space.medium }}
|
|
76
|
+
/>
|
|
77
|
+
<Icon
|
|
78
|
+
icon="reply"
|
|
79
|
+
intent="primary"
|
|
80
|
+
style={{ marginEnd: theme.space.medium }}
|
|
81
|
+
/>
|
|
82
|
+
<Icon
|
|
83
|
+
icon="health-bag"
|
|
84
|
+
intent="info"
|
|
85
|
+
style={{ marginEnd: theme.space.medium }}
|
|
86
|
+
/>
|
|
87
|
+
<Icon
|
|
88
|
+
icon="clock"
|
|
89
|
+
intent="danger"
|
|
90
|
+
style={{ marginEnd: theme.space.medium }}
|
|
91
|
+
/>
|
|
92
|
+
<Icon
|
|
93
|
+
icon="target"
|
|
94
|
+
intent="success"
|
|
95
|
+
style={{ marginEnd: theme.space.medium }}
|
|
96
|
+
/>
|
|
97
|
+
<Icon icon="speaker" intent="warning" />
|
|
98
|
+
</View>
|
|
99
|
+
|
|
100
|
+
<Typography.Text style={{ marginBottom: theme.space.xsmall }}>
|
|
101
|
+
Icon with different sizes
|
|
102
|
+
</Typography.Text>
|
|
103
|
+
<View
|
|
104
|
+
style={{
|
|
105
|
+
flexDirection: 'row',
|
|
106
|
+
marginBottom: theme.space.large,
|
|
107
|
+
alignItems: 'flex-end',
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
<Icon
|
|
111
|
+
icon="activate"
|
|
112
|
+
intent="text"
|
|
113
|
+
size="xsmall"
|
|
114
|
+
style={{ marginEnd: theme.space.medium }}
|
|
115
|
+
/>
|
|
116
|
+
<Icon
|
|
117
|
+
icon="add-person"
|
|
118
|
+
intent="primary"
|
|
119
|
+
size="small"
|
|
120
|
+
style={{ marginEnd: theme.space.medium }}
|
|
121
|
+
/>
|
|
122
|
+
<Icon
|
|
123
|
+
icon="adjustment"
|
|
124
|
+
intent="info"
|
|
125
|
+
size="medium"
|
|
126
|
+
style={{ marginEnd: theme.space.medium }}
|
|
127
|
+
/>
|
|
128
|
+
<Icon
|
|
129
|
+
icon="alignment"
|
|
130
|
+
intent="danger"
|
|
131
|
+
size="large"
|
|
132
|
+
style={{ marginEnd: theme.space.medium }}
|
|
133
|
+
/>
|
|
134
|
+
<Icon icon="bank" intent="success" size="xlarge" />
|
|
135
|
+
</View>
|
|
136
|
+
</ScrollView>
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export default IconPlayground;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { Typography, useTheme } from '../../src/index';
|
|
4
|
+
|
|
5
|
+
const TypographyPlayground = () => {
|
|
6
|
+
const theme = useTheme();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<View style={{ padding: theme.space.large }}>
|
|
10
|
+
<Typography.Text fontSize="xlarge" fontWeight="semi-bold">
|
|
11
|
+
This is a title
|
|
12
|
+
</Typography.Text>
|
|
13
|
+
<Typography.Text fontSize="large">This is a subtitle</Typography.Text>
|
|
14
|
+
<Typography.Text>This is a 2nd subtitle</Typography.Text>
|
|
15
|
+
<Typography.Text>This is body text</Typography.Text>
|
|
16
|
+
<Typography.Text intent="subdued">This is body text</Typography.Text>
|
|
17
|
+
</View>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default TypographyPlayground;
|
package/playground/index.tsx
CHANGED
|
@@ -1,17 +1,42 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
/* eslint-disable import/no-extraneous-dependencies */
|
|
3
|
+
import { NavigationContainer, DefaultTheme } from '@react-navigation/native';
|
|
4
|
+
import {
|
|
5
|
+
createNativeStackNavigator,
|
|
6
|
+
NativeStackScreenProps,
|
|
7
|
+
} from '@react-navigation/native-stack';
|
|
8
|
+
import { useFonts } from 'expo-font';
|
|
9
|
+
/* eslint-enable import/no-extraneous-dependencies */
|
|
10
|
+
import { SafeAreaView, FlatList, Text } from 'react-native';
|
|
5
11
|
import { ThemeProvider, theme, useTheme } from '../src/index';
|
|
12
|
+
import BadgePlayground from './components/Badge';
|
|
13
|
+
import CardPlayground from './components/Card';
|
|
6
14
|
import DividerPlayground from './components/Divider';
|
|
15
|
+
import IconPlayground from './components/Icon';
|
|
16
|
+
import TypographyPlayground from './components/Typography';
|
|
7
17
|
|
|
8
|
-
|
|
18
|
+
const heroIconFontPath = require('../assets/fonts/hero-icons.ttf');
|
|
9
19
|
|
|
10
|
-
|
|
20
|
+
type RootStackParamList = {
|
|
21
|
+
Home: undefined;
|
|
22
|
+
Badge: undefined;
|
|
23
|
+
Card: undefined;
|
|
24
|
+
Divider: undefined;
|
|
25
|
+
Icon: undefined;
|
|
26
|
+
Typography: undefined;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
type Navigation = NativeStackScreenProps<RootStackParamList>;
|
|
30
|
+
|
|
31
|
+
const Stack = createNativeStackNavigator<RootStackParamList>();
|
|
11
32
|
|
|
12
|
-
const components
|
|
33
|
+
const components = [
|
|
34
|
+
{ name: 'Badge', component: BadgePlayground },
|
|
35
|
+
{ name: 'Card', component: CardPlayground },
|
|
13
36
|
{ name: 'Divider', component: DividerPlayground },
|
|
14
|
-
|
|
37
|
+
{ name: 'Icon', component: IconPlayground },
|
|
38
|
+
{ name: 'Typography', component: TypographyPlayground },
|
|
39
|
+
] as const;
|
|
15
40
|
|
|
16
41
|
const ComponentItem = ({
|
|
17
42
|
name,
|
|
@@ -34,13 +59,13 @@ const ComponentItem = ({
|
|
|
34
59
|
);
|
|
35
60
|
};
|
|
36
61
|
|
|
37
|
-
const ComponentList = ({ navigation }) => {
|
|
62
|
+
const ComponentList = ({ navigation }: Navigation) => {
|
|
38
63
|
const hdTheme = useTheme();
|
|
39
64
|
return (
|
|
40
65
|
<SafeAreaView style={{ marginHorizontal: hdTheme.space.large }}>
|
|
41
66
|
<FlatList
|
|
42
67
|
data={components}
|
|
43
|
-
renderItem={({ item }
|
|
68
|
+
renderItem={({ item }) => (
|
|
44
69
|
<ComponentItem
|
|
45
70
|
name={item.name}
|
|
46
71
|
onPress={() => navigation.navigate(item.name)}
|
|
@@ -60,6 +85,14 @@ const App = () => {
|
|
|
60
85
|
background: theme.colors.platformBackground,
|
|
61
86
|
},
|
|
62
87
|
};
|
|
88
|
+
|
|
89
|
+
const [fontsLoaded] = useFonts({
|
|
90
|
+
'hero-icons': heroIconFontPath,
|
|
91
|
+
});
|
|
92
|
+
if (!fontsLoaded) {
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
|
|
63
96
|
return (
|
|
64
97
|
<ThemeProvider theme={theme}>
|
|
65
98
|
<NavigationContainer theme={CustomNavigationTheme}>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Text, View } from 'react-native';
|
|
2
|
+
import styled, { css } from 'styled-components-native';
|
|
3
|
+
|
|
4
|
+
const BACKGROUND_INTENTS = {
|
|
5
|
+
success: 'successBackground',
|
|
6
|
+
warning: 'warningBackground',
|
|
7
|
+
danger: 'dangerBackground',
|
|
8
|
+
info: 'infoBackground',
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
type ThemeIntent = 'success' | 'warning' | 'danger' | 'info';
|
|
12
|
+
|
|
13
|
+
const StyledView = styled(View)<{ themeIntent: ThemeIntent }>`
|
|
14
|
+
border-width: ${({ theme }) => theme.__hd__.badge.borderWidths.default};
|
|
15
|
+
border-radius: ${({ theme }) => theme.__hd__.badge.radii.default};
|
|
16
|
+
padding: ${({ theme }) => theme.__hd__.badge.padding.default};
|
|
17
|
+
|
|
18
|
+
${({ themeIntent }) => css`
|
|
19
|
+
border-color: ${({ theme }) => theme.__hd__.badge.colors[themeIntent]};
|
|
20
|
+
background-color: ${({ theme }) =>
|
|
21
|
+
theme.__hd__.badge.colors[BACKGROUND_INTENTS[themeIntent]]};
|
|
22
|
+
`};
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const StyledText = styled(Text)<{ themeIntent: ThemeIntent }>`
|
|
26
|
+
font-weight: ${({ theme }) => theme.__hd__.badge.fontWeights.default};
|
|
27
|
+
font-size: ${({ theme }) => theme.__hd__.badge.fontSizes.default};
|
|
28
|
+
|
|
29
|
+
${({ themeIntent }) => css`
|
|
30
|
+
color: ${({ theme }) => theme.__hd__.badge.colors[themeIntent]};
|
|
31
|
+
`};
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
export { StyledView, StyledText };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render } from '@testing-library/react-native';
|
|
3
|
+
import { ThemeProvider, theme } from '../../../index';
|
|
4
|
+
import Badge from '..';
|
|
5
|
+
|
|
6
|
+
describe('Badge', () => {
|
|
7
|
+
it('has success style when intent is success', () => {
|
|
8
|
+
const { getByText, toJSON } = render(
|
|
9
|
+
<ThemeProvider theme={theme}>
|
|
10
|
+
<Badge content="APPROVED" intent="success" />
|
|
11
|
+
</ThemeProvider>
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
expect(toJSON()).toMatchSnapshot();
|
|
15
|
+
expect(getByText('APPROVED')).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('has warning style when intent is warning', () => {
|
|
19
|
+
const { getByText, toJSON } = render(
|
|
20
|
+
<ThemeProvider theme={theme}>
|
|
21
|
+
<Badge content="PENDING" intent="warning" />
|
|
22
|
+
</ThemeProvider>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
expect(toJSON()).toMatchSnapshot();
|
|
26
|
+
expect(getByText('PENDING')).toBeDefined();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('has danger style when intent is danger', () => {
|
|
30
|
+
const { getByText, toJSON } = render(
|
|
31
|
+
<ThemeProvider theme={theme}>
|
|
32
|
+
<Badge content="DECLINED" intent="danger" />
|
|
33
|
+
</ThemeProvider>
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expect(toJSON()).toMatchSnapshot();
|
|
37
|
+
expect(getByText('DECLINED')).toBeDefined();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('has info style when intent is info', () => {
|
|
41
|
+
const { getByText, toJSON } = render(
|
|
42
|
+
<ThemeProvider theme={theme}>
|
|
43
|
+
<Badge content="SUBMITTED" intent="info" />
|
|
44
|
+
</ThemeProvider>
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
expect(toJSON()).toMatchSnapshot();
|
|
48
|
+
expect(getByText('SUBMITTED')).toBeDefined();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Badge has danger style when intent is danger 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Object {
|
|
7
|
+
"backgroundColor": "#fcebe7",
|
|
8
|
+
"borderBottomColor": "#de350b",
|
|
9
|
+
"borderBottomLeftRadius": 4,
|
|
10
|
+
"borderBottomRightRadius": 4,
|
|
11
|
+
"borderBottomWidth": 1,
|
|
12
|
+
"borderLeftColor": "#de350b",
|
|
13
|
+
"borderLeftWidth": 1,
|
|
14
|
+
"borderRightColor": "#de350b",
|
|
15
|
+
"borderRightWidth": 1,
|
|
16
|
+
"borderTopColor": "#de350b",
|
|
17
|
+
"borderTopLeftRadius": 4,
|
|
18
|
+
"borderTopRightRadius": 4,
|
|
19
|
+
"borderTopWidth": 1,
|
|
20
|
+
"paddingBottom": 4,
|
|
21
|
+
"paddingLeft": 8,
|
|
22
|
+
"paddingRight": 8,
|
|
23
|
+
"paddingTop": 4,
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
themeIntent="danger"
|
|
27
|
+
>
|
|
28
|
+
<Text
|
|
29
|
+
style={
|
|
30
|
+
Object {
|
|
31
|
+
"color": "#de350b",
|
|
32
|
+
"fontSize": 12,
|
|
33
|
+
"fontWeight": "600",
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
themeIntent="danger"
|
|
37
|
+
>
|
|
38
|
+
DECLINED
|
|
39
|
+
</Text>
|
|
40
|
+
</View>
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
exports[`Badge has info style when intent is info 1`] = `
|
|
44
|
+
<View
|
|
45
|
+
style={
|
|
46
|
+
Object {
|
|
47
|
+
"backgroundColor": "#ecf0ff",
|
|
48
|
+
"borderBottomColor": "#4568fb",
|
|
49
|
+
"borderBottomLeftRadius": 4,
|
|
50
|
+
"borderBottomRightRadius": 4,
|
|
51
|
+
"borderBottomWidth": 1,
|
|
52
|
+
"borderLeftColor": "#4568fb",
|
|
53
|
+
"borderLeftWidth": 1,
|
|
54
|
+
"borderRightColor": "#4568fb",
|
|
55
|
+
"borderRightWidth": 1,
|
|
56
|
+
"borderTopColor": "#4568fb",
|
|
57
|
+
"borderTopLeftRadius": 4,
|
|
58
|
+
"borderTopRightRadius": 4,
|
|
59
|
+
"borderTopWidth": 1,
|
|
60
|
+
"paddingBottom": 4,
|
|
61
|
+
"paddingLeft": 8,
|
|
62
|
+
"paddingRight": 8,
|
|
63
|
+
"paddingTop": 4,
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
themeIntent="info"
|
|
67
|
+
>
|
|
68
|
+
<Text
|
|
69
|
+
style={
|
|
70
|
+
Object {
|
|
71
|
+
"color": "#4568fb",
|
|
72
|
+
"fontSize": 12,
|
|
73
|
+
"fontWeight": "600",
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
themeIntent="info"
|
|
77
|
+
>
|
|
78
|
+
SUBMITTED
|
|
79
|
+
</Text>
|
|
80
|
+
</View>
|
|
81
|
+
`;
|
|
82
|
+
|
|
83
|
+
exports[`Badge has success style when intent is success 1`] = `
|
|
84
|
+
<View
|
|
85
|
+
style={
|
|
86
|
+
Object {
|
|
87
|
+
"backgroundColor": "#f0fef4",
|
|
88
|
+
"borderBottomColor": "#017d6d",
|
|
89
|
+
"borderBottomLeftRadius": 4,
|
|
90
|
+
"borderBottomRightRadius": 4,
|
|
91
|
+
"borderBottomWidth": 1,
|
|
92
|
+
"borderLeftColor": "#017d6d",
|
|
93
|
+
"borderLeftWidth": 1,
|
|
94
|
+
"borderRightColor": "#017d6d",
|
|
95
|
+
"borderRightWidth": 1,
|
|
96
|
+
"borderTopColor": "#017d6d",
|
|
97
|
+
"borderTopLeftRadius": 4,
|
|
98
|
+
"borderTopRightRadius": 4,
|
|
99
|
+
"borderTopWidth": 1,
|
|
100
|
+
"paddingBottom": 4,
|
|
101
|
+
"paddingLeft": 8,
|
|
102
|
+
"paddingRight": 8,
|
|
103
|
+
"paddingTop": 4,
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
themeIntent="success"
|
|
107
|
+
>
|
|
108
|
+
<Text
|
|
109
|
+
style={
|
|
110
|
+
Object {
|
|
111
|
+
"color": "#017d6d",
|
|
112
|
+
"fontSize": 12,
|
|
113
|
+
"fontWeight": "600",
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
themeIntent="success"
|
|
117
|
+
>
|
|
118
|
+
APPROVED
|
|
119
|
+
</Text>
|
|
120
|
+
</View>
|
|
121
|
+
`;
|
|
122
|
+
|
|
123
|
+
exports[`Badge has warning style when intent is warning 1`] = `
|
|
124
|
+
<View
|
|
125
|
+
style={
|
|
126
|
+
Object {
|
|
127
|
+
"backgroundColor": "#fff6eb",
|
|
128
|
+
"borderBottomColor": "#d98a2c",
|
|
129
|
+
"borderBottomLeftRadius": 4,
|
|
130
|
+
"borderBottomRightRadius": 4,
|
|
131
|
+
"borderBottomWidth": 1,
|
|
132
|
+
"borderLeftColor": "#d98a2c",
|
|
133
|
+
"borderLeftWidth": 1,
|
|
134
|
+
"borderRightColor": "#d98a2c",
|
|
135
|
+
"borderRightWidth": 1,
|
|
136
|
+
"borderTopColor": "#d98a2c",
|
|
137
|
+
"borderTopLeftRadius": 4,
|
|
138
|
+
"borderTopRightRadius": 4,
|
|
139
|
+
"borderTopWidth": 1,
|
|
140
|
+
"paddingBottom": 4,
|
|
141
|
+
"paddingLeft": 8,
|
|
142
|
+
"paddingRight": 8,
|
|
143
|
+
"paddingTop": 4,
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
themeIntent="warning"
|
|
147
|
+
>
|
|
148
|
+
<Text
|
|
149
|
+
style={
|
|
150
|
+
Object {
|
|
151
|
+
"color": "#d98a2c",
|
|
152
|
+
"fontSize": 12,
|
|
153
|
+
"fontWeight": "600",
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
themeIntent="warning"
|
|
157
|
+
>
|
|
158
|
+
PENDING
|
|
159
|
+
</Text>
|
|
160
|
+
</View>
|
|
161
|
+
`;
|