@hero-design/rn 7.2.0 → 7.3.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.
Files changed (244) hide show
  1. package/.expo/README.md +15 -0
  2. package/.expo/packager-info.json +10 -0
  3. package/.expo/prebuild/cached-packages.json +4 -0
  4. package/.expo/settings.json +10 -0
  5. package/.expo/xcodebuild-error.log +2 -0
  6. package/.expo/xcodebuild.log +11199 -0
  7. package/.turbo/turbo-build.log +8 -0
  8. package/.turbo/turbo-build:types.log +2 -0
  9. package/.turbo/turbo-publish:npm.log +0 -0
  10. package/.turbo/turbo-test.log +131 -0
  11. package/.turbo/turbo-type-check.log +7 -0
  12. package/es/index.js +2406 -469
  13. package/jest.config.js +1 -1
  14. package/lib/index.js +2423 -481
  15. package/package.json +4 -38
  16. package/playground/components/Avatar.tsx +102 -0
  17. package/playground/components/Badge.tsx +146 -9
  18. package/playground/components/Button.tsx +138 -35
  19. package/playground/components/Card.tsx +40 -14
  20. package/playground/components/Collapse.tsx +99 -0
  21. package/playground/components/Drawer.tsx +32 -0
  22. package/playground/components/FAB.tsx +15 -0
  23. package/playground/components/IconButton.tsx +67 -0
  24. package/playground/components/Progress.tsx +95 -0
  25. package/playground/components/Tabs.tsx +106 -14
  26. package/playground/components/Tag.tsx +45 -0
  27. package/playground/index.tsx +18 -0
  28. package/src/components/Avatar/StyledAvatar.tsx +61 -0
  29. package/src/components/Avatar/__tests__/StyledAvatar.spec.tsx +48 -0
  30. package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +87 -0
  31. package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +88 -0
  32. package/src/components/Avatar/__tests__/index.spec.tsx +26 -0
  33. package/src/components/Avatar/index.tsx +71 -0
  34. package/src/components/Badge/Status.tsx +77 -0
  35. package/src/components/Badge/StyledBadge.tsx +38 -26
  36. package/src/components/Badge/__tests__/Badge.spec.tsx +16 -0
  37. package/src/components/Badge/__tests__/Status.spec.tsx +27 -0
  38. package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +133 -52
  39. package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +89 -0
  40. package/src/components/Badge/index.tsx +77 -19
  41. package/src/components/Button/Button.tsx +163 -0
  42. package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +58 -0
  43. package/src/components/Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.tsx +20 -0
  44. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +101 -0
  45. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +606 -0
  46. package/src/components/Button/LoadingIndicator/__tests__/index.spec.tsx +24 -0
  47. package/src/components/Button/LoadingIndicator/index.tsx +140 -0
  48. package/src/components/Button/StyledButton.tsx +254 -0
  49. package/src/components/Button/__tests__/Button.spec.tsx +86 -0
  50. package/src/components/Button/__tests__/{index.spec.tsx → IconButton.spec.tsx} +0 -0
  51. package/src/components/Button/__tests__/StyledButton.spec.tsx +154 -0
  52. package/src/components/Button/__tests__/__snapshots__/{index.spec.tsx.snap → IconButton.spec.tsx.snap} +0 -0
  53. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +895 -0
  54. package/src/components/Button/index.tsx +10 -2
  55. package/src/components/Card/StyledCard.tsx +27 -5
  56. package/src/components/Card/__tests__/StyledCard.spec.tsx +15 -3
  57. package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +34 -2
  58. package/src/components/Card/__tests__/index.spec.tsx +16 -21
  59. package/src/components/Card/index.tsx +15 -2
  60. package/src/components/Collapse/StyledCollapse.tsx +15 -0
  61. package/src/components/Collapse/__tests__/StyledCollapse.spec.tsx +26 -0
  62. package/src/components/Collapse/__tests__/__snapshots__/StyledCollapse.spec.tsx.snap +37 -0
  63. package/src/components/Collapse/__tests__/__snapshots__/index.spec.tsx.snap +84 -0
  64. package/src/components/Collapse/__tests__/index.spec.tsx +42 -0
  65. package/src/components/Collapse/index.tsx +109 -0
  66. package/src/components/Divider/index.tsx +1 -1
  67. package/src/components/Drawer/StyledDrawer.tsx +39 -0
  68. package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +244 -0
  69. package/src/components/Drawer/__tests__/index.spec.tsx +37 -0
  70. package/src/components/Drawer/index.tsx +93 -0
  71. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +78 -62
  72. package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +2 -0
  73. package/src/components/FAB/ActionGroup/index.tsx +13 -1
  74. package/src/components/FAB/FAB.tsx +63 -13
  75. package/src/components/FAB/StyledFAB.tsx +25 -6
  76. package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +6 -2
  77. package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +7 -3
  78. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +88 -6
  79. package/src/components/FAB/__tests__/index.spec.tsx +16 -0
  80. package/src/components/Progress/ProgressBar.tsx +73 -0
  81. package/src/components/Progress/ProgressCircle.tsx +165 -0
  82. package/src/components/Progress/StyledProgressBar.tsx +21 -0
  83. package/src/components/Progress/StyledProgressCircle.tsx +66 -0
  84. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +641 -0
  85. package/src/components/Progress/__tests__/index.spec.js +46 -0
  86. package/src/components/Progress/index.tsx +6 -0
  87. package/src/components/Progress/types.ts +1 -0
  88. package/src/components/Tabs/ActiveTabIndicator.tsx +37 -0
  89. package/src/components/Tabs/ScrollableTabs.tsx +216 -0
  90. package/src/components/Tabs/StyledScrollableTabs.tsx +60 -0
  91. package/src/components/Tabs/StyledTabs.tsx +30 -44
  92. package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +84 -0
  93. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +591 -0
  94. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +317 -224
  95. package/src/components/Tabs/__tests__/index.spec.tsx +22 -21
  96. package/src/components/Tabs/index.tsx +155 -114
  97. package/src/components/Tabs/utils.ts +13 -0
  98. package/src/components/Tag/StyledTag.tsx +35 -0
  99. package/src/components/Tag/__tests__/Tag.spec.tsx +41 -0
  100. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +153 -0
  101. package/src/components/Tag/index.tsx +41 -0
  102. package/src/components/Typography/Text/index.tsx +1 -1
  103. package/src/index.ts +10 -0
  104. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +181 -22
  105. package/src/theme/components/avatar.ts +40 -0
  106. package/src/theme/components/badge.ts +14 -16
  107. package/src/theme/components/button.ts +57 -0
  108. package/src/theme/components/card.ts +5 -5
  109. package/src/theme/components/drawer.ts +24 -0
  110. package/src/theme/components/fab.ts +9 -2
  111. package/src/theme/components/progress.ts +27 -0
  112. package/src/theme/components/tabs.ts +22 -7
  113. package/src/theme/components/tag.ts +39 -0
  114. package/src/theme/global/borders.ts +13 -1
  115. package/src/theme/global/colors.ts +7 -2
  116. package/src/theme/global/index.ts +3 -1
  117. package/src/theme/global/scale.ts +3 -0
  118. package/src/theme/index.ts +15 -0
  119. package/src/utils/hooks.ts +10 -0
  120. package/testUtils/setup.tsx +43 -0
  121. package/types/playground/components/Avatar.d.ts +2 -0
  122. package/types/playground/components/Badge.d.ts +0 -0
  123. package/types/playground/components/BottomNavigation.d.ts +0 -0
  124. package/types/playground/components/Button.d.ts +0 -0
  125. package/types/playground/components/Card.d.ts +0 -0
  126. package/types/playground/components/Collapse.d.ts +2 -0
  127. package/types/playground/components/Divider.d.ts +0 -0
  128. package/types/playground/components/Drawer.d.ts +2 -0
  129. package/types/playground/components/FAB.d.ts +0 -0
  130. package/types/playground/components/Icon.d.ts +0 -0
  131. package/types/playground/components/IconButton.d.ts +2 -0
  132. package/types/playground/components/Progress.d.ts +2 -0
  133. package/types/playground/components/Tabs.d.ts +0 -0
  134. package/types/playground/components/Tag.d.ts +2 -0
  135. package/types/playground/components/Typography.d.ts +0 -0
  136. package/types/playground/index.d.ts +0 -0
  137. package/types/src/components/Avatar/StyledAvatar.d.ts +46 -0
  138. package/types/src/components/Avatar/__tests__/StyledAvatar.spec.d.ts +1 -0
  139. package/types/src/components/Avatar/__tests__/index.spec.d.ts +1 -0
  140. package/types/src/components/Avatar/index.d.ts +25 -0
  141. package/types/src/components/Badge/Status.d.ts +24 -0
  142. package/types/src/components/Badge/StyledBadge.d.ts +17 -9
  143. package/types/src/components/Badge/__tests__/Badge.spec.d.ts +0 -0
  144. package/types/src/components/Badge/__tests__/Status.spec.d.ts +1 -0
  145. package/types/src/components/Badge/index.d.ts +17 -7
  146. package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +0 -0
  147. package/types/src/components/BottomNavigation/__tests__/index.spec.d.ts +0 -0
  148. package/types/src/components/BottomNavigation/index.d.ts +0 -0
  149. package/types/src/components/Button/Button.d.ts +57 -0
  150. package/types/src/components/Button/IconButton.d.ts +0 -0
  151. package/types/src/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +20 -0
  152. package/types/src/components/Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.d.ts +1 -0
  153. package/types/src/components/Button/LoadingIndicator/__tests__/index.spec.d.ts +1 -0
  154. package/types/src/components/Button/LoadingIndicator/index.d.ts +26 -0
  155. package/types/src/components/Button/StyledButton.d.ts +40 -0
  156. package/types/src/components/Button/__tests__/Button.spec.d.ts +1 -0
  157. package/types/src/components/Button/__tests__/IconButton.spec.d.ts +1 -0
  158. package/types/src/components/Button/__tests__/StyledButton.spec.d.ts +1 -0
  159. package/types/src/components/Button/__tests__/index.spec.d.ts +0 -0
  160. package/types/src/components/Button/index.d.ts +8 -4
  161. package/types/src/components/Card/StyledCard.d.ts +9 -1
  162. package/types/src/components/Card/__tests__/StyledCard.spec.d.ts +0 -0
  163. package/types/src/components/Card/__tests__/index.spec.d.ts +0 -0
  164. package/types/src/components/Card/index.d.ts +5 -1
  165. package/types/src/components/Collapse/StyledCollapse.d.ts +15 -0
  166. package/types/src/components/Collapse/__tests__/StyledCollapse.spec.d.ts +1 -0
  167. package/types/src/components/Collapse/__tests__/index.spec.d.ts +1 -0
  168. package/types/src/components/Collapse/index.d.ts +23 -0
  169. package/types/src/components/Divider/StyledDivider.d.ts +0 -0
  170. package/types/src/components/Divider/__tests__/StyledDivider.spec.d.ts +0 -0
  171. package/types/src/components/Divider/index.d.ts +0 -0
  172. package/types/src/components/Drawer/StyledDrawer.d.ts +25 -0
  173. package/types/src/components/Drawer/__tests__/index.spec.d.ts +1 -0
  174. package/types/src/components/Drawer/index.d.ts +25 -0
  175. package/types/src/components/FAB/ActionGroup/ActionItem.d.ts +0 -0
  176. package/types/src/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -0
  177. package/types/src/components/FAB/ActionGroup/StyledActionItem.d.ts +0 -0
  178. package/types/src/components/FAB/ActionGroup/__tests__/index.spec.d.ts +0 -0
  179. package/types/src/components/FAB/ActionGroup/index.d.ts +8 -1
  180. package/types/src/components/FAB/AnimatedFABIcon.d.ts +0 -0
  181. package/types/src/components/FAB/FAB.d.ts +5 -1
  182. package/types/src/components/FAB/StyledFAB.d.ts +8 -2
  183. package/types/src/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts +0 -0
  184. package/types/src/components/FAB/__tests__/StyledFAB.spec.d.ts +0 -0
  185. package/types/src/components/FAB/__tests__/index.spec.d.ts +0 -0
  186. package/types/src/components/FAB/index.d.ts +2 -2
  187. package/types/src/components/Icon/HeroIcon/index.d.ts +0 -0
  188. package/types/src/components/Icon/IconList.d.ts +0 -0
  189. package/types/src/components/Icon/__tests__/index.spec.d.ts +0 -0
  190. package/types/src/components/Icon/index.d.ts +0 -0
  191. package/types/src/components/Icon/utils.d.ts +1 -1
  192. package/types/src/components/Progress/ProgressBar.d.ts +18 -0
  193. package/types/src/components/Progress/ProgressCircle.d.ts +18 -0
  194. package/types/src/components/Progress/StyledProgressBar.d.ts +18 -0
  195. package/types/src/components/Progress/StyledProgressCircle.d.ts +38 -0
  196. package/types/src/components/Progress/__tests__/index.spec.d.ts +1 -0
  197. package/types/src/components/Progress/index.d.ts +5 -0
  198. package/types/src/components/Progress/types.d.ts +1 -0
  199. package/types/src/components/Tabs/ActiveTabIndicator.d.ts +8 -0
  200. package/types/src/components/Tabs/ScrollableTabs.d.ts +3 -0
  201. package/types/src/components/Tabs/StyledScrollableTabs.d.ts +61 -0
  202. package/types/src/components/Tabs/StyledTabs.d.ts +22 -22
  203. package/types/src/components/Tabs/__tests__/ScrollableTabs.spec.d.ts +1 -0
  204. package/types/src/components/Tabs/__tests__/index.spec.d.ts +0 -0
  205. package/types/src/components/Tabs/index.d.ts +28 -19
  206. package/types/src/components/Tabs/utils.d.ts +2 -0
  207. package/types/src/components/Tag/StyledTag.d.ts +20 -0
  208. package/types/src/components/Tag/__tests__/Tag.spec.d.ts +1 -0
  209. package/types/src/components/Tag/index.d.ts +21 -0
  210. package/types/src/components/Typography/Text/StyledText.d.ts +0 -0
  211. package/types/src/components/Typography/Text/__tests__/StyledText.spec.d.ts +0 -0
  212. package/types/src/components/Typography/Text/__tests__/index.spec.d.ts +0 -0
  213. package/types/src/components/Typography/Text/index.d.ts +0 -0
  214. package/types/src/components/Typography/index.d.ts +0 -0
  215. package/types/src/index.d.ts +6 -1
  216. package/types/src/testHelpers/renderWithTheme.d.ts +0 -0
  217. package/types/src/theme/__tests__/index.spec.d.ts +0 -0
  218. package/types/src/theme/components/avatar.d.ts +32 -0
  219. package/types/src/theme/components/badge.d.ts +12 -13
  220. package/types/src/theme/components/bottomNavigation.d.ts +0 -0
  221. package/types/src/theme/components/button.d.ts +37 -0
  222. package/types/src/theme/components/card.d.ts +3 -3
  223. package/types/src/theme/components/divider.d.ts +0 -0
  224. package/types/src/theme/components/drawer.d.ts +21 -0
  225. package/types/src/theme/components/fab.d.ts +8 -1
  226. package/types/src/theme/components/icon.d.ts +0 -0
  227. package/types/src/theme/components/progress.d.ts +21 -0
  228. package/types/src/theme/components/tabs.d.ts +14 -2
  229. package/types/src/theme/components/tag.d.ts +30 -0
  230. package/types/src/theme/components/typography.d.ts +0 -0
  231. package/types/src/theme/global/borders.d.ts +7 -1
  232. package/types/src/theme/global/colors.d.ts +6 -1
  233. package/types/src/theme/global/index.d.ts +7 -1
  234. package/types/src/theme/global/scale.d.ts +1 -0
  235. package/types/src/theme/global/space.d.ts +0 -0
  236. package/types/src/theme/global/typography.d.ts +0 -0
  237. package/types/src/theme/index.d.ts +10 -0
  238. package/types/src/types.d.ts +0 -0
  239. package/types/src/utils/__tests__/scale.spec.d.ts +0 -0
  240. package/types/src/utils/helpers.d.ts +0 -0
  241. package/types/src/utils/hooks.d.ts +1 -0
  242. package/types/src/utils/scale.d.ts +0 -0
  243. package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +0 -34
  244. package/testUtils/setup.ts +0 -18
@@ -0,0 +1,99 @@
1
+ import React, { useCallback } from 'react';
2
+ import { Text, View } from 'react-native';
3
+ import palette from '@hero-design/colors';
4
+ import {
5
+ Avatar,
6
+ Typography,
7
+ useTheme,
8
+ Button,
9
+ Card,
10
+ Collapse,
11
+ } from '../../src/index';
12
+
13
+ const CollapsePlayground = () => {
14
+ const theme = useTheme();
15
+ const source = { uri: 'https://i.pravatar.cc/300' };
16
+ const [isCollapsed, setIsCollapsed] = React.useState<boolean>(true);
17
+
18
+ const toggleContent = useCallback(() => {
19
+ setIsCollapsed(!isCollapsed);
20
+ }, [isCollapsed]);
21
+
22
+ return (
23
+ <View
24
+ style={{
25
+ marginVertical: theme.space.medium,
26
+ marginHorizontal: theme.space.medium,
27
+ }}
28
+ >
29
+ <Typography.Text style={{ marginBottom: theme.space.small }}>
30
+ Integrate as Accordion example
31
+ </Typography.Text>
32
+ <View>
33
+ <Card
34
+ style={{
35
+ display: 'flex',
36
+ flexDirection: 'row',
37
+ alignItems: 'center',
38
+ justifyContent: 'space-between',
39
+ backgroundColor: palette.greyLight90,
40
+ padding: theme.space.medium,
41
+ ...(isCollapsed
42
+ ? {}
43
+ : {
44
+ borderBottomEndRadius: 0,
45
+ borderBottomStartRadius: 0,
46
+ }),
47
+ }}
48
+ >
49
+ <View
50
+ style={{
51
+ display: 'flex',
52
+ flexDirection: 'row',
53
+ alignItems: 'center',
54
+ }}
55
+ >
56
+ <Avatar source={source} />
57
+ <View
58
+ style={{
59
+ display: 'flex',
60
+ flexDirection: 'column',
61
+ marginLeft: theme.space.medium,
62
+ }}
63
+ >
64
+ <Typography.Text fontSize="large">Rob Dunn</Typography.Text>
65
+ <Typography.Text fontSize="small" intent="subdued">
66
+ 3 OKRS
67
+ </Typography.Text>
68
+ </View>
69
+ </View>
70
+ <Button.Icon
71
+ icon={`carat-${isCollapsed ? 'left' : 'down'}`}
72
+ intent="text"
73
+ size="xsmall"
74
+ onPress={toggleContent}
75
+ style={{ padding: theme.space.small }}
76
+ />
77
+ </Card>
78
+ <Collapse
79
+ open={!isCollapsed}
80
+ style={{
81
+ backgroundColor: palette.greyLight90,
82
+ }}
83
+ >
84
+ <View
85
+ style={{
86
+ padding: theme.space.large,
87
+ borderTopWidth: theme.space.xxsmall,
88
+ borderTopColor: palette.greyLight85,
89
+ }}
90
+ >
91
+ <Text>Hidden Content</Text>
92
+ </View>
93
+ </Collapse>
94
+ </View>
95
+ </View>
96
+ );
97
+ };
98
+
99
+ export default CollapsePlayground;
@@ -0,0 +1,32 @@
1
+ import { Button, SafeAreaView, Text, View } from 'react-native';
2
+ import React, { useState } from 'react';
3
+
4
+ import { Drawer } from '../../src/index';
5
+
6
+ const DrawerContent = () => (
7
+ <View style={{ padding: 30 }}>
8
+ <Text>Drawer Content</Text>
9
+ <Text>Drawer Content</Text>
10
+ <Text>Drawer Content</Text>
11
+ <Text>Drawer Content</Text>
12
+ <Text>Drawer Content</Text>
13
+ <Text>Drawer Content</Text>
14
+ </View>
15
+ );
16
+
17
+ const DrawerPlayground = () => {
18
+ const [visible, setVisibility] = useState(false);
19
+
20
+ return (
21
+ <SafeAreaView
22
+ style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}
23
+ >
24
+ <Drawer visible={visible} onDismiss={() => setVisibility(false)}>
25
+ <DrawerContent />
26
+ </Drawer>
27
+ <Button title="Toggle Drawer" onPress={() => setVisibility(!visible)} />
28
+ </SafeAreaView>
29
+ );
30
+ };
31
+
32
+ export default DrawerPlayground;
@@ -43,6 +43,21 @@ const FABPlayground = (): JSX.Element => {
43
43
  }}
44
44
  active={active}
45
45
  />
46
+
47
+ <FAB
48
+ style={{
49
+ position: 'absolute',
50
+ bottom: 0,
51
+ marginLeft: theme.space.large,
52
+ marginBottom: theme.space.large,
53
+ }}
54
+ onPress={() => {
55
+ alert('pressed shout out');
56
+ }}
57
+ title="Shout out"
58
+ icon="pencil"
59
+ animated
60
+ />
46
61
  </SafeAreaView>
47
62
  </SafeAreaProvider>
48
63
  );
@@ -0,0 +1,67 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+
4
+ import { Button, Typography, useTheme } from '../../src/index';
5
+
6
+ const IconButtonPlayground = (): JSX.Element => {
7
+ const theme = useTheme();
8
+ return (
9
+ <View style={{ padding: theme.space.small }}>
10
+ <Typography.Text style={{ marginBottom: theme.space.xsmall }}>
11
+ Different Intents and Sizes from Icon
12
+ </Typography.Text>
13
+ <View
14
+ style={{
15
+ flexDirection: 'row',
16
+ alignItems: 'center',
17
+ marginBottom: theme.space.large,
18
+ }}
19
+ >
20
+ <Button.Icon
21
+ icon="circle-add-outlined"
22
+ intent="text"
23
+ size="xsmall"
24
+ onPress={() => {}}
25
+ style={{ marginEnd: theme.space.medium }}
26
+ />
27
+ <Button.Icon
28
+ icon="circle-add-outlined"
29
+ intent="primary"
30
+ size="xsmall"
31
+ onPress={() => {}}
32
+ style={{ marginEnd: theme.space.medium }}
33
+ />
34
+ <Button.Icon
35
+ icon="circle-add-outlined"
36
+ intent="success"
37
+ size="small"
38
+ onPress={() => {}}
39
+ style={{ marginEnd: theme.space.medium }}
40
+ />
41
+ <Button.Icon
42
+ icon="circle-add-outlined"
43
+ intent="info"
44
+ size="medium"
45
+ onPress={() => {}}
46
+ style={{ marginEnd: theme.space.medium }}
47
+ />
48
+ <Button.Icon
49
+ icon="circle-add-outlined"
50
+ intent="warning"
51
+ size="large"
52
+ onPress={() => {}}
53
+ style={{ marginEnd: theme.space.medium }}
54
+ />
55
+ <Button.Icon
56
+ icon="circle-add-outlined"
57
+ intent="danger"
58
+ size="xlarge"
59
+ onPress={() => {}}
60
+ style={{ marginEnd: theme.space.medium }}
61
+ />
62
+ </View>
63
+ </View>
64
+ );
65
+ };
66
+
67
+ export default IconButtonPlayground;
@@ -0,0 +1,95 @@
1
+ import React, { useState } from 'react';
2
+ import { View, Button } from 'react-native';
3
+ import { Progress, Typography, useTheme } from '../../src/index';
4
+
5
+ const ProgressPlayground = () => {
6
+ const [progress, setProgress] = useState(0);
7
+ const theme = useTheme();
8
+
9
+ return (
10
+ <View style={{ flex: 1 }}>
11
+ <View
12
+ style={{ alignItems: 'center', paddingVertical: theme.space.xlarge }}
13
+ >
14
+ <Typography.Text
15
+ fontSize="large"
16
+ style={{ marginBottom: theme.space.small }}
17
+ >
18
+ Progress Circle
19
+ </Typography.Text>
20
+ <View
21
+ style={{
22
+ flexDirection: 'row',
23
+ alignItems: 'center',
24
+ }}
25
+ >
26
+ <Progress.Circle value={progress} />
27
+ <Progress.Circle value={progress} intent="success" />
28
+ <Progress.Circle value={progress} intent="warning" />
29
+ </View>
30
+
31
+ <View
32
+ style={{
33
+ flexDirection: 'row',
34
+ alignItems: 'center',
35
+ }}
36
+ >
37
+ <Progress.Circle value={progress} intent="danger" />
38
+ <Progress.Circle value={progress} intent="info" />
39
+ </View>
40
+ </View>
41
+ <View
42
+ style={{ alignItems: 'center', paddingVertical: theme.space.small }}
43
+ >
44
+ <Typography.Text
45
+ fontSize="large"
46
+ style={{ marginBottom: theme.space.small }}
47
+ >
48
+ Progress Bar
49
+ </Typography.Text>
50
+ <Progress.Bar
51
+ value={progress}
52
+ style={{ marginBottom: theme.space.small }}
53
+ />
54
+ <Progress.Bar
55
+ value={progress}
56
+ intent="success"
57
+ style={{ marginBottom: theme.space.small }}
58
+ />
59
+ <Progress.Bar
60
+ value={progress}
61
+ intent="warning"
62
+ style={{ marginBottom: theme.space.small }}
63
+ />
64
+ <Progress.Bar
65
+ value={progress}
66
+ intent="danger"
67
+ style={{ marginBottom: theme.space.small }}
68
+ />
69
+ <Progress.Bar
70
+ value={progress}
71
+ intent="info"
72
+ style={{ marginBottom: theme.space.small }}
73
+ />
74
+ </View>
75
+ <View style={{ alignItems: 'center', padding: theme.space.xlarge }}>
76
+ <View
77
+ style={{
78
+ flexDirection: 'row',
79
+ width: '80%',
80
+ justifyContent: 'space-around',
81
+ }}
82
+ >
83
+ <Button
84
+ title="Random Value"
85
+ onPress={() => setProgress(Math.floor(Math.random() * 100))}
86
+ />
87
+ <Button title="Min" onPress={() => setProgress(0)} />
88
+ <Button title="Max" onPress={() => setProgress(100)} />
89
+ </View>
90
+ </View>
91
+ </View>
92
+ );
93
+ };
94
+
95
+ export default ProgressPlayground;
@@ -1,31 +1,121 @@
1
1
  import React from 'react';
2
2
  import { View } from 'react-native';
3
- import { Tabs, Typography, TabType } from '../../src/index';
3
+ import {
4
+ Tabs,
5
+ Typography,
6
+ TabType,
7
+ Icon,
8
+ useTheme,
9
+ IconName,
10
+ } from '../../src/index';
4
11
 
5
- const WorkScreen = () => (
12
+ const CustomScreen = ({ title }: { title: string }) => (
6
13
  <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
7
- <Typography.Text>Work Screen</Typography.Text>
14
+ <Typography.Text>{title}</Typography.Text>
8
15
  </View>
9
16
  );
10
17
 
11
- const PersonalScreen = () => (
12
- <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
13
- <Typography.Text>Personal Screen</Typography.Text>
14
- </View>
15
- );
18
+ const CustomItem = ({
19
+ color,
20
+ icon,
21
+ title,
22
+ }: {
23
+ color: string;
24
+ icon: IconName;
25
+ title: string;
26
+ }) => {
27
+ const theme = useTheme();
28
+
29
+ return (
30
+ <View style={{ display: 'flex', flexDirection: 'row' }}>
31
+ <Icon
32
+ icon={icon}
33
+ size="small"
34
+ style={{ color, marginEnd: theme.space.small }}
35
+ />
36
+ <Typography.Text
37
+ fontWeight="semi-bold"
38
+ numberOfLines={1}
39
+ style={{ color }}
40
+ >
41
+ {title}
42
+ </Typography.Text>
43
+ </View>
44
+ );
45
+ };
46
+
47
+ const workTabs: TabType[] = [
48
+ {
49
+ key: 'activity',
50
+ activeItem: 'Activity',
51
+ component: <CustomScreen title="Activity" />,
52
+ showBadge: true,
53
+ },
54
+ {
55
+ key: 'news',
56
+ activeItem: `What's new`,
57
+ component: <CustomScreen title="News" />,
58
+ },
59
+ ];
60
+
61
+ const WorkScreen = () => {
62
+ const [selectedTabKey, setSelectedTabKey] = React.useState('activity');
63
+
64
+ return (
65
+ <Tabs
66
+ onTabPress={newTabKey => setSelectedTabKey(newTabKey)}
67
+ selectedTabKey={selectedTabKey}
68
+ tabs={workTabs}
69
+ />
70
+ );
71
+ };
16
72
 
17
73
  const tabs: TabType[] = [
18
74
  {
19
75
  key: 'work',
20
- title: 'Work',
21
- icon: 'suitcase',
76
+ activeItem: ({ color }) => (
77
+ <CustomItem color={color} icon="home-outlined" title="Home" />
78
+ ),
79
+ inactiveItem: 'home-outlined',
22
80
  component: <WorkScreen />,
23
81
  },
24
82
  {
25
83
  key: 'personal',
26
- title: 'Personal',
27
- icon: 'face-smiley',
28
- component: <PersonalScreen />,
84
+ activeItem: ({ color }) => (
85
+ <CustomItem color={color} icon="bell-outlined" title="Notifications" />
86
+ ),
87
+ inactiveItem: 'bell-outlined',
88
+ component: <CustomScreen title="Notifications Screen" />,
89
+ showBadge: true,
90
+ },
91
+ {
92
+ key: 'speaker',
93
+ activeItem: ({ color }) => (
94
+ <CustomItem color={color} icon="speaker-outlined" title="Shoutouts" />
95
+ ),
96
+ inactiveItem: 'speaker-outlined',
97
+ component: <CustomScreen title="Shoutouts Screen" />,
98
+ },
99
+ {
100
+ key: 'payslips',
101
+ activeItem: 'Payslips',
102
+ component: <CustomScreen title="Payslips Screen" />,
103
+ },
104
+ {
105
+ key: 'leave',
106
+ activeItem: 'Leave',
107
+ component: <CustomScreen title="Leave Screen" />,
108
+ showBadge: true,
109
+ },
110
+ {
111
+ key: 'rosters',
112
+ activeItem: 'Rosters',
113
+ component: <CustomScreen title="Rosters Screen" />,
114
+ },
115
+ {
116
+ key: 'timesheets',
117
+ activeItem: 'Timesheets',
118
+ component: <CustomScreen title="Timesheets Screen" />,
29
119
  },
30
120
  ];
31
121
 
@@ -33,10 +123,12 @@ const TabsPlayground = () => {
33
123
  const [selectedTabKey, setSelectedTabKey] = React.useState('work');
34
124
 
35
125
  return (
36
- <Tabs
126
+ <Tabs.Scroll
37
127
  onTabPress={newTabKey => setSelectedTabKey(newTabKey)}
38
128
  selectedTabKey={selectedTabKey}
39
129
  tabs={tabs}
130
+ lazy
131
+ lazyPreloadDistance={3}
40
132
  />
41
133
  );
42
134
  };
@@ -0,0 +1,45 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { Tag, useTheme } from '../../src/index';
4
+
5
+ const TagPlayground = () => {
6
+ const theme = useTheme();
7
+
8
+ return (
9
+ <View style={{ margin: theme.space.medium }}>
10
+ <View
11
+ style={{
12
+ display: 'flex',
13
+ flexDirection: 'row',
14
+ marginBottom: theme.space.small,
15
+ }}
16
+ >
17
+ <Tag
18
+ content="APPROVED"
19
+ intent="success"
20
+ style={{ marginEnd: theme.space.small }}
21
+ />
22
+ <Tag
23
+ content="PENDING"
24
+ intent="warning"
25
+ style={{ marginEnd: theme.space.small }}
26
+ />
27
+ </View>
28
+ <View
29
+ style={{
30
+ display: 'flex',
31
+ flexDirection: 'row',
32
+ }}
33
+ >
34
+ <Tag
35
+ content="DECLINED"
36
+ intent="danger"
37
+ style={{ marginEnd: theme.space.small }}
38
+ />
39
+ <Tag content="SUBMITTED" style={{ marginEnd: theme.space.small }} />
40
+ </View>
41
+ </View>
42
+ );
43
+ };
44
+
45
+ export default TagPlayground;
@@ -15,14 +15,20 @@ import {
15
15
  Icon,
16
16
  Divider,
17
17
  } from '../src/index';
18
+ import AvatarPlayground from './components/Avatar';
18
19
  import BadgePlayground from './components/Badge';
19
20
  import BottomNavigation from './components/BottomNavigation';
20
21
  import Button from './components/Button';
21
22
  import CardPlayground from './components/Card';
23
+ import CollapsePlayground from './components/Collapse';
22
24
  import DividerPlayground from './components/Divider';
25
+ import DrawerPlayground from './components/Drawer';
23
26
  import FABPlayground from './components/FAB';
24
27
  import IconPlayground from './components/Icon';
28
+ import IconButtonPlayground from './components/IconButton';
29
+ import ProgressPlayground from './components/Progress';
25
30
  import TabsPlayground from './components/Tabs';
31
+ import TagPlayground from './components/Tag';
26
32
  import TypographyPlayground from './components/Typography';
27
33
 
28
34
  const heroIconFontPath = require('../assets/fonts/hero-icons.ttf');
@@ -31,15 +37,21 @@ const beVietnamProRegularFont = require('../assets/fonts/be-vietnam-pro-regular.
31
37
  const beVietnamProSemiBoldFont = require('../assets/fonts/be-vietnam-pro-semibold.ttf');
32
38
 
33
39
  type RootStackParamList = {
40
+ Avatar: undefined;
34
41
  Badge: undefined;
35
42
  BottomNavigation: undefined;
36
43
  Button: undefined;
37
44
  Card: undefined;
45
+ Collapse: undefined;
38
46
  Divider: undefined;
47
+ Drawer: undefined;
39
48
  FAB: undefined;
40
49
  Home: undefined;
41
50
  Icon: undefined;
51
+ IconButton: undefined;
52
+ Progress: undefined;
42
53
  Tabs: undefined;
54
+ Tag: undefined;
43
55
  Typography: undefined;
44
56
  };
45
57
 
@@ -48,14 +60,20 @@ type Navigation = NativeStackScreenProps<RootStackParamList>;
48
60
  const Stack = createNativeStackNavigator<RootStackParamList>();
49
61
 
50
62
  const components = [
63
+ { name: 'Avatar', component: AvatarPlayground },
51
64
  { name: 'Badge', component: BadgePlayground },
52
65
  { name: 'BottomNavigation', component: BottomNavigation },
53
66
  { name: 'Button', component: Button },
54
67
  { name: 'Card', component: CardPlayground },
68
+ { name: 'Collapse', component: CollapsePlayground },
55
69
  { name: 'Divider', component: DividerPlayground },
70
+ { name: 'Drawer', component: DrawerPlayground },
56
71
  { name: 'FAB', component: FABPlayground },
57
72
  { name: 'Icon', component: IconPlayground },
73
+ { name: 'IconButton', component: IconButtonPlayground },
74
+ { name: 'Progress', component: ProgressPlayground },
58
75
  { name: 'Tabs', component: TabsPlayground },
76
+ { name: 'Tag', component: TagPlayground },
59
77
  { name: 'Typography', component: TypographyPlayground },
60
78
  ] as const;
61
79
 
@@ -0,0 +1,61 @@
1
+ import { View, Image, TouchableOpacity, Text } from 'react-native';
2
+ import styled from '@emotion/native';
3
+
4
+ type ThemeSize = 'small' | 'medium' | 'large' | 'xlarge';
5
+ type ThemeIntent = 'primary' | 'info' | 'danger' | 'success' | 'warning';
6
+
7
+ const StyledPressable = styled(TouchableOpacity)<{
8
+ themeSize: ThemeSize;
9
+ themeIntent: ThemeIntent;
10
+ }>(({ themeSize, themeIntent, theme }) => ({
11
+ borderWidth: theme.__hd__.avatar.borderWidths.default,
12
+ borderRadius: theme.__hd__.avatar.radii[themeSize],
13
+ borderColor: theme.__hd__.avatar.colors[themeIntent],
14
+ width: theme.__hd__.avatar.sizes[themeSize],
15
+ height: theme.__hd__.avatar.sizes[themeSize],
16
+ overflow: 'hidden',
17
+ }));
18
+
19
+ const StyledView = styled(View)<{
20
+ themeSize: ThemeSize;
21
+ themeIntent: ThemeIntent;
22
+ }>(({ themeSize, themeIntent, theme }) => ({
23
+ borderWidth: theme.__hd__.avatar.borderWidths.default,
24
+ borderRadius: theme.__hd__.avatar.radii[themeSize],
25
+ borderColor: theme.__hd__.avatar.colors[themeIntent],
26
+ width: theme.__hd__.avatar.sizes[themeSize],
27
+ height: theme.__hd__.avatar.sizes[themeSize],
28
+ overflow: 'hidden',
29
+ }));
30
+
31
+ const StyledTextWrapper = styled(View)(() => ({
32
+ alignItems: 'center',
33
+ justifyContent: 'center',
34
+ display: 'flex',
35
+ width: '100%',
36
+ height: '100%',
37
+ }));
38
+
39
+ const StyledText = styled(Text)<{
40
+ themeSize: ThemeSize;
41
+ themeIntent: ThemeIntent;
42
+ }>(({ themeSize, themeIntent, theme }) => ({
43
+ fontSize: theme.__hd__.avatar.fontSizes[themeSize],
44
+ color: theme.__hd__.avatar.colors[themeIntent],
45
+ overflow: 'hidden',
46
+ }));
47
+
48
+ const StyledImage = styled(Image)<{
49
+ themeSize: ThemeSize;
50
+ }>(({ themeSize, theme }) => ({
51
+ width: theme.__hd__.avatar.sizes[themeSize],
52
+ height: theme.__hd__.avatar.sizes[themeSize],
53
+ }));
54
+
55
+ export {
56
+ StyledPressable,
57
+ StyledView,
58
+ StyledImage,
59
+ StyledTextWrapper,
60
+ StyledText,
61
+ };
@@ -0,0 +1,48 @@
1
+ import React from 'react';
2
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
3
+ import {
4
+ StyledView,
5
+ StyledPressable,
6
+ StyledImage,
7
+ StyledText,
8
+ } from '../StyledAvatar';
9
+
10
+ describe('StyledPressable', () => {
11
+ it('renders correct style', () => {
12
+ const { toJSON } = renderWithTheme(
13
+ <StyledPressable themeIntent="primary" themeSize="small" />
14
+ );
15
+ expect(toJSON()).toMatchSnapshot();
16
+ });
17
+ });
18
+
19
+ describe('StyledView', () => {
20
+ it('renders correct style', () => {
21
+ const { toJSON } = renderWithTheme(
22
+ <StyledView themeIntent="primary" themeSize="small" />
23
+ );
24
+ expect(toJSON()).toMatchSnapshot();
25
+ });
26
+ });
27
+
28
+ describe('StyledText', () => {
29
+ it('renders correct style', () => {
30
+ const text = 'MD';
31
+ const { toJSON } = renderWithTheme(
32
+ <StyledText themeSize="small" themeIntent="primary">
33
+ {text}
34
+ </StyledText>
35
+ );
36
+ expect(toJSON()).toMatchSnapshot();
37
+ });
38
+ });
39
+
40
+ describe('StyledImage', () => {
41
+ it('renders correct style', () => {
42
+ const source = 'https://i.pravatar.cc/300';
43
+ const { toJSON } = renderWithTheme(
44
+ <StyledImage themeSize="small" source={{ uri: source }} />
45
+ );
46
+ expect(toJSON()).toMatchSnapshot();
47
+ });
48
+ });