@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
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
3
  import { AnimatedFABIcon } from './AnimatedFABIcon';
4
- import { StyledFABContainer, StyledFABIcon } from './StyledFAB';
4
+ import { StyledFABContainer, StyledFABIcon, StyledFABText } from './StyledFAB';
5
5
  import { IconName } from '../Icon';
6
6
 
7
7
  export interface FABProps {
@@ -10,41 +10,91 @@ export interface FABProps {
10
10
  */
11
11
  icon: IconName;
12
12
 
13
+ /**
14
+ * title of the component.
15
+ */
16
+ title?: string;
17
+
13
18
  /**
14
19
  * This function is called on pressing the button.
15
20
  */
16
21
  onPress?: () => void;
22
+
17
23
  /**
18
24
  * Specify if the button is animated.
19
25
  */
20
26
  animated?: boolean;
27
+
21
28
  /**
22
29
  * Specify if the button is in active state. It only works if animated is true.
23
30
  */
24
31
  active?: boolean;
32
+
25
33
  /**
26
34
  * Additional style.
27
35
  */
28
36
  style?: StyleProp<ViewStyle>;
37
+
29
38
  /**
30
39
  * Testing id of the component.
31
40
  */
32
41
  testID?: string;
33
42
  }
34
43
 
35
- const FAB = ({ onPress, icon, animated, testID, active, style }: FABProps) => (
36
- <StyledFABContainer
37
- testID={testID}
38
- onPress={onPress}
39
- activeOpacity={0.6}
40
- style={style}
41
- >
42
- {animated ? (
44
+ const IconOnlyContent = ({
45
+ icon,
46
+ animated,
47
+ active,
48
+ }: {
49
+ icon: IconName;
50
+ animated?: boolean;
51
+
52
+ active?: boolean;
53
+ }) => {
54
+ if (animated) {
55
+ return (
43
56
  <AnimatedFABIcon active={active} icon={icon} testID="animated-fab-icon" />
44
- ) : (
45
- <StyledFABIcon icon={icon} testID="styled-fab-icon" />
46
- )}
47
- </StyledFABContainer>
57
+ );
58
+ }
59
+ return <StyledFABIcon icon={icon} testID="styled-fab-icon" />;
60
+ };
61
+
62
+ const IconWithTextContent = ({
63
+ icon,
64
+ title,
65
+ }: {
66
+ icon: IconName;
67
+ title?: string;
68
+ }) => (
69
+ <>
70
+ <StyledFABIcon size="xsmall" icon={icon} testID="styled-fab-icon" />
71
+ <StyledFABText>{title}</StyledFABText>
72
+ </>
48
73
  );
74
+ const FAB = ({
75
+ onPress,
76
+ title,
77
+ icon,
78
+ animated,
79
+ testID,
80
+ active,
81
+ style,
82
+ }: FABProps): JSX.Element => {
83
+ const isIconOnly = !title;
84
+ return (
85
+ <StyledFABContainer
86
+ testID={testID}
87
+ style={style}
88
+ onPress={onPress}
89
+ activeOpacity={0.6}
90
+ >
91
+ {isIconOnly ? (
92
+ <IconOnlyContent animated={animated} active={active} icon={icon} />
93
+ ) : (
94
+ <IconWithTextContent icon={icon} title={title} />
95
+ )}
96
+ </StyledFABContainer>
97
+ );
98
+ };
49
99
 
50
100
  export default FAB;
@@ -1,22 +1,41 @@
1
- import { TouchableHighlight, TouchableHighlightProps } from 'react-native';
1
+ import {
2
+ Text,
3
+ TextProps,
4
+ TouchableHighlight,
5
+ TouchableHighlightProps,
6
+ } from 'react-native';
2
7
  import styled from '@emotion/native';
3
8
  import Icon, { IconProps } from '../Icon';
4
9
 
5
10
  const StyledFABContainer = styled(TouchableHighlight)<TouchableHighlightProps>(
6
11
  ({ theme }) => ({
7
- height: theme.__hd__.fab.sizes.height,
8
- width: theme.__hd__.fab.sizes.width,
9
12
  backgroundColor: theme.__hd__.fab.colors.buttonBackground,
10
- borderRadius: 999,
13
+ borderRadius: theme.radii.rounded,
11
14
  alignItems: 'center',
12
15
  justifyContent: 'center',
13
16
  overflow: 'hidden',
17
+ alignSelf: 'flex-start',
18
+ paddingHorizontal: theme.__hd__.fab.space.containerPaddingHorizontal,
19
+ paddingVertical: theme.__hd__.fab.space.containerPaddingVertical,
20
+ flexDirection: 'row',
14
21
  })
15
22
  );
16
23
 
17
24
  const StyledFABIcon = styled(Icon)<IconProps>(({ theme }) => ({
18
25
  color: theme.__hd__.fab.colors.icon,
19
- fontSize: theme.__hd__.fab.fontSizes.buttonIcon,
26
+ lineHeight: theme.__hd__.fab.lineHeights.icon,
27
+ textAlignVertical: 'center',
28
+ textAlign: 'center',
20
29
  }));
21
30
 
22
- export { StyledFABContainer, StyledFABIcon };
31
+ const StyledFABText = styled(Text)<TextProps>(({ theme }) => ({
32
+ fontFamily: theme.__hd__.fab.fonts.title,
33
+ fontSize: theme.__hd__.fab.fontSizes.title,
34
+ lineHeight: theme.__hd__.fab.lineHeights.title,
35
+ color: theme.__hd__.fab.colors.titleText,
36
+ textAlignVertical: 'center',
37
+ textAlign: 'center',
38
+ marginHorizontal: theme.__hd__.fab.space.titleMarginHorizontal,
39
+ }));
40
+
41
+ export { StyledFABContainer, StyledFABIcon, StyledFABText };
@@ -25,7 +25,9 @@ exports[`AnimatedFABIcon renders correctly when isActive is false 1`] = `
25
25
  Array [
26
26
  Object {
27
27
  "color": "#ffffff",
28
- "fontSize": 24,
28
+ "lineHeight": 24,
29
+ "textAlign": "center",
30
+ "textAlignVertical": "center",
29
31
  },
30
32
  Object {},
31
33
  ],
@@ -62,7 +64,9 @@ exports[`AnimatedFABIcon renders correctly when isActive is true 1`] = `
62
64
  Array [
63
65
  Object {
64
66
  "color": "#ffffff",
65
- "fontSize": 24,
67
+ "lineHeight": 24,
68
+ "textAlign": "center",
69
+ "textAlignVertical": "center",
66
70
  },
67
71
  Object {},
68
72
  ],
@@ -15,12 +15,14 @@ exports[`StyledFABContainer renders correctly 1`] = `
15
15
  Array [
16
16
  Object {
17
17
  "alignItems": "center",
18
+ "alignSelf": "flex-start",
18
19
  "backgroundColor": "#292a2b",
19
20
  "borderRadius": 999,
20
- "height": 64,
21
+ "flexDirection": "row",
21
22
  "justifyContent": "center",
22
23
  "overflow": "hidden",
23
- "width": 64,
24
+ "paddingHorizontal": 16,
25
+ "paddingVertical": 16,
24
26
  },
25
27
  undefined,
26
28
  ]
@@ -60,7 +62,9 @@ exports[`StyledFABIcon renders correctly 1`] = `
60
62
  Array [
61
63
  Object {
62
64
  "color": "#ffffff",
63
- "fontSize": 24,
65
+ "lineHeight": 24,
66
+ "textAlign": "center",
67
+ "textAlignVertical": "center",
64
68
  },
65
69
  undefined,
66
70
  ],
@@ -15,12 +15,14 @@ exports[`FAB when animated is false renders StyledFABIcon 1`] = `
15
15
  Array [
16
16
  Object {
17
17
  "alignItems": "center",
18
+ "alignSelf": "flex-start",
18
19
  "backgroundColor": "#292a2b",
19
20
  "borderRadius": 999,
20
- "height": 64,
21
+ "flexDirection": "row",
21
22
  "justifyContent": "center",
22
23
  "overflow": "hidden",
23
- "width": 64,
24
+ "paddingHorizontal": 16,
25
+ "paddingVertical": 16,
24
26
  },
25
27
  Object {
26
28
  "backgroundColor": "#292a2b",
@@ -39,7 +41,9 @@ exports[`FAB when animated is false renders StyledFABIcon 1`] = `
39
41
  Array [
40
42
  Object {
41
43
  "color": "#ffffff",
42
- "fontSize": 24,
44
+ "lineHeight": 24,
45
+ "textAlign": "center",
46
+ "textAlignVertical": "center",
43
47
  },
44
48
  undefined,
45
49
  ],
@@ -67,12 +71,14 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
67
71
  Array [
68
72
  Object {
69
73
  "alignItems": "center",
74
+ "alignSelf": "flex-start",
70
75
  "backgroundColor": "#292a2b",
71
76
  "borderRadius": 999,
72
- "height": 64,
77
+ "flexDirection": "row",
73
78
  "justifyContent": "center",
74
79
  "overflow": "hidden",
75
- "width": 64,
80
+ "paddingHorizontal": 16,
81
+ "paddingVertical": 16,
76
82
  },
77
83
  Object {
78
84
  "backgroundColor": "#292a2b",
@@ -104,7 +110,9 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
104
110
  Array [
105
111
  Object {
106
112
  "color": "#ffffff",
107
- "fontSize": 24,
113
+ "lineHeight": 24,
114
+ "textAlign": "center",
115
+ "textAlignVertical": "center",
108
116
  },
109
117
  Object {},
110
118
  ],
@@ -117,3 +125,77 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
117
125
  </View>
118
126
  </View>
119
127
  `;
128
+
129
+ exports[`FAB when title has value renders correctly 1`] = `
130
+ <View
131
+ accessible={true}
132
+ focusable={false}
133
+ onClick={[Function]}
134
+ onResponderGrant={[Function]}
135
+ onResponderMove={[Function]}
136
+ onResponderRelease={[Function]}
137
+ onResponderTerminate={[Function]}
138
+ onResponderTerminationRequest={[Function]}
139
+ onStartShouldSetResponder={[Function]}
140
+ style={
141
+ Array [
142
+ Object {
143
+ "alignItems": "center",
144
+ "alignSelf": "flex-start",
145
+ "backgroundColor": "#292a2b",
146
+ "borderRadius": 999,
147
+ "flexDirection": "row",
148
+ "justifyContent": "center",
149
+ "overflow": "hidden",
150
+ "paddingHorizontal": 16,
151
+ "paddingVertical": 16,
152
+ },
153
+ Object {
154
+ "backgroundColor": "#292a2b",
155
+ },
156
+ ]
157
+ }
158
+ >
159
+ <HeroIcon
160
+ name="pencil"
161
+ style={
162
+ Array [
163
+ Object {
164
+ "color": "#292a2b",
165
+ "fontSize": 16,
166
+ },
167
+ Array [
168
+ Object {
169
+ "color": "#ffffff",
170
+ "lineHeight": 24,
171
+ "textAlign": "center",
172
+ "textAlignVertical": "center",
173
+ },
174
+ undefined,
175
+ ],
176
+ ]
177
+ }
178
+ testID="styled-fab-icon"
179
+ themeIntent="text"
180
+ themeSize="xsmall"
181
+ />
182
+ <Text
183
+ style={
184
+ Array [
185
+ Object {
186
+ "color": "#ffffff",
187
+ "fontFamily": "BeVietnamPro-SemiBold",
188
+ "fontSize": 16,
189
+ "lineHeight": 24,
190
+ "marginHorizontal": 8,
191
+ "textAlign": "center",
192
+ "textAlignVertical": "center",
193
+ },
194
+ undefined,
195
+ ]
196
+ }
197
+ >
198
+ Shout out
199
+ </Text>
200
+ </View>
201
+ `;
@@ -20,6 +20,22 @@ describe('FAB', () => {
20
20
  });
21
21
  });
22
22
 
23
+ describe('when title has value', () => {
24
+ it('renders correctly', () => {
25
+ const { queryAllByTestId, queryAllByText, toJSON } = renderWithTheme(
26
+ <FAB
27
+ icon="pencil"
28
+ title="Shout out"
29
+ style={{ backgroundColor: theme.colors.backgroundDark }}
30
+ />
31
+ );
32
+
33
+ expect(toJSON()).toMatchSnapshot();
34
+ expect(queryAllByTestId('styled-fab-icon')).toHaveLength(1);
35
+ expect(queryAllByText('Shout out')).toHaveLength(1);
36
+ });
37
+ });
38
+
23
39
  describe('when animated is false', () => {
24
40
  it('renders StyledFABIcon', () => {
25
41
  const { queryAllByTestId, toJSON } = renderWithTheme(
@@ -0,0 +1,73 @@
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import { Animated, StyleProp, ViewStyle, ViewProps } from 'react-native';
3
+
4
+ import { StyledWrapper, StyledInner } from './StyledProgressBar';
5
+
6
+ export interface ProgressBarProps extends ViewProps {
7
+ /**
8
+ * The progress completion percentage: 0-100.
9
+ */
10
+ value: number;
11
+ /**
12
+ * Set intent for your progress.
13
+ */
14
+ intent?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
15
+ /**
16
+ * Additional style.
17
+ */
18
+ style?: StyleProp<ViewStyle>;
19
+ /*
20
+ * Testing id of the component.
21
+ * */
22
+ testID?: string;
23
+ }
24
+
25
+ const ProgressBar = ({
26
+ value,
27
+ intent = 'primary',
28
+ style,
29
+ testID,
30
+ ...nativeProps
31
+ }: ProgressBarProps): JSX.Element => {
32
+ const [width, setWidth] = useState(0);
33
+ const progressAnimatedValue = useRef<Animated.Value>(new Animated.Value(0));
34
+
35
+ useEffect(() => {
36
+ const animation = Animated.timing(progressAnimatedValue.current, {
37
+ toValue: value,
38
+ useNativeDriver: true,
39
+ });
40
+
41
+ animation.start();
42
+
43
+ return () => animation.stop();
44
+ }, [value]);
45
+
46
+ const interpolateTranslateX = progressAnimatedValue.current.interpolate({
47
+ inputRange: [0, 100],
48
+ outputRange: [-width, 0],
49
+ extrapolate: 'clamp',
50
+ });
51
+
52
+ const interpolateBorderRadius = progressAnimatedValue.current.interpolate({
53
+ inputRange: [99, 100], // Transition range to remove bother when reached 100%
54
+ outputRange: [999, 0],
55
+ extrapolate: 'clamp',
56
+ });
57
+
58
+ return (
59
+ <StyledWrapper {...nativeProps} testID={testID} style={style}>
60
+ <StyledInner
61
+ themeIntent={intent}
62
+ onLayout={({ nativeEvent }) => setWidth(nativeEvent.layout.width)}
63
+ style={{
64
+ transform: [{ translateX: interpolateTranslateX }],
65
+ borderTopRightRadius: interpolateBorderRadius,
66
+ borderBottomRightRadius: interpolateBorderRadius,
67
+ }}
68
+ />
69
+ </StyledWrapper>
70
+ );
71
+ };
72
+
73
+ export default ProgressBar;
@@ -0,0 +1,165 @@
1
+ import { useTheme } from '@emotion/react';
2
+ import React, { useEffect, useRef } from 'react';
3
+ import {
4
+ Animated,
5
+ View,
6
+ StyleSheet,
7
+ ViewProps,
8
+ StyleProp,
9
+ ViewStyle,
10
+ } from 'react-native';
11
+ import {
12
+ DonutCircle,
13
+ HalfCircleInnerFG,
14
+ HalfCircleInnerBG,
15
+ HalfCircleWrapper,
16
+ StrokeEnd,
17
+ } from './StyledProgressCircle';
18
+ import { ThemeIntent } from './types';
19
+ import Typography from '../Typography';
20
+
21
+ export interface ProgressCircleProps extends ViewProps {
22
+ /**
23
+ * The progress completion percentage: 0-100.
24
+ */
25
+ value: number;
26
+ /**
27
+ * Set intent for your progress.
28
+ */
29
+ intent?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
30
+ /**
31
+ * Additional style.
32
+ */
33
+ style?: StyleProp<ViewStyle>;
34
+ /*
35
+ * Testing id of the component.
36
+ * */
37
+ testID?: string;
38
+ }
39
+
40
+ const HalfCircle = ({
41
+ type,
42
+ themeIntent = 'primary',
43
+ }: {
44
+ type: 'background' | 'foreground';
45
+ themeIntent?: ThemeIntent;
46
+ }) => (
47
+ <HalfCircleWrapper>
48
+ {type === 'background' ? (
49
+ <HalfCircleInnerBG />
50
+ ) : (
51
+ <HalfCircleInnerFG themeIntent={themeIntent} />
52
+ )}
53
+ </HalfCircleWrapper>
54
+ );
55
+
56
+ const ProgressCircle = ({
57
+ value,
58
+ intent = 'primary',
59
+ style,
60
+ testID,
61
+ ...nativeProps
62
+ }: ProgressCircleProps): JSX.Element => {
63
+ const theme = useTheme();
64
+ const { radius } = theme.__hd__.progress.sizes;
65
+ const progressAnimatedValue = useRef<Animated.Value>(new Animated.Value(0));
66
+
67
+ useEffect(() => {
68
+ const animation = Animated.timing(progressAnimatedValue.current, {
69
+ toValue: value,
70
+ useNativeDriver: true,
71
+ });
72
+
73
+ animation.start();
74
+
75
+ return () => animation.stop();
76
+ }, [value]);
77
+
78
+ // Animate progress circle: 0% => 50%
79
+ const interpolateRotateRightHalf = progressAnimatedValue.current.interpolate({
80
+ inputRange: [0, 50],
81
+ outputRange: ['0deg', '180deg'],
82
+ extrapolate: 'clamp',
83
+ });
84
+
85
+ const interpolateOpacityRightHalf = progressAnimatedValue.current.interpolate(
86
+ {
87
+ inputRange: [50, 51], // Transition between left and right half
88
+ outputRange: [1, 0],
89
+ extrapolate: 'clamp',
90
+ }
91
+ );
92
+
93
+ // Animate progress circle: 50% => 100%
94
+ const interpolateRotateSecondHalf = progressAnimatedValue.current.interpolate(
95
+ {
96
+ inputRange: [50, 100],
97
+ outputRange: ['0deg', '180deg'],
98
+ extrapolate: 'clamp',
99
+ }
100
+ );
101
+
102
+ // Curve at the end of progress stroke
103
+ const interpolateDotRotate = progressAnimatedValue.current.interpolate({
104
+ inputRange: [0, 100],
105
+ outputRange: ['0deg', '360deg'],
106
+ extrapolate: 'clamp',
107
+ });
108
+
109
+ return (
110
+ <View {...nativeProps} testID={testID} style={style}>
111
+ <View
112
+ style={{
113
+ flexDirection: 'row',
114
+ }}
115
+ >
116
+ <View>
117
+ <HalfCircle type="foreground" themeIntent={intent} />
118
+ <Animated.View
119
+ style={{
120
+ ...StyleSheet.absoluteFillObject,
121
+ transform: [
122
+ { translateX: radius / 2 },
123
+ { rotate: interpolateRotateSecondHalf },
124
+ { translateX: -radius / 2 },
125
+ ],
126
+ }}
127
+ >
128
+ <HalfCircle type="background" />
129
+ </Animated.View>
130
+ </View>
131
+ <View style={{ transform: [{ rotate: '180deg' }], zIndex: 1 }}>
132
+ <HalfCircle type="foreground" themeIntent={intent} />
133
+ <Animated.View
134
+ style={{
135
+ ...StyleSheet.absoluteFillObject,
136
+ transform: [
137
+ { translateX: radius / 2 },
138
+ { rotate: interpolateRotateRightHalf },
139
+ { translateX: -radius / 2 },
140
+ ],
141
+ opacity: interpolateOpacityRightHalf,
142
+ }}
143
+ >
144
+ <HalfCircle type="background" />
145
+ </Animated.View>
146
+ </View>
147
+ <StrokeEnd themeIntent={intent} />
148
+ <Animated.View
149
+ style={{
150
+ ...StyleSheet.absoluteFillObject,
151
+ zIndex: 2,
152
+ transform: [{ rotate: interpolateDotRotate }],
153
+ }}
154
+ >
155
+ <StrokeEnd themeIntent={intent} />
156
+ </Animated.View>
157
+ <DonutCircle>
158
+ <Typography.Text fontSize="xlarge">{`${value}%`}</Typography.Text>
159
+ </DonutCircle>
160
+ </View>
161
+ </View>
162
+ );
163
+ };
164
+
165
+ export default ProgressCircle;
@@ -0,0 +1,21 @@
1
+ import { Animated, View, ViewProps } from 'react-native';
2
+ import styled from '@emotion/native';
3
+
4
+ import { ThemeIntent } from './types';
5
+
6
+ const StyledWrapper = styled(View)<ViewProps>(({ theme }) => ({
7
+ height: theme.__hd__.progress.sizes.barHeight,
8
+ alignSelf: 'stretch',
9
+ backgroundColor: theme.__hd__.progress.colors.background,
10
+ overflow: 'hidden',
11
+ }));
12
+
13
+ const StyledInner = styled(Animated.View)<{ themeIntent: ThemeIntent }>(
14
+ ({ theme, themeIntent }) => ({
15
+ flex: 1,
16
+ alignSelf: 'stretch',
17
+ backgroundColor: theme.__hd__.progress.colors[themeIntent],
18
+ })
19
+ );
20
+
21
+ export { StyledWrapper, StyledInner };
@@ -0,0 +1,66 @@
1
+ import { View, ViewProps } from 'react-native';
2
+ import styled from '@emotion/native';
3
+
4
+ import { ThemeIntent } from './types';
5
+
6
+ const HalfCircleWrapper = styled(View)<ViewProps>(({ theme }) => ({
7
+ width: theme.__hd__.progress.sizes.radius,
8
+ height: theme.__hd__.progress.sizes.radius * 2,
9
+ overflow: 'hidden',
10
+ }));
11
+
12
+ const HalfCircleInnerFG = styled(View)<{ themeIntent: ThemeIntent }>(
13
+ ({ theme, themeIntent }) => ({
14
+ width: theme.__hd__.progress.sizes.radius * 2,
15
+ height: theme.__hd__.progress.sizes.radius * 2,
16
+ backgroundColor: theme.__hd__.progress.colors[themeIntent],
17
+ borderRadius: theme.__hd__.progress.radii.default,
18
+ })
19
+ );
20
+
21
+ const HalfCircleInnerBG = styled(View)<ViewProps>(({ theme }) => ({
22
+ width: theme.__hd__.progress.sizes.radius * 2,
23
+ height: theme.__hd__.progress.sizes.radius * 2,
24
+ backgroundColor: theme.__hd__.progress.colors.background,
25
+ borderRadius: theme.__hd__.progress.radii.default,
26
+ }));
27
+
28
+ const DonutCircle = styled(View)<ViewProps>(({ theme }) => ({
29
+ position: 'absolute',
30
+ top: theme.__hd__.progress.sizes.strokeWidth,
31
+ left: theme.__hd__.progress.sizes.strokeWidth,
32
+ width:
33
+ theme.__hd__.progress.sizes.radius * 2 -
34
+ theme.__hd__.progress.sizes.strokeWidth * 2,
35
+ height:
36
+ theme.__hd__.progress.sizes.radius * 2 -
37
+ theme.__hd__.progress.sizes.strokeWidth * 2,
38
+ zIndex: 3,
39
+ backgroundColor: theme.__hd__.progress.colors.innerBackground,
40
+ borderRadius: theme.__hd__.progress.radii.default,
41
+ alignItems: 'center',
42
+ justifyContent: 'center',
43
+ }));
44
+
45
+ const StrokeEnd = styled(View)<{ themeIntent: ThemeIntent }>(
46
+ ({ theme, themeIntent }) => ({
47
+ position: 'absolute',
48
+ top: 0,
49
+ left:
50
+ theme.__hd__.progress.sizes.radius -
51
+ theme.__hd__.progress.sizes.strokeWidth / 2,
52
+ width: theme.__hd__.progress.sizes.strokeWidth,
53
+ height: theme.__hd__.progress.sizes.strokeWidth,
54
+ borderRadius: theme.__hd__.progress.radii.default,
55
+ backgroundColor: theme.__hd__.progress.colors[themeIntent],
56
+ zIndex: 2,
57
+ })
58
+ );
59
+
60
+ export {
61
+ DonutCircle,
62
+ HalfCircleWrapper,
63
+ HalfCircleInnerFG,
64
+ HalfCircleInnerBG,
65
+ StrokeEnd,
66
+ };