@hero-design/rn 7.2.2 → 7.3.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 (243) hide show
  1. package/.turbo/turbo-build.log +2 -2
  2. package/es/index.js +2389 -449
  3. package/jest.config.js +1 -1
  4. package/lib/index.js +2410 -465
  5. package/package.json +4 -2
  6. package/playground/components/Avatar.tsx +102 -0
  7. package/playground/components/Badge.tsx +146 -9
  8. package/playground/components/Button.tsx +138 -35
  9. package/playground/components/Card.tsx +36 -1
  10. package/playground/components/Collapse.tsx +99 -0
  11. package/playground/components/Drawer.tsx +32 -0
  12. package/playground/components/FAB.tsx +15 -0
  13. package/playground/components/IconButton.tsx +67 -0
  14. package/playground/components/Progress.tsx +95 -0
  15. package/playground/components/Tabs.tsx +106 -14
  16. package/playground/components/Tag.tsx +45 -0
  17. package/playground/index.tsx +18 -0
  18. package/src/components/Avatar/StyledAvatar.tsx +61 -0
  19. package/src/components/Avatar/__tests__/StyledAvatar.spec.tsx +48 -0
  20. package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +87 -0
  21. package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +88 -0
  22. package/src/components/Avatar/__tests__/index.spec.tsx +26 -0
  23. package/src/components/Avatar/index.tsx +71 -0
  24. package/src/components/Badge/Status.tsx +77 -0
  25. package/src/components/Badge/StyledBadge.tsx +38 -26
  26. package/src/components/Badge/__tests__/Badge.spec.tsx +16 -0
  27. package/src/components/Badge/__tests__/Status.spec.tsx +27 -0
  28. package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +133 -52
  29. package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +89 -0
  30. package/src/components/Badge/index.tsx +77 -19
  31. package/src/components/Button/Button.tsx +163 -0
  32. package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +58 -0
  33. package/src/components/Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.tsx +20 -0
  34. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +101 -0
  35. package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +606 -0
  36. package/src/components/Button/LoadingIndicator/__tests__/index.spec.tsx +24 -0
  37. package/src/components/Button/LoadingIndicator/index.tsx +140 -0
  38. package/src/components/Button/StyledButton.tsx +254 -0
  39. package/src/components/Button/__tests__/Button.spec.tsx +86 -0
  40. package/src/components/Button/__tests__/{index.spec.tsx → IconButton.spec.tsx} +0 -0
  41. package/src/components/Button/__tests__/StyledButton.spec.tsx +154 -0
  42. package/src/components/Button/__tests__/__snapshots__/{index.spec.tsx.snap → IconButton.spec.tsx.snap} +0 -0
  43. package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +895 -0
  44. package/src/components/Button/index.tsx +10 -2
  45. package/src/components/Card/StyledCard.tsx +27 -4
  46. package/src/components/Card/__tests__/StyledCard.spec.tsx +15 -3
  47. package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +34 -1
  48. package/src/components/Card/__tests__/index.spec.tsx +16 -21
  49. package/src/components/Card/index.tsx +15 -2
  50. package/src/components/Collapse/StyledCollapse.tsx +15 -0
  51. package/src/components/Collapse/__tests__/StyledCollapse.spec.tsx +26 -0
  52. package/src/components/Collapse/__tests__/__snapshots__/StyledCollapse.spec.tsx.snap +37 -0
  53. package/src/components/Collapse/__tests__/__snapshots__/index.spec.tsx.snap +84 -0
  54. package/src/components/Collapse/__tests__/index.spec.tsx +42 -0
  55. package/src/components/Collapse/index.tsx +109 -0
  56. package/src/components/Divider/index.tsx +1 -1
  57. package/src/components/Drawer/StyledDrawer.tsx +39 -0
  58. package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +244 -0
  59. package/src/components/Drawer/__tests__/index.spec.tsx +37 -0
  60. package/src/components/Drawer/index.tsx +93 -0
  61. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +78 -62
  62. package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +2 -0
  63. package/src/components/FAB/ActionGroup/index.tsx +13 -0
  64. package/src/components/FAB/FAB.tsx +63 -13
  65. package/src/components/FAB/StyledFAB.tsx +25 -6
  66. package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +6 -2
  67. package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +7 -3
  68. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +88 -6
  69. package/src/components/FAB/__tests__/index.spec.tsx +16 -0
  70. package/src/components/Progress/ProgressBar.tsx +73 -0
  71. package/src/components/Progress/ProgressCircle.tsx +165 -0
  72. package/src/components/Progress/StyledProgressBar.tsx +21 -0
  73. package/src/components/Progress/StyledProgressCircle.tsx +66 -0
  74. package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +641 -0
  75. package/src/components/Progress/__tests__/index.spec.js +46 -0
  76. package/src/components/Progress/index.tsx +6 -0
  77. package/src/components/Progress/types.ts +1 -0
  78. package/src/components/Tabs/ActiveTabIndicator.tsx +37 -0
  79. package/src/components/Tabs/ScrollableTabs.tsx +216 -0
  80. package/src/components/Tabs/StyledScrollableTabs.tsx +60 -0
  81. package/src/components/Tabs/StyledTabs.tsx +30 -44
  82. package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +84 -0
  83. package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +591 -0
  84. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +317 -224
  85. package/src/components/Tabs/__tests__/index.spec.tsx +22 -21
  86. package/src/components/Tabs/index.tsx +155 -114
  87. package/src/components/Tabs/utils.ts +13 -0
  88. package/src/components/Tag/StyledTag.tsx +35 -0
  89. package/src/components/Tag/__tests__/Tag.spec.tsx +41 -0
  90. package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +153 -0
  91. package/src/components/Tag/index.tsx +41 -0
  92. package/src/components/Typography/Text/index.tsx +1 -1
  93. package/src/index.ts +10 -0
  94. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +182 -20
  95. package/src/theme/components/avatar.ts +40 -0
  96. package/src/theme/components/badge.ts +14 -16
  97. package/src/theme/components/button.ts +57 -0
  98. package/src/theme/components/card.ts +8 -2
  99. package/src/theme/components/drawer.ts +24 -0
  100. package/src/theme/components/fab.ts +9 -2
  101. package/src/theme/components/progress.ts +27 -0
  102. package/src/theme/components/tabs.ts +22 -7
  103. package/src/theme/components/tag.ts +39 -0
  104. package/src/theme/global/borders.ts +13 -1
  105. package/src/theme/global/colors.ts +6 -1
  106. package/src/theme/global/index.ts +3 -1
  107. package/src/theme/global/scale.ts +3 -0
  108. package/src/theme/index.ts +16 -1
  109. package/src/utils/hooks.ts +10 -0
  110. package/testUtils/setup.tsx +43 -0
  111. package/types/playground/components/Avatar.d.ts +2 -0
  112. package/types/playground/components/Badge.d.ts +0 -0
  113. package/types/playground/components/BottomNavigation.d.ts +0 -0
  114. package/types/playground/components/Button.d.ts +0 -0
  115. package/types/playground/components/Card.d.ts +0 -0
  116. package/types/playground/components/Collapse.d.ts +2 -0
  117. package/types/playground/components/Divider.d.ts +0 -0
  118. package/types/playground/components/Drawer.d.ts +2 -0
  119. package/types/playground/components/FAB.d.ts +0 -0
  120. package/types/playground/components/Icon.d.ts +0 -0
  121. package/types/playground/components/IconButton.d.ts +2 -0
  122. package/types/playground/components/Progress.d.ts +2 -0
  123. package/types/playground/components/Tabs.d.ts +0 -0
  124. package/types/playground/components/Tag.d.ts +2 -0
  125. package/types/playground/components/Typography.d.ts +0 -0
  126. package/types/playground/index.d.ts +0 -0
  127. package/types/src/components/Avatar/StyledAvatar.d.ts +46 -0
  128. package/types/src/components/{BottomNavigation/__tests__/BottomNavigation.spec.d.ts → Avatar/__tests__/StyledAvatar.spec.d.ts} +0 -0
  129. package/types/src/components/{Card/__tests__/Card.spec.d.ts → Avatar/__tests__/index.spec.d.ts} +0 -0
  130. package/types/src/components/Avatar/index.d.ts +25 -0
  131. package/types/src/components/Badge/Status.d.ts +24 -0
  132. package/types/src/components/Badge/StyledBadge.d.ts +17 -9
  133. package/types/src/components/Badge/__tests__/Badge.spec.d.ts +0 -0
  134. package/types/src/components/{FAB/__tests__/StyledFABContainer.spec.d.ts → Badge/__tests__/Status.spec.d.ts} +0 -0
  135. package/types/src/components/Badge/index.d.ts +17 -7
  136. package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +0 -0
  137. package/types/src/components/BottomNavigation/__tests__/index.spec.d.ts +0 -0
  138. package/types/src/components/BottomNavigation/index.d.ts +0 -0
  139. package/types/src/components/Button/Button.d.ts +57 -0
  140. package/types/src/components/Button/IconButton.d.ts +0 -0
  141. package/types/src/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +20 -0
  142. package/types/src/components/{FAB/__tests__/StyledFABIcon.spec.d.ts → Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.d.ts} +0 -0
  143. package/types/src/components/{Icon/__tests__/Icon.spec.d.ts → Button/LoadingIndicator/__tests__/index.spec.d.ts} +0 -0
  144. package/types/src/components/Button/LoadingIndicator/index.d.ts +26 -0
  145. package/types/src/components/Button/StyledButton.d.ts +40 -0
  146. package/types/src/components/{Tabs/__tests__/Tabs.spec.d.ts → Button/__tests__/Button.spec.d.ts} +0 -0
  147. package/types/src/components/Button/__tests__/IconButton.spec.d.ts +1 -0
  148. package/types/src/components/Button/__tests__/StyledButton.spec.d.ts +1 -0
  149. package/types/src/components/Button/__tests__/index.spec.d.ts +0 -0
  150. package/types/src/components/Button/index.d.ts +8 -4
  151. package/types/src/components/Card/StyledCard.d.ts +9 -1
  152. package/types/src/components/Card/__tests__/StyledCard.spec.d.ts +0 -0
  153. package/types/src/components/Card/__tests__/index.spec.d.ts +0 -0
  154. package/types/src/components/Card/index.d.ts +5 -1
  155. package/types/src/components/Collapse/StyledCollapse.d.ts +15 -0
  156. package/types/src/components/Collapse/__tests__/StyledCollapse.spec.d.ts +1 -0
  157. package/types/src/components/Collapse/__tests__/index.spec.d.ts +1 -0
  158. package/types/src/components/Collapse/index.d.ts +23 -0
  159. package/types/src/components/Divider/StyledDivider.d.ts +0 -0
  160. package/types/src/components/Divider/__tests__/StyledDivider.spec.d.ts +0 -0
  161. package/types/src/components/Divider/index.d.ts +0 -0
  162. package/types/src/components/Drawer/StyledDrawer.d.ts +25 -0
  163. package/types/src/components/Drawer/__tests__/index.spec.d.ts +1 -0
  164. package/types/src/components/Drawer/index.d.ts +25 -0
  165. package/types/src/components/FAB/ActionGroup/ActionItem.d.ts +0 -0
  166. package/types/src/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -0
  167. package/types/src/components/FAB/ActionGroup/StyledActionItem.d.ts +0 -0
  168. package/types/src/components/FAB/ActionGroup/__tests__/index.spec.d.ts +0 -0
  169. package/types/src/components/FAB/ActionGroup/index.d.ts +5 -1
  170. package/types/src/components/FAB/AnimatedFABIcon.d.ts +0 -0
  171. package/types/src/components/FAB/FAB.d.ts +5 -1
  172. package/types/src/components/FAB/StyledFAB.d.ts +8 -2
  173. package/types/src/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts +0 -0
  174. package/types/src/components/FAB/__tests__/StyledFAB.spec.d.ts +0 -0
  175. package/types/src/components/FAB/__tests__/index.spec.d.ts +0 -0
  176. package/types/src/components/FAB/index.d.ts +2 -2
  177. package/types/src/components/Icon/HeroIcon/index.d.ts +0 -0
  178. package/types/src/components/Icon/IconList.d.ts +0 -0
  179. package/types/src/components/Icon/__tests__/index.spec.d.ts +0 -0
  180. package/types/src/components/Icon/index.d.ts +0 -0
  181. package/types/src/components/Icon/utils.d.ts +1 -1
  182. package/types/src/components/Progress/ProgressBar.d.ts +18 -0
  183. package/types/src/components/Progress/ProgressCircle.d.ts +18 -0
  184. package/types/src/components/Progress/StyledProgressBar.d.ts +18 -0
  185. package/types/src/components/Progress/StyledProgressCircle.d.ts +38 -0
  186. package/types/src/components/Progress/__tests__/index.spec.d.ts +1 -0
  187. package/types/src/components/Progress/index.d.ts +5 -0
  188. package/types/src/components/Progress/types.d.ts +1 -0
  189. package/types/src/components/Tabs/ActiveTabIndicator.d.ts +8 -0
  190. package/types/src/components/Tabs/ScrollableTab.d.ts +3 -0
  191. package/types/src/components/Tabs/ScrollableTabs.d.ts +3 -0
  192. package/types/src/components/Tabs/StyledScrollableTab.d.ts +61 -0
  193. package/types/src/components/Tabs/StyledScrollableTabs.d.ts +61 -0
  194. package/types/src/components/Tabs/StyledTabs.d.ts +22 -22
  195. package/types/src/components/Tabs/__tests__/ScrollableTab.spec.d.ts +1 -0
  196. package/types/src/components/Tabs/__tests__/ScrollableTabs.spec.d.ts +1 -0
  197. package/types/src/components/Tabs/__tests__/index.spec.d.ts +0 -0
  198. package/types/src/components/Tabs/index.d.ts +28 -19
  199. package/types/src/components/Tabs/utils.d.ts +2 -0
  200. package/types/src/components/Tag/StyledTag.d.ts +20 -0
  201. package/types/src/components/Tag/__tests__/Tag.spec.d.ts +1 -0
  202. package/types/src/components/Tag/index.d.ts +21 -0
  203. package/types/src/components/Typography/Text/StyledText.d.ts +0 -0
  204. package/types/src/components/Typography/Text/__tests__/StyledText.spec.d.ts +0 -0
  205. package/types/src/components/Typography/Text/__tests__/index.spec.d.ts +0 -0
  206. package/types/src/components/Typography/Text/index.d.ts +0 -0
  207. package/types/src/components/Typography/index.d.ts +0 -0
  208. package/types/src/index.d.ts +6 -1
  209. package/types/src/testHelpers/renderWithTheme.d.ts +0 -0
  210. package/types/src/theme/__tests__/index.spec.d.ts +0 -0
  211. package/types/src/theme/components/avatar.d.ts +32 -0
  212. package/types/src/theme/components/badge.d.ts +12 -13
  213. package/types/src/theme/components/bottomNavigation.d.ts +0 -0
  214. package/types/src/theme/components/button.d.ts +37 -0
  215. package/types/src/theme/components/card.d.ts +5 -1
  216. package/types/src/theme/components/divider.d.ts +0 -0
  217. package/types/src/theme/components/drawer.d.ts +21 -0
  218. package/types/src/theme/components/fab.d.ts +8 -1
  219. package/types/src/theme/components/icon.d.ts +0 -0
  220. package/types/src/theme/components/progress.d.ts +21 -0
  221. package/types/src/theme/components/tabs.d.ts +14 -2
  222. package/types/src/theme/components/tag.d.ts +30 -0
  223. package/types/src/theme/components/typography.d.ts +0 -0
  224. package/types/src/theme/global/borders.d.ts +7 -1
  225. package/types/src/theme/global/colors.d.ts +6 -1
  226. package/types/src/theme/global/index.d.ts +7 -1
  227. package/types/src/theme/global/scale.d.ts +1 -0
  228. package/types/src/theme/global/space.d.ts +0 -0
  229. package/types/src/theme/global/typography.d.ts +0 -0
  230. package/types/src/theme/index.d.ts +10 -0
  231. package/types/src/types.d.ts +0 -0
  232. package/types/src/utils/__tests__/scale.spec.d.ts +0 -0
  233. package/types/src/utils/helpers.d.ts +0 -0
  234. package/types/src/utils/hooks.d.ts +1 -0
  235. package/types/src/utils/scale.d.ts +0 -0
  236. package/.expo/README.md +0 -15
  237. package/.expo/packager-info.json +0 -10
  238. package/.expo/settings.json +0 -10
  239. package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +0 -33
  240. package/testUtils/setup.ts +0 -18
  241. package/types/src/components/FAB/StyledFABContainer.d.ts +0 -3
  242. package/types/src/components/FAB/StyledFABIcon.d.ts +0 -3
  243. package/types/src/styled-components.d.ts +0 -6
@@ -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
+ });
@@ -0,0 +1,87 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`StyledImage renders correct style 1`] = `
4
+ <Image
5
+ source={
6
+ Object {
7
+ "uri": "https://i.pravatar.cc/300",
8
+ }
9
+ }
10
+ style={
11
+ Array [
12
+ Object {
13
+ "height": 32,
14
+ "width": 32,
15
+ },
16
+ undefined,
17
+ ]
18
+ }
19
+ themeSize="small"
20
+ />
21
+ `;
22
+
23
+ exports[`StyledPressable renders correct style 1`] = `
24
+ <View
25
+ accessible={true}
26
+ collapsable={false}
27
+ focusable={false}
28
+ nativeID="animatedComponent"
29
+ onClick={[Function]}
30
+ onResponderGrant={[Function]}
31
+ onResponderMove={[Function]}
32
+ onResponderRelease={[Function]}
33
+ onResponderTerminate={[Function]}
34
+ onResponderTerminationRequest={[Function]}
35
+ onStartShouldSetResponder={[Function]}
36
+ style={
37
+ Object {
38
+ "borderColor": "#7622d7",
39
+ "borderRadius": 16,
40
+ "borderWidth": 1,
41
+ "height": 32,
42
+ "opacity": 1,
43
+ "overflow": "hidden",
44
+ "width": 32,
45
+ }
46
+ }
47
+ />
48
+ `;
49
+
50
+ exports[`StyledText renders correct style 1`] = `
51
+ <Text
52
+ style={
53
+ Array [
54
+ Object {
55
+ "color": "#7622d7",
56
+ "fontSize": 16,
57
+ "overflow": "hidden",
58
+ },
59
+ undefined,
60
+ ]
61
+ }
62
+ themeIntent="primary"
63
+ themeSize="small"
64
+ >
65
+ MD
66
+ </Text>
67
+ `;
68
+
69
+ exports[`StyledView renders correct style 1`] = `
70
+ <View
71
+ style={
72
+ Array [
73
+ Object {
74
+ "borderColor": "#7622d7",
75
+ "borderRadius": 16,
76
+ "borderWidth": 1,
77
+ "height": 32,
78
+ "overflow": "hidden",
79
+ "width": 32,
80
+ },
81
+ undefined,
82
+ ]
83
+ }
84
+ themeIntent="primary"
85
+ themeSize="small"
86
+ />
87
+ `;