@hero-design/rn 7.1.3-alpha5 → 7.1.3-alpha8

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 (165) hide show
  1. package/.eslintrc.json +0 -6
  2. package/.expo/packager-info.json +1 -1
  3. package/babel.config.js +0 -14
  4. package/es/index.js +2787 -8941
  5. package/jest-setup.ts +0 -1
  6. package/jest.config.js +2 -4
  7. package/lib/index.js +2822 -8956
  8. package/package.json +5 -7
  9. package/playground/components/BottomNavigation.tsx +14 -11
  10. package/playground/components/Button.tsx +67 -0
  11. package/playground/components/Card.tsx +141 -107
  12. package/playground/components/Tabs.tsx +44 -0
  13. package/playground/index.tsx +13 -7
  14. package/src/components/Badge/StyledBadge.tsx +19 -21
  15. package/src/components/Badge/__tests__/Badge.spec.tsx +9 -18
  16. package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +76 -96
  17. package/src/components/Badge/index.tsx +1 -1
  18. package/src/components/BottomNavigation/StyledBottomNavigation.tsx +44 -42
  19. package/src/components/BottomNavigation/__tests__/__snapshots__/{BottomNavigation.spec.tsx.snap → index.spec.tsx.snap} +130 -96
  20. package/src/components/BottomNavigation/__tests__/{BottomNavigation.spec.tsx → index.spec.tsx} +4 -4
  21. package/src/components/BottomNavigation/index.tsx +28 -32
  22. package/src/components/Button/IconButton.tsx +62 -0
  23. package/src/components/Button/__tests__/__snapshots__/index.spec.tsx.snap +46 -0
  24. package/src/components/Button/__tests__/index.spec.tsx +23 -0
  25. package/src/components/Button/index.tsx +5 -0
  26. package/src/components/Card/StyledCard.tsx +6 -6
  27. package/src/components/Card/__tests__/StyledCard.spec.tsx +2 -7
  28. package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +8 -11
  29. package/src/components/Card/__tests__/__snapshots__/{Card.spec.tsx.snap → index.spec.tsx.snap} +2 -8
  30. package/src/components/Card/__tests__/index.spec.tsx +35 -0
  31. package/src/components/Divider/StyledDivider.tsx +18 -60
  32. package/src/components/Divider/__tests__/StyledDivider.spec.tsx +5 -10
  33. package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +106 -70
  34. package/src/components/Divider/index.tsx +1 -1
  35. package/src/components/FAB/ActionGroup/ActionItem.tsx +2 -4
  36. package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +36 -37
  37. package/src/components/FAB/ActionGroup/StyledActionItem.tsx +26 -24
  38. package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +271 -245
  39. package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +29 -33
  40. package/src/components/FAB/ActionGroup/index.tsx +1 -5
  41. package/src/components/FAB/AnimatedFABIcon.tsx +1 -1
  42. package/src/components/FAB/FAB.tsx +5 -9
  43. package/src/components/FAB/StyledFAB.tsx +22 -0
  44. package/src/components/FAB/__tests__/AnimatedFABIcon.spec.tsx +3 -6
  45. package/src/components/FAB/__tests__/StyledFAB.spec.tsx +24 -0
  46. package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +14 -10
  47. package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +72 -0
  48. package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +16 -17
  49. package/src/components/FAB/__tests__/index.spec.tsx +21 -26
  50. package/src/components/Icon/HeroIcon/index.tsx +5 -7
  51. package/src/components/Icon/__tests__/__snapshots__/{Icon.spec.tsx.snap → index.spec.tsx.snap} +21 -12
  52. package/src/components/Icon/__tests__/index.spec.tsx +25 -0
  53. package/src/components/Icon/index.tsx +1 -1
  54. package/src/components/Tabs/StyledTabs.tsx +70 -0
  55. package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +321 -0
  56. package/src/components/Tabs/__tests__/index.spec.tsx +79 -0
  57. package/src/components/Tabs/index.tsx +185 -0
  58. package/src/components/Typography/Text/StyledText.tsx +19 -64
  59. package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +90 -63
  60. package/src/emotion.d.ts +6 -0
  61. package/src/index.ts +9 -3
  62. package/src/testHelpers/renderWithTheme.tsx +2 -1
  63. package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +70 -48
  64. package/src/theme/components/badge.ts +10 -9
  65. package/src/theme/components/bottomNavigation.ts +7 -3
  66. package/src/theme/components/card.ts +2 -2
  67. package/src/theme/components/divider.ts +6 -6
  68. package/src/theme/components/fab.ts +19 -17
  69. package/src/theme/components/tabs.ts +20 -0
  70. package/src/theme/components/typography.ts +4 -4
  71. package/src/theme/global/borders.ts +8 -2
  72. package/src/theme/global/colors.ts +3 -1
  73. package/src/theme/global/index.ts +31 -17
  74. package/src/theme/global/scale.ts +18 -0
  75. package/src/theme/global/space.ts +23 -13
  76. package/src/theme/global/typography.ts +71 -27
  77. package/src/theme/index.ts +29 -13
  78. package/src/types.ts +7 -0
  79. package/src/utils/__tests__/scale.spec.ts +3 -3
  80. package/testUtils/setup.ts +11 -0
  81. package/tsconfig.json +1 -5
  82. package/types/playground/components/BottomNavigation.d.ts +2 -2
  83. package/types/playground/components/Button.d.ts +2 -0
  84. package/types/playground/components/Tabs.d.ts +2 -0
  85. package/types/src/components/Badge/StyledBadge.d.ts +16 -5
  86. package/types/src/components/Badge/index.d.ts +1 -1
  87. package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +44 -9
  88. package/types/src/components/{Typography/Text/__test__ → BottomNavigation/__tests__}/index.spec.d.ts +0 -0
  89. package/types/src/components/BottomNavigation/index.d.ts +19 -14
  90. package/types/src/components/Button/IconButton.d.ts +34 -0
  91. package/types/{theme → src/components/Button}/__tests__/index.spec.d.ts +0 -0
  92. package/types/src/components/Button/index.d.ts +4 -0
  93. package/types/src/components/Card/StyledCard.d.ts +7 -1
  94. package/types/{components/Card/__tests__/Card.spec.d.ts → src/components/Card/__tests__/index.spec.d.ts} +0 -0
  95. package/types/src/components/Divider/StyledDivider.d.ts +8 -2
  96. package/types/src/components/Divider/index.d.ts +1 -1
  97. package/types/src/components/FAB/ActionGroup/StyledActionGroup.d.ts +25 -7
  98. package/types/src/components/FAB/ActionGroup/StyledActionItem.d.ts +11 -2
  99. package/types/src/components/FAB/ActionGroup/index.d.ts +1 -1
  100. package/types/src/components/FAB/FAB.d.ts +4 -4
  101. package/types/src/components/FAB/StyledFAB.d.ts +14 -0
  102. package/types/{components/Card/__tests__/StyledCard.spec.d.ts → src/components/FAB/__tests__/StyledFAB.spec.d.ts} +0 -0
  103. package/types/src/components/Icon/HeroIcon/index.d.ts +8 -2
  104. package/types/{components/Divider/__tests__/StyledDivider.spec.d.ts → src/components/Icon/__tests__/index.spec.d.ts} +0 -0
  105. package/types/src/components/Icon/index.d.ts +1 -1
  106. package/types/src/components/Icon/utils.d.ts +1 -1
  107. package/types/src/components/Tabs/StyledTabs.d.ts +55 -0
  108. package/types/{components/ExampleComponent/__tests__/StyledView.spec.d.ts → src/components/Tabs/__tests__/index.spec.d.ts} +0 -0
  109. package/types/src/components/Tabs/index.d.ts +45 -0
  110. package/types/src/components/Typography/Text/StyledText.d.ts +8 -2
  111. package/types/src/index.d.ts +6 -3
  112. package/types/src/theme/components/badge.d.ts +8 -7
  113. package/types/src/theme/components/bottomNavigation.d.ts +8 -2
  114. package/types/src/theme/components/card.d.ts +2 -2
  115. package/types/src/theme/components/divider.d.ts +6 -6
  116. package/types/src/theme/components/fab.d.ts +19 -17
  117. package/types/src/theme/components/tabs.d.ts +15 -0
  118. package/types/src/theme/components/typography.d.ts +4 -4
  119. package/types/src/theme/global/borders.d.ts +4 -3
  120. package/types/src/theme/global/colors.d.ts +2 -2
  121. package/types/src/theme/global/index.d.ts +10 -45
  122. package/types/src/theme/global/scale.d.ts +8 -0
  123. package/types/src/theme/global/space.d.ts +8 -7
  124. package/types/src/theme/global/typography.d.ts +9 -16
  125. package/types/src/theme/index.d.ts +4 -2
  126. package/types/src/types.d.ts +5 -0
  127. package/lib/assets/fonts/be-vietnam-pro-light.ttf +0 -0
  128. package/lib/assets/fonts/be-vietnam-pro-regular.ttf +0 -0
  129. package/lib/assets/fonts/be-vietnam-pro-semibold.ttf +0 -0
  130. package/src/components/Card/__tests__/Card.spec.tsx +0 -36
  131. package/src/components/FAB/StyledFABContainer.tsx +0 -14
  132. package/src/components/FAB/StyledFABIcon.tsx +0 -9
  133. package/src/components/FAB/__tests__/StyledFABContainer.spec.tsx +0 -18
  134. package/src/components/FAB/__tests__/StyledFABIcon.spec.tsx +0 -16
  135. package/src/components/FAB/__tests__/__snapshots__/StyledFABContainer.spec.tsx.snap +0 -46
  136. package/src/components/FAB/__tests__/__snapshots__/StyledFABIcon.spec.tsx.snap +0 -21
  137. package/src/components/Icon/__tests__/Icon.spec.tsx +0 -36
  138. package/src/styled-components.ts +0 -14
  139. package/src/styled.d.ts +0 -7
  140. package/types/components/Card/StyledCard.d.ts +0 -3
  141. package/types/components/Card/index.d.ts +0 -5
  142. package/types/components/Divider/StyledDivider.d.ts +0 -7
  143. package/types/components/Divider/index.d.ts +0 -12
  144. package/types/components/ExampleComponent/StyledView.d.ts +0 -7
  145. package/types/components/ExampleComponent/index.d.ts +0 -16
  146. package/types/index.d.ts +0 -5
  147. package/types/src/components/BottomNavigation/__tests__/BottomNavigation.spec.d.ts +0 -1
  148. package/types/src/components/Card/__tests__/Card.spec.d.ts +0 -1
  149. package/types/src/components/FAB/StyledFABContainer.d.ts +0 -3
  150. package/types/src/components/FAB/StyledFABIcon.d.ts +0 -3
  151. package/types/src/components/FAB/__tests__/StyledFABContainer.spec.d.ts +0 -1
  152. package/types/src/components/FAB/__tests__/StyledFABIcon.spec.d.ts +0 -1
  153. package/types/src/components/Icon/__tests__/Icon.spec.d.ts +0 -1
  154. package/types/src/components/Typography/Text/__test__/StyledText.spec.d.ts +0 -1
  155. package/types/src/styled-components.d.ts +0 -6
  156. package/types/styled-components.d.ts +0 -6
  157. package/types/theme/components/card.d.ts +0 -10
  158. package/types/theme/components/divider.d.ts +0 -17
  159. package/types/theme/components/exampleComponent.d.ts +0 -14
  160. package/types/theme/global/borders.d.ts +0 -4
  161. package/types/theme/global/colors.d.ts +0 -26
  162. package/types/theme/global/index.d.ts +0 -63
  163. package/types/theme/global/space.d.ts +0 -12
  164. package/types/theme/global/typography.d.ts +0 -21
  165. package/types/theme/index.d.ts +0 -13
@@ -1,8 +1,8 @@
1
+ import '@testing-library/jest-native/extend-expect';
1
2
  import React from 'react';
2
- import { fireEvent, render } from '@testing-library/react-native';
3
+ import { fireEvent } from '@testing-library/react-native';
4
+ import renderWithTheme from '../../../../testHelpers/renderWithTheme';
3
5
  import ActionGroup from '..';
4
- import { ThemeProvider, theme } from '../../../../index';
5
- import '@testing-library/jest-native/extend-expect';
6
6
 
7
7
  describe('ActionGroup', () => {
8
8
  it.each`
@@ -10,32 +10,30 @@ describe('ActionGroup', () => {
10
10
  ${true}
11
11
  ${false}
12
12
  `('has active $active', ({ active }) => {
13
- const { toJSON, getByTestId, getByText } = render(
14
- <ThemeProvider theme={theme}>
15
- <ActionGroup
16
- active={active}
17
- headerTitle="What would you like to create?"
18
- items={[
19
- {
20
- icon: 'speaker',
21
- title: 'Give shout out',
22
- testID: 'speaker-action-item',
23
- },
24
- { icon: 'target', title: 'Goal', testID: 'target-action-item' },
25
- {
26
- icon: 'plane',
27
- title: 'Leave request',
28
- testID: 'plane-action-item',
29
- },
30
- {
31
- icon: 'health-bag',
32
- title: 'Safety incident',
33
- testID: 'health-bag-action-item',
34
- },
35
- { icon: 'clock', title: 'Timesheets', testID: 'clock-action-item' },
36
- ]}
37
- />
38
- </ThemeProvider>
13
+ const { toJSON, getByTestId, getByText } = renderWithTheme(
14
+ <ActionGroup
15
+ active={active}
16
+ headerTitle="What would you like to create?"
17
+ items={[
18
+ {
19
+ icon: 'speaker',
20
+ title: 'Give shout out',
21
+ testID: 'speaker-action-item',
22
+ },
23
+ { icon: 'target', title: 'Goal', testID: 'target-action-item' },
24
+ {
25
+ icon: 'plane',
26
+ title: 'Leave request',
27
+ testID: 'plane-action-item',
28
+ },
29
+ {
30
+ icon: 'health-bag',
31
+ title: 'Safety incident',
32
+ testID: 'health-bag-action-item',
33
+ },
34
+ { icon: 'clock', title: 'Timesheets', testID: 'clock-action-item' },
35
+ ]}
36
+ />
39
37
  );
40
38
 
41
39
  expect(toJSON()).toMatchSnapshot();
@@ -64,10 +62,8 @@ describe('ActionGroup', () => {
64
62
  describe('when user presses', () => {
65
63
  it('calls onPress', () => {
66
64
  const onPressSpy = jest.fn();
67
- const { getByTestId } = render(
68
- <ThemeProvider theme={theme}>
69
- <ActionGroup onPress={onPressSpy} />
70
- </ThemeProvider>
65
+ const { getByTestId } = renderWithTheme(
66
+ <ActionGroup onPress={onPressSpy} />
71
67
  );
72
68
  fireEvent(getByTestId('fab'), 'press');
73
69
  expect(onPressSpy).toBeCalledTimes(1);
@@ -29,27 +29,23 @@ export interface ActionGroupProps {
29
29
  * Title of the action group header.
30
30
  */
31
31
  headerTitle?: string;
32
-
33
32
  /**
34
33
  * This function is called on pressing the FAB button.
35
34
  * */
36
35
  onPress?: () => void;
37
-
38
36
  /**
39
37
  * Specify if the FAB button is in active state and the action group is shown.
40
38
  * */
41
39
  active?: boolean;
42
40
 
43
41
  /**
44
- * Addditional style.
42
+ * Additional style.
45
43
  */
46
44
  style?: StyleProp<ViewStyle>;
47
-
48
45
  /**
49
46
  * Action items of the action group.
50
47
  * */
51
48
  items?: Array<ActionItemProps>;
52
-
53
49
  /**
54
50
  * Testing id of the component.
55
51
  */
@@ -1,7 +1,7 @@
1
1
  import React, { useEffect, useRef } from 'react';
2
2
  import { Animated, StyleSheet } from 'react-native';
3
3
  import { IconProps } from '../Icon';
4
- import { StyledFABIcon } from './StyledFABIcon';
4
+ import { StyledFABIcon } from './StyledFAB';
5
5
 
6
6
  const AnimatedIcons = Animated.createAnimatedComponent(StyledFABIcon);
7
7
 
@@ -1,35 +1,31 @@
1
1
  import React from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
- import { IconProps } from '../Icon';
4
3
  import { AnimatedFABIcon } from './AnimatedFABIcon';
5
- import { StyledFABContainer } from './StyledFABContainer';
6
- import { StyledFABIcon } from './StyledFABIcon';
4
+ import { StyledFABContainer, StyledFABIcon } from './StyledFAB';
5
+ import { IconName } from '../Icon';
7
6
 
8
7
  export interface FABProps {
9
8
  /**
10
9
  * Name of the Icon.
11
10
  */
12
- icon: IconProps['icon'];
11
+ icon: IconName;
13
12
 
14
13
  /**
15
14
  * This function is called on pressing the button.
16
- * */
15
+ */
17
16
  onPress?: () => void;
18
-
19
17
  /**
20
18
  * Specify if the button is animated.
21
19
  */
22
20
  animated?: boolean;
23
-
24
21
  /**
25
22
  * Specify if the button is in active state. It only works if animated is true.
26
23
  */
27
24
  active?: boolean;
28
25
  /**
29
- * Addditional style.
26
+ * Additional style.
30
27
  */
31
28
  style?: StyleProp<ViewStyle>;
32
-
33
29
  /**
34
30
  * Testing id of the component.
35
31
  */
@@ -0,0 +1,22 @@
1
+ import { TouchableHighlight, TouchableHighlightProps } from 'react-native';
2
+ import styled from '@emotion/native';
3
+ import Icon, { IconProps } from '../Icon';
4
+
5
+ const StyledFABContainer = styled(TouchableHighlight)<TouchableHighlightProps>(
6
+ ({ theme }) => ({
7
+ height: theme.__hd__.fab.sizes.height,
8
+ width: theme.__hd__.fab.sizes.width,
9
+ backgroundColor: theme.__hd__.fab.colors.buttonBackground,
10
+ borderRadius: 999,
11
+ alignItems: 'center',
12
+ justifyContent: 'center',
13
+ overflow: 'hidden',
14
+ })
15
+ );
16
+
17
+ const StyledFABIcon = styled(Icon)<IconProps>(({ theme }) => ({
18
+ color: theme.__hd__.fab.colors.icon,
19
+ fontSize: theme.__hd__.fab.fontSizes.buttonIcon,
20
+ }));
21
+
22
+ export { StyledFABContainer, StyledFABIcon };
@@ -1,6 +1,5 @@
1
1
  import React from 'react';
2
- import { render } from '@testing-library/react-native';
3
- import { ThemeProvider, theme } from '../../../index';
2
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
3
  import { AnimatedFABIcon } from '../AnimatedFABIcon';
5
4
 
6
5
  describe('AnimatedFABIcon', () => {
@@ -9,10 +8,8 @@ describe('AnimatedFABIcon', () => {
9
8
  ${true}
10
9
  ${false}
11
10
  `('renders correctly when isActive is $active', ({ active }) => {
12
- const { toJSON } = render(
13
- <ThemeProvider theme={theme}>
14
- <AnimatedFABIcon active={active} icon="add" />
15
- </ThemeProvider>
11
+ const { toJSON } = renderWithTheme(
12
+ <AnimatedFABIcon active={active} icon="add" />
16
13
  );
17
14
 
18
15
  expect(toJSON()).toMatchSnapshot();
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
3
+ import { Typography } from '../../../index';
4
+ import { StyledFABContainer, StyledFABIcon } from '../StyledFAB';
5
+
6
+ describe('StyledFABContainer', () => {
7
+ it('renders correctly', () => {
8
+ const { toJSON } = renderWithTheme(
9
+ <StyledFABContainer>
10
+ <Typography.Text> button </Typography.Text>
11
+ </StyledFABContainer>
12
+ );
13
+
14
+ expect(toJSON()).toMatchSnapshot();
15
+ });
16
+ });
17
+
18
+ describe('StyledFABIcon', () => {
19
+ it('renders correctly', () => {
20
+ const { toJSON } = renderWithTheme(<StyledFABIcon icon="add" />);
21
+
22
+ expect(toJSON()).toMatchSnapshot();
23
+ });
24
+ });
@@ -22,11 +22,13 @@ exports[`AnimatedFABIcon renders correctly when isActive is false 1`] = `
22
22
  "color": "#292a2b",
23
23
  "fontSize": 24,
24
24
  },
25
- Object {
26
- "color": "#ffffff",
27
- "fontSize": 24,
28
- },
29
- Object {},
25
+ Array [
26
+ Object {
27
+ "color": "#ffffff",
28
+ "fontSize": 24,
29
+ },
30
+ Object {},
31
+ ],
30
32
  ]
31
33
  }
32
34
  themeIntent="text"
@@ -57,11 +59,13 @@ exports[`AnimatedFABIcon renders correctly when isActive is true 1`] = `
57
59
  "color": "#292a2b",
58
60
  "fontSize": 24,
59
61
  },
60
- Object {
61
- "color": "#ffffff",
62
- "fontSize": 24,
63
- },
64
- Object {},
62
+ Array [
63
+ Object {
64
+ "color": "#ffffff",
65
+ "fontSize": 24,
66
+ },
67
+ Object {},
68
+ ],
65
69
  ]
66
70
  }
67
71
  themeIntent="text"
@@ -0,0 +1,72 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`StyledFABContainer renders correctly 1`] = `
4
+ <View
5
+ accessible={true}
6
+ focusable={false}
7
+ onClick={[Function]}
8
+ onResponderGrant={[Function]}
9
+ onResponderMove={[Function]}
10
+ onResponderRelease={[Function]}
11
+ onResponderTerminate={[Function]}
12
+ onResponderTerminationRequest={[Function]}
13
+ onStartShouldSetResponder={[Function]}
14
+ style={
15
+ Array [
16
+ Object {
17
+ "alignItems": "center",
18
+ "backgroundColor": "#292a2b",
19
+ "borderRadius": 999,
20
+ "height": 64,
21
+ "justifyContent": "center",
22
+ "overflow": "hidden",
23
+ "width": 64,
24
+ },
25
+ undefined,
26
+ ]
27
+ }
28
+ >
29
+ <Text
30
+ style={
31
+ Array [
32
+ Object {
33
+ "color": "#292a2b",
34
+ "fontFamily": "BeVietnamPro-Regular",
35
+ "fontSize": 14,
36
+ "letterSpacing": 0.42,
37
+ "lineHeight": 22,
38
+ },
39
+ undefined,
40
+ ]
41
+ }
42
+ themeFontSize="medium"
43
+ themeFontWeight="regular"
44
+ themeIntent="body"
45
+ >
46
+ button
47
+ </Text>
48
+ </View>
49
+ `;
50
+
51
+ exports[`StyledFABIcon renders correctly 1`] = `
52
+ <HeroIcon
53
+ name="add"
54
+ style={
55
+ Array [
56
+ Object {
57
+ "color": "#292a2b",
58
+ "fontSize": 24,
59
+ },
60
+ Array [
61
+ Object {
62
+ "color": "#ffffff",
63
+ "fontSize": 24,
64
+ },
65
+ undefined,
66
+ ],
67
+ ]
68
+ }
69
+ themeIntent="text"
70
+ themeSize="medium"
71
+ />
72
+ `;
@@ -16,10 +16,7 @@ exports[`FAB when animated is false renders StyledFABIcon 1`] = `
16
16
  Object {
17
17
  "alignItems": "center",
18
18
  "backgroundColor": "#292a2b",
19
- "borderBottomLeftRadius": 999,
20
- "borderBottomRightRadius": 999,
21
- "borderTopLeftRadius": 999,
22
- "borderTopRightRadius": 999,
19
+ "borderRadius": 999,
23
20
  "height": 64,
24
21
  "justifyContent": "center",
25
22
  "overflow": "hidden",
@@ -39,10 +36,13 @@ exports[`FAB when animated is false renders StyledFABIcon 1`] = `
39
36
  "color": "#292a2b",
40
37
  "fontSize": 24,
41
38
  },
42
- Object {
43
- "color": "#ffffff",
44
- "fontSize": 24,
45
- },
39
+ Array [
40
+ Object {
41
+ "color": "#ffffff",
42
+ "fontSize": 24,
43
+ },
44
+ undefined,
45
+ ],
46
46
  ]
47
47
  }
48
48
  testID="styled-fab-icon"
@@ -68,10 +68,7 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
68
68
  Object {
69
69
  "alignItems": "center",
70
70
  "backgroundColor": "#292a2b",
71
- "borderBottomLeftRadius": 999,
72
- "borderBottomRightRadius": 999,
73
- "borderTopLeftRadius": 999,
74
- "borderTopRightRadius": 999,
71
+ "borderRadius": 999,
75
72
  "height": 64,
76
73
  "justifyContent": "center",
77
74
  "overflow": "hidden",
@@ -104,11 +101,13 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
104
101
  "color": "#292a2b",
105
102
  "fontSize": 24,
106
103
  },
107
- Object {
108
- "color": "#ffffff",
109
- "fontSize": 24,
110
- },
111
- Object {},
104
+ Array [
105
+ Object {
106
+ "color": "#ffffff",
107
+ "fontSize": 24,
108
+ },
109
+ Object {},
110
+ ],
112
111
  ]
113
112
  }
114
113
  testID="animated-fab-icon"
@@ -1,19 +1,18 @@
1
1
  import React from 'react';
2
- import { fireEvent, render } from '@testing-library/react-native';
3
- import { ThemeProvider, theme } from '../../../index';
2
+ import { fireEvent } from '@testing-library/react-native';
3
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
+ import { theme } from '../../../index';
4
5
  import FAB from '..';
5
6
 
6
7
  describe('FAB', () => {
7
8
  describe('when animated is true', () => {
8
9
  it('renders animatedFABIcon', () => {
9
- const { queryAllByTestId, toJSON } = render(
10
- <ThemeProvider theme={theme}>
11
- <FAB
12
- icon="add"
13
- animated
14
- style={{ backgroundColor: theme.colors.backgroundDark }}
15
- />
16
- </ThemeProvider>
10
+ const { queryAllByTestId, toJSON } = renderWithTheme(
11
+ <FAB
12
+ icon="add"
13
+ animated
14
+ style={{ backgroundColor: theme.colors.backgroundDark }}
15
+ />
17
16
  );
18
17
 
19
18
  expect(toJSON()).toMatchSnapshot();
@@ -23,13 +22,11 @@ describe('FAB', () => {
23
22
 
24
23
  describe('when animated is false', () => {
25
24
  it('renders StyledFABIcon', () => {
26
- const { queryAllByTestId, toJSON } = render(
27
- <ThemeProvider theme={theme}>
28
- <FAB
29
- icon="add"
30
- style={{ backgroundColor: theme.colors.backgroundDark }}
31
- />
32
- </ThemeProvider>
25
+ const { queryAllByTestId, toJSON } = renderWithTheme(
26
+ <FAB
27
+ icon="add"
28
+ style={{ backgroundColor: theme.colors.backgroundDark }}
29
+ />
33
30
  );
34
31
 
35
32
  expect(toJSON()).toMatchSnapshot();
@@ -40,15 +37,13 @@ describe('FAB', () => {
40
37
  describe('when onPress', () => {
41
38
  it('triggers onPress', () => {
42
39
  const onPressSpy = jest.fn();
43
- const { getByTestId } = render(
44
- <ThemeProvider theme={theme}>
45
- <FAB
46
- onPress={onPressSpy}
47
- icon="add"
48
- style={{ backgroundColor: theme.colors.backgroundDark }}
49
- testID="fab"
50
- />
51
- </ThemeProvider>
40
+ const { getByTestId } = renderWithTheme(
41
+ <FAB
42
+ onPress={onPressSpy}
43
+ icon="add"
44
+ style={{ backgroundColor: theme.colors.backgroundDark }}
45
+ testID="fab"
46
+ />
52
47
  );
53
48
 
54
49
  fireEvent(getByTestId('fab'), 'press');
@@ -1,5 +1,5 @@
1
1
  import { createIconSetFromIcoMoon } from 'react-native-vector-icons';
2
- import styled, { css } from 'styled-components-native';
2
+ import styled from '@emotion/native';
3
3
  import heroIconConfig from './selection.json';
4
4
 
5
5
  type ThemeSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
@@ -20,11 +20,9 @@ const HeroIcon = createIconSetFromIcoMoon(
20
20
  const StyledHeroIcon = styled(HeroIcon)<{
21
21
  themeSize: ThemeSize;
22
22
  themeIntent: ThemeIntent;
23
- }>`
24
- ${({ themeIntent, themeSize }) => css`
25
- color: ${({ theme }) => theme.__hd__.icon.colors[themeIntent]};
26
- font-size: ${({ theme }) => theme.__hd__.icon.sizes[themeSize]}px;
27
- `};
28
- `;
23
+ }>(({ themeIntent, themeSize, theme }) => ({
24
+ color: theme.__hd__.icon.colors[themeIntent],
25
+ fontSize: theme.__hd__.icon.sizes[themeSize],
26
+ }));
29
27
 
30
28
  export default StyledHeroIcon;
@@ -4,10 +4,13 @@ exports[`Icon renders correctly 1`] = `
4
4
  <HeroIcon
5
5
  name="home"
6
6
  style={
7
- Object {
8
- "color": "#292a2b",
9
- "fontSize": 24,
10
- }
7
+ Array [
8
+ Object {
9
+ "color": "#292a2b",
10
+ "fontSize": 24,
11
+ },
12
+ undefined,
13
+ ]
11
14
  }
12
15
  themeIntent="text"
13
16
  themeSize="medium"
@@ -18,10 +21,13 @@ exports[`Icon renders correctly with color and size 1`] = `
18
21
  <HeroIcon
19
22
  name="home"
20
23
  style={
21
- Object {
22
- "color": "#de350b",
23
- "fontSize": 28,
24
- }
24
+ Array [
25
+ Object {
26
+ "color": "#de350b",
27
+ "fontSize": 28,
28
+ },
29
+ undefined,
30
+ ]
25
31
  }
26
32
  themeIntent="danger"
27
33
  themeSize="large"
@@ -32,10 +38,13 @@ exports[`Icon renders correctly with intent 1`] = `
32
38
  <HeroIcon
33
39
  name="home"
34
40
  style={
35
- Object {
36
- "color": "#7622d7",
37
- "fontSize": 24,
38
- }
41
+ Array [
42
+ Object {
43
+ "color": "#7622d7",
44
+ "fontSize": 24,
45
+ },
46
+ undefined,
47
+ ]
39
48
  }
40
49
  themeIntent="primary"
41
50
  themeSize="medium"
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
3
+ import Icon from '..';
4
+
5
+ describe('Icon', () => {
6
+ it('renders correctly', () => {
7
+ const { toJSON } = renderWithTheme(<Icon icon="home" />);
8
+
9
+ expect(toJSON()).toMatchSnapshot();
10
+ });
11
+
12
+ it('renders correctly with intent', () => {
13
+ const { toJSON } = renderWithTheme(<Icon icon="home" intent="primary" />);
14
+
15
+ expect(toJSON()).toMatchSnapshot();
16
+ });
17
+
18
+ it('renders correctly with color and size', () => {
19
+ const { toJSON } = renderWithTheme(
20
+ <Icon icon="home" intent="danger" size="large" />
21
+ );
22
+
23
+ expect(toJSON()).toMatchSnapshot();
24
+ });
25
+ });
@@ -3,7 +3,7 @@ import { StyleProp, TextStyle } from 'react-native';
3
3
  import IconList from './IconList';
4
4
  import HeroIcon from './HeroIcon';
5
5
 
6
- type IconName = typeof IconList[number];
6
+ export type IconName = typeof IconList[number];
7
7
 
8
8
  export interface IconProps {
9
9
  /**
@@ -0,0 +1,70 @@
1
+ import { View, FlatList } from 'react-native';
2
+ import styled from '@emotion/native';
3
+ import Icon from '../Icon';
4
+ import Typography from '../Typography';
5
+
6
+ const TabScreen = styled(View)<{ themeVisibility?: boolean }>(
7
+ ({ themeVisibility }) => ({
8
+ flex: 1,
9
+ display: themeVisibility === false ? 'none' : 'flex',
10
+ })
11
+ );
12
+
13
+ const TabContainer = styled(View)({
14
+ flex: 1,
15
+ overflow: 'hidden',
16
+ });
17
+
18
+ const ContentWrapper = styled(View)({
19
+ flex: 1,
20
+ });
21
+
22
+ const HeaderTabWrapper = styled(View)<{
23
+ themeInsets: { top: number; right: number; bottom: number; left: number };
24
+ }>(({ themeInsets, theme }) => ({
25
+ paddingLeft: Math.max(themeInsets.left, themeInsets.right),
26
+ paddingRight: Math.max(themeInsets.left, themeInsets.right),
27
+ backgroundColor: theme.__hd__.tabs.colors.background,
28
+ }));
29
+
30
+ const StyledFlatList = (styled(FlatList)(({ theme }) => ({
31
+ paddingLeft: theme.__hd__.tabs.space.flatListHorizontalPadding,
32
+ paddingRight: theme.__hd__.tabs.space.flatListHorizontalPadding,
33
+ })) as unknown) as new <T>() => FlatList<T>;
34
+
35
+ const HeaderTabItem = styled(View)(({ theme }) => ({
36
+ flexDirection: 'row',
37
+ alignItems: 'center',
38
+ paddingLeft: theme.__hd__.tabs.space.itemHorizontalPadding,
39
+ paddingRight: theme.__hd__.tabs.space.itemHorizontalPadding,
40
+ paddingTop: theme.__hd__.tabs.space.itemVerticalPadding,
41
+ paddingBottom: theme.__hd__.tabs.space.itemVerticalPadding,
42
+ }));
43
+
44
+ const StyledHeaderTabIcon = styled(Icon)<{ themeActive: boolean }>(
45
+ ({ themeActive, theme }) => ({
46
+ color: themeActive
47
+ ? theme.__hd__.tabs.colors.active
48
+ : theme.__hd__.tabs.colors.inactive,
49
+ })
50
+ );
51
+
52
+ const StyledHeaderTabText = styled(Typography.Text)<{ themeActive: boolean }>(
53
+ ({ themeActive, theme }) => ({
54
+ marginLeft: theme.__hd__.tabs.space.titleMarginLeft,
55
+ color: themeActive
56
+ ? theme.__hd__.tabs.colors.active
57
+ : theme.__hd__.tabs.colors.inactive,
58
+ })
59
+ );
60
+
61
+ export {
62
+ StyledFlatList,
63
+ HeaderTabItem,
64
+ TabScreen,
65
+ TabContainer,
66
+ HeaderTabWrapper,
67
+ ContentWrapper,
68
+ StyledHeaderTabIcon,
69
+ StyledHeaderTabText,
70
+ };