@hero-design/rn 7.0.6 → 7.1.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.
Files changed (92) hide show
  1. package/.eslintrc.json +4 -3
  2. package/babel.config.js +1 -1
  3. package/es/index.js +411 -134
  4. package/lib/index.js +411 -131
  5. package/package.json +5 -4
  6. package/playground/components/BottomNavigation.tsx +69 -0
  7. package/playground/components/Card.tsx +174 -112
  8. package/playground/components/FAB.tsx +49 -0
  9. package/playground/index.tsx +6 -1
  10. package/rollup.config.js +1 -1
  11. package/src/components/BottomNavigation/StyledBottomNavigation.tsx +58 -0
  12. package/src/components/BottomNavigation/__tests__/BottomNavigation.spec.tsx +95 -0
  13. package/src/components/BottomNavigation/__tests__/__snapshots__/BottomNavigation.spec.tsx.snap +315 -0
  14. package/src/components/BottomNavigation/index.tsx +169 -0
  15. package/src/components/Card/StyledCard.tsx +1 -0
  16. package/src/components/Card/__tests__/__snapshots__/Card.spec.tsx.snap +5 -4
  17. package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +5 -4
  18. package/src/components/FAB/AnimatedFABIcon.tsx +47 -0
  19. package/src/components/FAB/StyledFABContainer.tsx +14 -0
  20. package/src/components/FAB/StyledFABIcon.tsx +9 -0
  21. package/src/components/FAB/__tests__/AnimatedFABIcon.spec.tsx +20 -0
  22. package/src/components/FAB/__tests__/StyledFABContainer.spec.tsx +18 -0
  23. package/src/components/FAB/__tests__/StyledFABIcon.spec.tsx +16 -0
  24. package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +71 -0
  25. package/src/components/FAB/__tests__/__snapshots__/StyledFABContainer.spec.tsx.snap +46 -0
  26. package/src/components/FAB/__tests__/__snapshots__/StyledFABIcon.spec.tsx.snap +21 -0
  27. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +120 -0
  28. package/src/components/FAB/__tests__/index.spec.tsx +58 -0
  29. package/src/components/FAB/index.tsx +56 -0
  30. package/src/components/Icon/index.tsx +1 -1
  31. package/src/components/Icon/utils.ts +6 -0
  32. package/src/components/Typography/Text/StyledText.tsx +5 -1
  33. package/src/components/Typography/Text/index.tsx +1 -1
  34. package/src/index.ts +6 -0
  35. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +30 -1
  36. package/src/theme/components/bottomNavigation.ts +23 -0
  37. package/src/theme/components/card.ts +1 -1
  38. package/src/theme/components/fab.ts +21 -0
  39. package/src/theme/components/typography.ts +1 -0
  40. package/src/theme/global/space.ts +11 -9
  41. package/src/theme/global/typography.ts +11 -9
  42. package/src/theme/index.ts +6 -0
  43. package/src/utils/__tests__/scale.spec.ts +26 -0
  44. package/src/utils/helpers.ts +4 -0
  45. package/src/utils/scale.ts +10 -0
  46. package/testUtils/setup.ts +4 -0
  47. package/types/playground/components/BottomNavigation.d.ts +2 -0
  48. package/types/playground/components/FAB.d.ts +2 -0
  49. package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +17 -0
  50. package/types/{components/Card/__tests__/Card.spec.d.ts → src/components/BottomNavigation/__tests__/BottomNavigation.spec.d.ts} +0 -0
  51. package/types/src/components/BottomNavigation/index.d.ts +40 -0
  52. package/types/src/components/FAB/AnimatedFABIcon.d.ts +6 -0
  53. package/types/src/components/FAB/StyledFABContainer.d.ts +3 -0
  54. package/types/src/components/FAB/StyledFABIcon.d.ts +3 -0
  55. package/types/{components/Card/__tests__/StyledCard.spec.d.ts → src/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts} +0 -0
  56. package/types/{components/Divider/__tests__/StyledDivider.spec.d.ts → src/components/FAB/__tests__/StyledFABContainer.spec.d.ts} +0 -0
  57. package/types/{components/ExampleComponent/__tests__/StyledView.spec.d.ts → src/components/FAB/__tests__/StyledFABIcon.spec.d.ts} +0 -0
  58. package/types/src/components/{Typography/Text/__test__ → FAB/__tests__}/index.spec.d.ts +0 -0
  59. package/types/src/components/FAB/index.d.ts +30 -0
  60. package/types/src/components/Icon/index.d.ts +1 -1
  61. package/types/src/components/Icon/utils.d.ts +2 -0
  62. package/types/src/components/Typography/Text/StyledText.d.ts +1 -1
  63. package/types/src/components/Typography/Text/index.d.ts +1 -1
  64. package/types/src/index.d.ts +4 -1
  65. package/types/src/theme/components/bottomNavigation.d.ts +17 -0
  66. package/types/src/theme/components/fab.d.ts +15 -0
  67. package/types/src/theme/components/typography.d.ts +1 -0
  68. package/types/src/theme/index.d.ts +4 -0
  69. package/types/src/{components/Typography/Text/__test__/StyledText.spec.d.ts → utils/__tests__/scale.spec.d.ts} +0 -0
  70. package/types/src/utils/helpers.d.ts +2 -0
  71. package/types/src/utils/scale.d.ts +2 -0
  72. package/.expo/README.md +0 -15
  73. package/.expo/packager-info.json +0 -10
  74. package/.expo/settings.json +0 -10
  75. package/types/components/Card/StyledCard.d.ts +0 -3
  76. package/types/components/Card/index.d.ts +0 -5
  77. package/types/components/Divider/StyledDivider.d.ts +0 -7
  78. package/types/components/Divider/index.d.ts +0 -12
  79. package/types/components/ExampleComponent/StyledView.d.ts +0 -7
  80. package/types/components/ExampleComponent/index.d.ts +0 -16
  81. package/types/index.d.ts +0 -5
  82. package/types/styled-components.d.ts +0 -6
  83. package/types/theme/__tests__/index.spec.d.ts +0 -1
  84. package/types/theme/components/card.d.ts +0 -10
  85. package/types/theme/components/divider.d.ts +0 -17
  86. package/types/theme/components/exampleComponent.d.ts +0 -14
  87. package/types/theme/global/borders.d.ts +0 -4
  88. package/types/theme/global/colors.d.ts +0 -26
  89. package/types/theme/global/index.d.ts +0 -63
  90. package/types/theme/global/space.d.ts +0 -12
  91. package/types/theme/global/typography.d.ts +0 -21
  92. package/types/theme/index.d.ts +0 -13
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@hero-design/rn",
3
- "version": "7.0.6",
3
+ "version": "7.1.2",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
7
- "types": "types/index.d.ts",
7
+ "types": "types/src/index.d.ts",
8
8
  "scripts": {
9
9
  "lint": "eslint src playground --ext .js,.jsx,.ts,.tsx --ignore-path ../../.gitignore",
10
10
  "type-check": "tsc --noEmit",
@@ -18,19 +18,20 @@
18
18
  "publish:npm": "yarn publish --access public"
19
19
  },
20
20
  "dependencies": {
21
- "@hero-design/colors": "7.0.6",
21
+ "@hero-design/colors": "7.1.2",
22
22
  "styled-components": "6.0.0-alpha.5"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "react": "17.0.2",
26
26
  "react-native": "0.65.1",
27
+ "react-native-safe-area-context": "^4.2.5",
27
28
  "react-native-vector-icons": "^9.1.0"
28
29
  },
29
30
  "devDependencies": {
30
31
  "@babel/core": "^7.17.5",
31
32
  "@babel/preset-env": "^7.16.11",
32
33
  "@babel/preset-react": "^7.16.7",
33
- "@babel/preset-typescript": "^7.16.7",
34
+ "@babel/preset-typescript": "^7.17.12",
34
35
  "@react-navigation/native": "^6.0.10",
35
36
  "@react-navigation/native-stack": "^6.6.2",
36
37
  "@rollup/plugin-babel": "^5.3.1",
@@ -0,0 +1,69 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { Tab } from '../../src/components/BottomNavigation';
4
+ import { BottomNavigation, Typography } from '../../src/index';
5
+
6
+ const HomeScreen = () => (
7
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
8
+ <Typography.Text>Home Screen</Typography.Text>
9
+ </View>
10
+ );
11
+
12
+ const FeedScreen = () => (
13
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
14
+ <Typography.Text>Feed Screen</Typography.Text>
15
+ </View>
16
+ );
17
+
18
+ const AlertsScreen = () => (
19
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
20
+ <Typography.Text>Alerts Screen</Typography.Text>
21
+ </View>
22
+ );
23
+
24
+ const ProfileScreen = () => (
25
+ <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
26
+ <Typography.Text>Profile Screen</Typography.Text>
27
+ </View>
28
+ );
29
+
30
+ const tabs: Tab<number>[] = [
31
+ {
32
+ key: 0,
33
+ title: 'Home',
34
+ icon: 'home',
35
+ component: <HomeScreen />,
36
+ },
37
+ {
38
+ key: 1,
39
+ title: 'Feed',
40
+ icon: 'speaker',
41
+ component: <FeedScreen />,
42
+ },
43
+ {
44
+ key: 2,
45
+ title: 'Alerts',
46
+ icon: 'bell',
47
+ component: <AlertsScreen />,
48
+ },
49
+ {
50
+ key: 3,
51
+ title: 'Profile',
52
+ icon: 'user',
53
+ component: <ProfileScreen />,
54
+ },
55
+ ];
56
+
57
+ const MyComponent = () => {
58
+ const [selectedTabKey, setSelectedTabKey] = React.useState(0);
59
+
60
+ return (
61
+ <BottomNavigation
62
+ onChange={newTabKey => setSelectedTabKey(newTabKey)}
63
+ selectedTabKey={selectedTabKey}
64
+ tabs={tabs}
65
+ />
66
+ );
67
+ };
68
+
69
+ export default MyComponent;
@@ -1,24 +1,108 @@
1
1
  import React, { ComponentProps } from 'react';
2
- import { View, ViewProps, StyleSheet } from 'react-native';
2
+ import {
3
+ View,
4
+ ViewProps,
5
+ StyleSheet,
6
+ TouchableOpacity,
7
+ ScrollView,
8
+ } from 'react-native';
3
9
  import { palette } from '@hero-design/colors';
4
- import { Card, useTheme, Typography, Icon, Divider } from '../../src/index';
10
+ import { scale, Card, Typography, Icon, Divider, theme } from '../../src/index';
5
11
 
6
- const TextBox = (props: ViewProps) => (
7
- <View
8
- style={{
9
- flex: 1,
10
- justifyContent: 'flex-end',
11
- }}
12
- {...props}
13
- />
14
- );
15
-
16
- const Screen = View;
17
12
  type DashboardCardProps = ViewProps & {
18
13
  icon: ComponentProps<typeof Icon>['icon'];
19
14
  title: string;
20
15
  subtitle: string;
21
16
  };
17
+ type PendingItemProps = {
18
+ count: number;
19
+ label: string;
20
+ onPress?: () => void;
21
+ wrapperTestID?: string;
22
+ countTestID?: string;
23
+ };
24
+
25
+ const PendingItem = ({
26
+ count,
27
+ label,
28
+ onPress,
29
+ wrapperTestID,
30
+ countTestID,
31
+ }: Omit<PendingItemProps, 'isLoading'>) => (
32
+ <TouchableOpacity
33
+ onPress={onPress}
34
+ style={{
35
+ paddingHorizontal: theme.space.small,
36
+ flex: 1,
37
+ }}
38
+ testID={wrapperTestID}
39
+ >
40
+ <Typography.Text
41
+ fontSize="xlarge"
42
+ fontWeight="semi-bold"
43
+ style={{
44
+ textAlign: 'center',
45
+ paddingBottom: theme.space.small,
46
+ color: palette.redLight30,
47
+ }}
48
+ testID={countTestID}
49
+ >
50
+ {count}
51
+ </Typography.Text>
52
+ <Typography.Text
53
+ style={{ textAlign: 'center', color: palette.greyDark75 }}
54
+ fontSize="large"
55
+ >
56
+ {label}
57
+ </Typography.Text>
58
+ </TouchableOpacity>
59
+ );
60
+
61
+ const ApprovalsCardLayout = ({ style }: ViewProps) => (
62
+ <Card
63
+ style={StyleSheet.flatten([
64
+ {
65
+ backgroundColor: palette.greyLight90,
66
+ marginBottom: theme.space.medium,
67
+ paddingTop: 0,
68
+ paddingRight: 0,
69
+ paddingBottom: 0,
70
+ paddingLeft: 0,
71
+ },
72
+ style,
73
+ ])}
74
+ >
75
+ <View
76
+ style={{
77
+ backgroundColor: palette.redLight60,
78
+ display: 'flex',
79
+ flexDirection: 'row',
80
+ padding: theme.space.medium,
81
+ marginBottom: theme.space.medium,
82
+ }}
83
+ >
84
+ <Icon
85
+ icon="multiple-users"
86
+ style={{
87
+ marginRight: theme.space.small,
88
+ }}
89
+ />
90
+ <Typography.Text fontWeight="semi-bold" fontSize="xlarge">
91
+ Approval card
92
+ </Typography.Text>
93
+ </View>
94
+ <View
95
+ style={{
96
+ flex: 1,
97
+ flexDirection: 'row',
98
+ }}
99
+ >
100
+ <PendingItem count={1} label="Timesheets" />
101
+ <PendingItem count={2} label="Leave Requests" />
102
+ <PendingItem count={7} label="Expense Claims" />
103
+ </View>
104
+ </Card>
105
+ );
22
106
 
23
107
  const DashboardCard = ({
24
108
  style,
@@ -26,16 +110,22 @@ const DashboardCard = ({
26
110
  title,
27
111
  subtitle,
28
112
  }: DashboardCardProps) => (
29
- <Card testID="inductionContent" style={style}>
113
+ <Card style={style}>
30
114
  <View style={{ flex: 1, alignItems: 'flex-end' }}>
31
115
  <Icon icon={icon} />
32
116
  </View>
33
- <TextBox>
117
+ <View
118
+ style={{
119
+ flex: 1,
120
+ justifyContent: 'flex-end',
121
+ margin: theme.space.small,
122
+ }}
123
+ >
34
124
  <Typography.Text fontSize="xlarge" fontWeight="semi-bold">
35
125
  {title}
36
126
  </Typography.Text>
37
127
  <Typography.Text fontSize="medium">{subtitle}</Typography.Text>
38
- </TextBox>
128
+ </View>
39
129
  </Card>
40
130
  );
41
131
 
@@ -59,14 +149,13 @@ const PoliciesCard = (props: ViewProps) => (
59
149
  const CertificationsCard = (props: ViewProps) => (
60
150
  <DashboardCard
61
151
  icon="file-certified"
62
- title="Certification"
152
+ title="Certifications"
63
153
  subtitle="1 to update"
64
154
  {...props}
65
155
  />
66
156
  );
67
157
 
68
- const Payslip = (props: ViewProps) => {
69
- const theme = useTheme();
158
+ const RostersCard = (props: ViewProps) => {
70
159
  const { style, ...otherProps } = props;
71
160
  return (
72
161
  <Card
@@ -74,45 +163,35 @@ const Payslip = (props: ViewProps) => {
74
163
  style={StyleSheet.flatten([
75
164
  {
76
165
  flexDirection: 'row',
77
- alignItems: 'stretch',
78
- backgroundColor: palette.greyLight75,
166
+ alignItems: 'center',
167
+ backgroundColor: palette.greyLight90,
79
168
  },
80
169
  style,
81
170
  ])}
82
171
  >
83
- <View>
172
+ <View style={{ padding: theme.space.small }}>
84
173
  <View
85
174
  style={{
86
175
  padding: theme.space.small,
87
- backgroundColor: '#C0ECE6',
176
+ backgroundColor: theme.colors.infoLight,
88
177
  borderRadius: 999,
89
- alignContent: 'stretch',
90
178
  }}
91
179
  >
92
- <Icon icon="coin" />
180
+ <Icon icon="calendar-clock" />
93
181
  </View>
94
182
  </View>
95
183
  <View style={{ flex: 1, marginLeft: theme.space.small }}>
96
- <Typography.Text fontSize="large" fontWeight="semi-bold">
184
+ <Typography.Text fontSize="xlarge" fontWeight="semi-bold">
97
185
  Rosters
98
186
  </Typography.Text>
99
- <Typography.Text fontSize="medium">3 shifts this week</Typography.Text>
100
- </View>
101
- <View
102
- style={{
103
- alignItems: 'center',
104
- alignContent: 'center',
105
- justifyContent: 'center',
106
- }}
107
- >
108
- <Icon icon="arrow-right" />
187
+ <Typography.Text fontSize="large">3 shifts this week</Typography.Text>
109
188
  </View>
189
+ <Icon icon="arrow-right" />
110
190
  </Card>
111
191
  );
112
192
  };
113
193
 
114
194
  const MyLeaveCard = (props: ViewProps) => {
115
- const theme = useTheme();
116
195
  const { style, ...otherProps } = props;
117
196
  return (
118
197
  <Card
@@ -129,58 +208,53 @@ const MyLeaveCard = (props: ViewProps) => {
129
208
  ])}
130
209
  >
131
210
  <View
132
- testID="header"
133
211
  style={{
134
- marginHorizontal: theme.space.small,
135
- marginTop: theme.space.small,
212
+ padding: theme.space.medium,
136
213
  justifyContent: 'space-between',
137
214
  flexDirection: 'row',
138
215
  }}
139
216
  >
140
- <Typography.Text fontSize="large" fontWeight="semi-bold">
217
+ <Typography.Text fontSize="xlarge" fontWeight="semi-bold">
141
218
  My Leave
142
219
  </Typography.Text>
143
-
144
220
  <View style={{ flexDirection: 'row', alignItems: 'center' }}>
145
- <Typography.Text fontWeight="semi-bold">Add / view</Typography.Text>
221
+ <Typography.Text fontSize="large" fontWeight="semi-bold">
222
+ Add / view
223
+ </Typography.Text>
146
224
  <Icon
147
225
  icon="circle-add-outlined"
148
226
  size="xsmall"
149
- style={{ margin: theme.space.xxsmall }}
227
+ style={{ marginLeft: theme.space.small }}
150
228
  />
151
229
  </View>
152
230
  </View>
153
- <Divider marginVertical="small" />
154
- <View testID="content" style={{ margin: theme.space.small }}>
155
- <Typography.Text fontSize="medium" fontWeight="semi-bold">
231
+ <Divider />
232
+ <View style={{ padding: theme.space.medium }}>
233
+ <Typography.Text
234
+ fontSize="large"
235
+ fontWeight="semi-bold"
236
+ style={{ marginBottom: theme.space.small }}
237
+ >
156
238
  Leave Balances
157
239
  </Typography.Text>
158
- <View
159
- testID="listItem1"
160
- style={{ flexDirection: 'row', justifyContent: 'space-between' }}
161
- >
162
- <Typography.Text>Jury Duty</Typography.Text>
240
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
241
+ <Typography.Text fontSize="large">Jury Duty</Typography.Text>
163
242
  <Typography.Text fontWeight="semi-bold">12.06 hrs</Typography.Text>
164
243
  </View>
165
- <View
166
- testID="listItem1"
167
- style={{ flexDirection: 'row', justifyContent: 'space-between' }}
168
- >
169
- <Typography.Text>Annual Leave</Typography.Text>
244
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
245
+ <Typography.Text fontSize="large">Annual Leave</Typography.Text>
170
246
  <Typography.Text fontWeight="semi-bold">12.06 hrs</Typography.Text>
171
247
  </View>
172
- <View
173
- testID="listItem1"
174
- style={{ flexDirection: 'row', justifyContent: 'space-between' }}
175
- >
176
- <Typography.Text>Values Champion Award</Typography.Text>
248
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
249
+ <Typography.Text fontSize="large">
250
+ Values Champion Award
251
+ </Typography.Text>
177
252
  <Typography.Text fontWeight="semi-bold">12.06 hrs</Typography.Text>
178
253
  </View>
179
- <View
180
- testID="listItem1"
181
- style={{ flexDirection: 'row', justifyContent: 'space-between' }}
182
- >
183
- <Typography.Text>Family and Domestic</Typography.Text>
254
+ <View style={{ flexDirection: 'row', justifyContent: 'space-between' }}>
255
+ <Typography.Text fontSize="large">
256
+ Family and Domestic
257
+ </Typography.Text>
184
258
  <Typography.Text fontWeight="semi-bold">12.06 hrs</Typography.Text>
185
259
  </View>
186
260
  </View>
@@ -188,51 +262,39 @@ const MyLeaveCard = (props: ViewProps) => {
188
262
  );
189
263
  };
190
264
 
191
- const CardPlayground = () => {
192
- const theme = useTheme();
193
- return (
194
- <Screen>
195
- <View style={{ flexDirection: 'row', height: 250 }}>
196
- <View style={{ flex: 1 }}>
197
- <InductionCard
198
- style={{
199
- flex: 1,
200
- margin: theme.space.small,
201
- backgroundColor: theme.colors.primaryLight,
202
- }}
203
- />
204
- </View>
205
- <View style={{ flex: 1 }}>
206
- <PoliciesCard
207
- style={{
208
- flex: 1,
209
- backgroundColor: palette.dodgerBlueLight75,
210
- margin: theme.space.small,
211
- }}
212
- testID="policies"
213
- />
214
- <CertificationsCard
215
- style={{
216
- flex: 1,
217
- margin: theme.space.small,
218
- backgroundColor: palette.dodgerBlueLight75,
219
- }}
220
- testID="certifications"
221
- />
222
- </View>
265
+ const CardPlayground = () => (
266
+ <ScrollView style={{ padding: theme.space.medium }}>
267
+ <View style={{ flexDirection: 'row', height: scale(216) }}>
268
+ <View style={{ flex: 1, marginRight: theme.space.medium }}>
269
+ <InductionCard
270
+ style={{
271
+ flex: 1,
272
+ backgroundColor: theme.colors.primaryLight,
273
+ }}
274
+ />
223
275
  </View>
224
- <Payslip
225
- style={{
226
- margin: theme.space.small,
227
- }}
228
- />
229
- <MyLeaveCard
230
- style={{
231
- margin: theme.space.small,
232
- }}
233
- />
234
- </Screen>
235
- );
236
- };
276
+ <View style={{ flex: 1 }}>
277
+ <PoliciesCard
278
+ style={{
279
+ flex: 1,
280
+ backgroundColor: theme.colors.infoLight,
281
+ marginBottom: theme.space.medium,
282
+ }}
283
+ testID="policies"
284
+ />
285
+ <CertificationsCard
286
+ style={{
287
+ flex: 1,
288
+ backgroundColor: theme.colors.infoLight,
289
+ }}
290
+ testID="certifications"
291
+ />
292
+ </View>
293
+ </View>
294
+ <RostersCard style={{ marginTop: theme.space.medium }} />
295
+ <MyLeaveCard style={{ marginTop: theme.space.medium }} />
296
+ <ApprovalsCardLayout style={{ marginTop: theme.space.medium }} />
297
+ </ScrollView>
298
+ );
237
299
 
238
300
  export default CardPlayground;
@@ -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;
@@ -6,24 +6,27 @@ 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';
12
+ import BottomNavigation from './components/BottomNavigation';
13
13
  import CardPlayground from './components/Card';
14
14
  import DividerPlayground from './components/Divider';
15
15
  import IconPlayground from './components/Icon';
16
16
  import TypographyPlayground from './components/Typography';
17
+ import FABPlayground from './components/FAB';
17
18
 
18
19
  const heroIconFontPath = require('../assets/fonts/hero-icons.ttf');
19
20
 
20
21
  type RootStackParamList = {
21
22
  Home: undefined;
22
23
  Badge: undefined;
24
+ BottomNavigation: undefined;
23
25
  Card: undefined;
24
26
  Divider: undefined;
25
27
  Icon: undefined;
26
28
  Typography: undefined;
29
+ FAB: undefined;
27
30
  };
28
31
 
29
32
  type Navigation = NativeStackScreenProps<RootStackParamList>;
@@ -32,10 +35,12 @@ const Stack = createNativeStackNavigator<RootStackParamList>();
32
35
 
33
36
  const components = [
34
37
  { name: 'Badge', component: BadgePlayground },
38
+ { name: 'BottomNavigation', component: BottomNavigation },
35
39
  { name: 'Card', component: CardPlayground },
36
40
  { name: 'Divider', component: DividerPlayground },
37
41
  { name: 'Icon', component: IconPlayground },
38
42
  { name: 'Typography', component: TypographyPlayground },
43
+ { name: 'FAB', component: FABPlayground },
39
44
  ] as const;
40
45
 
41
46
  const ComponentItem = ({
package/rollup.config.js CHANGED
@@ -22,7 +22,7 @@ export default {
22
22
  format: 'esm',
23
23
  },
24
24
  ],
25
- external: ['react', 'react-native'],
25
+ external: ['react', 'react-native', 'react-native-safe-area-context'],
26
26
  plugins: [
27
27
  replace({
28
28
  'process.env.NODE_ENV': JSON.stringify('production'),
@@ -0,0 +1,58 @@
1
+ import { View } from 'react-native';
2
+ import styled from 'styled-components-native';
3
+
4
+ const BottomNavigationTab = styled(View)<{ themeVisibility?: boolean }>`
5
+ flex: 1;
6
+ display: ${({ themeVisibility }) =>
7
+ themeVisibility === false ? 'none' : 'flex'};
8
+ `;
9
+
10
+ const BottomNavigationContainer = styled(View)`
11
+ flex: 1;
12
+ overflow: hidden;
13
+ `;
14
+
15
+ const ContentWrapper = styled(View)`
16
+ flex: 1;
17
+ `;
18
+
19
+ const BottomBarWrapper = styled(View)<{
20
+ themeInsets: { top: number; right: number; bottom: number; left: number };
21
+ }>`
22
+ height: ${({ theme, themeInsets }) =>
23
+ theme.__hd__.bottomNavigation.sizes.height + themeInsets.bottom}px;
24
+ padding-bottom: ${({ themeInsets }) => themeInsets.bottom}px;
25
+ padding-left: ${({ themeInsets }) =>
26
+ Math.max(themeInsets.left, themeInsets.right)}px;
27
+ padding-right: ${({ themeInsets }) =>
28
+ Math.max(themeInsets.left, themeInsets.right)}px;
29
+ background-color: ${({ theme }) =>
30
+ theme.__hd__.bottomNavigation.colors.background};
31
+ shadow-color: ${({ theme }) => theme.__hd__.bottomNavigation.colors.shadow};
32
+ shadow-offset: ${({ theme }) => theme.__hd__.bottomNavigation.shadows.offset};
33
+ shadow-opacity: ${({ theme }) =>
34
+ theme.__hd__.bottomNavigation.shadows.opacity};
35
+ shadow-radius: ${({ theme }) => theme.__hd__.bottomNavigation.shadows.radius};
36
+ elevation: ${({ theme }) => theme.__hd__.bottomNavigation.shadows.elevation};
37
+ `;
38
+
39
+ const BottomBar = styled(View)`
40
+ flex: 1;
41
+ flex-direction: row;
42
+ overflow: hidden;
43
+ align-items: center;
44
+ `;
45
+
46
+ const BottomBarItem = styled(View)`
47
+ flex: 1;
48
+ align-items: center;
49
+ `;
50
+
51
+ export {
52
+ BottomBar,
53
+ BottomBarItem,
54
+ BottomNavigationTab,
55
+ BottomNavigationContainer,
56
+ BottomBarWrapper,
57
+ ContentWrapper,
58
+ };