@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,3 +1,9 @@
1
- const borderWidths = { base: 1 };
1
+ interface BorderWidths {
2
+ base: number;
3
+ }
2
4
 
3
- export { borderWidths };
5
+ const getBorderWidths = (baseBorderWidth: number): BorderWidths => ({
6
+ base: baseBorderWidth,
7
+ });
8
+
9
+ export { BorderWidths, getBorderWidths };
@@ -25,4 +25,6 @@ const systemPalette = {
25
25
  outline: palette.greyLight60,
26
26
  };
27
27
 
28
- export { palette, systemPalette };
28
+ type SystemPalette = typeof systemPalette;
29
+
30
+ export { systemPalette, SystemPalette };
@@ -1,21 +1,35 @@
1
- import { systemPalette } from './colors';
2
- import { space } from './space';
3
- import { fonts, fontSizes, lineHeights } from './typography';
4
- import { borderWidths } from './borders';
1
+ import { scale as defaultScale, Scale } from './scale';
2
+ import { systemPalette as defaultSystemPalette, SystemPalette } from './colors';
3
+ import { getFonts, getFontSizes, getLineHeights } from './typography';
4
+ import { getSpace } from './space';
5
+ import { getBorderWidths } from './borders';
5
6
 
6
- const globalTheme = {
7
- colors: {
8
- ...systemPalette,
9
- },
10
- space,
11
- fonts,
12
- fontSizes,
13
- lineHeights,
14
- borderWidths,
15
- };
7
+ const getGlobalTheme = (scale: Scale, systemPalette: SystemPalette) => {
8
+ const fonts = getFonts(scale.font);
9
+ const fontSizes = getFontSizes(scale.fontSize);
10
+ const lineHeights = getLineHeights(fontSizes);
11
+ const borderWidths = getBorderWidths(scale.borderWidth);
12
+ const space = getSpace(scale.space);
16
13
 
17
- type GlobalTheme = typeof globalTheme;
14
+ return {
15
+ colors: {
16
+ ...systemPalette,
17
+ },
18
+ fonts,
19
+ fontSizes,
20
+ lineHeights,
21
+ borderWidths,
22
+ space,
23
+ };
24
+ };
18
25
 
19
- export { GlobalTheme };
26
+ type GlobalTheme = ReturnType<typeof getGlobalTheme>;
20
27
 
21
- export default globalTheme;
28
+ export {
29
+ GlobalTheme,
30
+ Scale,
31
+ SystemPalette,
32
+ getGlobalTheme,
33
+ defaultScale,
34
+ defaultSystemPalette,
35
+ };
@@ -0,0 +1,18 @@
1
+ const BASE_BORDER_WIDTH = 1;
2
+
3
+ const BASE_SPACE = 8;
4
+
5
+ const BASE_FONT = 'BeVietnamPro';
6
+
7
+ const BASE_FONT_SIZE = 10;
8
+
9
+ const scale = {
10
+ borderWidth: BASE_BORDER_WIDTH,
11
+ space: BASE_SPACE,
12
+ font: BASE_FONT,
13
+ fontSize: BASE_FONT_SIZE,
14
+ };
15
+
16
+ type Scale = typeof scale;
17
+
18
+ export { scale, Scale };
@@ -1,17 +1,27 @@
1
1
  import { scale } from '../../utils/scale';
2
2
 
3
- const BASE = 8;
3
+ interface Space {
4
+ large: number;
5
+ medium: number;
6
+ small: number;
7
+ xlarge: number;
8
+ xsmall: number;
9
+ xxlarge: number;
10
+ xxsmall: number;
11
+ xxxlarge: number;
12
+ xxxxlarge: number;
13
+ }
4
14
 
5
- const space = {
6
- xxsmall: scale(BASE * 0.25),
7
- xsmall: scale(BASE * 0.5),
8
- small: scale(BASE),
9
- medium: scale(BASE * 2),
10
- large: scale(BASE * 3),
11
- xlarge: scale(BASE * 4),
12
- xxlarge: scale(BASE * 5),
13
- xxxlarge: scale(BASE * 6),
14
- xxxxlarge: scale(BASE * 7),
15
- };
15
+ const getSpace = (baseSpace: number): Space => ({
16
+ xxsmall: scale(baseSpace * 0.25),
17
+ xsmall: scale(baseSpace * 0.5),
18
+ small: scale(baseSpace),
19
+ medium: scale(baseSpace * 2),
20
+ large: scale(baseSpace * 3),
21
+ xlarge: scale(baseSpace * 4),
22
+ xxlarge: scale(baseSpace * 5),
23
+ xxxlarge: scale(baseSpace * 6),
24
+ xxxxlarge: scale(baseSpace * 7),
25
+ });
16
26
 
17
- export { space };
27
+ export { Space, getSpace };
@@ -1,35 +1,79 @@
1
1
  import { scale } from '../../utils/scale';
2
2
 
3
- const BASE = 16;
3
+ interface Fonts {
4
+ light: string;
5
+ regular: string;
6
+ semiBold: string;
7
+ }
4
8
 
5
- const fonts = {
6
- light: 'Be Vietnam Pro Light',
7
- regular: 'Be Vietnam Pro Regular',
8
- semiBold: 'Be Vietnam Pro SemiBold',
9
- };
9
+ interface FontSizes {
10
+ xxxxxlarge: number;
11
+ xxxxlarge: number;
12
+ xxxlarge: number;
13
+ xxlarge: number;
14
+ xlarge: number;
15
+ large: number;
16
+ medium: number;
17
+ small: number;
18
+ xsmall: number;
19
+ }
20
+
21
+ type LineHeights = FontSizes;
22
+
23
+ // Hero design web typo scale is following
24
+ // https://www.ibm.com/design/language/typography/type-specs-ui#scales
25
+ const genFontSize = (prev: number, at: number): number =>
26
+ prev + Math.floor(Math.abs((at - 2) / 4) + 1) * 2;
10
27
 
11
- const fontSizes = {
12
- xxxxxlarge: scale(BASE * 2), // 32
13
- xxxxlarge: scale(BASE * 1.75), // 28
14
- xxxlarge: scale(BASE * 1.5), // 24
15
- xxlarge: scale(BASE * 1.25), // 20
16
- xlarge: scale(BASE * 1.125), // 18
17
- large: scale(BASE), // 16
18
- medium: scale(BASE * 0.875), // 14
19
- small: scale(BASE * 0.75), // 12
20
- xsmall: scale(BASE * 0.625), // 10
28
+ const getFonts = (baseFont: string): Fonts => ({
29
+ light: `${baseFont}-Light`,
30
+ regular: `${baseFont}-Regular`,
31
+ semiBold: `${baseFont}-SemiBold`,
32
+ });
33
+
34
+ const getFontSizes = (baseFontSize: number): FontSizes => {
35
+ const fontSizes = Array.from(new Array(9));
36
+ fontSizes.forEach((_, index) => {
37
+ if (index === 0) {
38
+ fontSizes[0] = baseFontSize;
39
+ } else {
40
+ fontSizes[index] = genFontSize(fontSizes[index - 1], index);
41
+ }
42
+ return undefined;
43
+ });
44
+ return {
45
+ xxxxxlarge: scale(fontSizes[8]), // 32
46
+ xxxxlarge: scale(fontSizes[7]), // 28
47
+ xxxlarge: scale(fontSizes[6]), // 24
48
+ xxlarge: scale(fontSizes[5]), // 20
49
+ xlarge: scale(fontSizes[4]), // 18
50
+ large: scale(fontSizes[3]), // 16
51
+ medium: scale(fontSizes[2]), // 14
52
+ small: scale(fontSizes[1]), // 12
53
+ xsmall: scale(fontSizes[0]), // 10
54
+ };
21
55
  };
22
56
 
23
- const lineHeights = {
24
- xxxxxlarge: fontSizes.xxxxxlarge + 8,
25
- xxxxlarge: fontSizes.xxxxlarge + 8,
26
- xxxlarge: fontSizes.xxxlarge + 8,
27
- xxlarge: fontSizes.xxlarge + 8,
28
- xlarge: fontSizes.xlarge + 8,
29
- large: fontSizes.large + 8,
30
- medium: fontSizes.medium + 8,
31
- small: fontSizes.small + 8,
32
- xsmall: fontSizes.xsmall + 8,
57
+ const getLineHeights = (fontSizes: FontSizes): LineHeights => {
58
+ const additionalSpace = 8;
59
+ return {
60
+ xxxxxlarge: fontSizes.xxxxxlarge + additionalSpace,
61
+ xxxxlarge: fontSizes.xxxxlarge + additionalSpace,
62
+ xxxlarge: fontSizes.xxxlarge + additionalSpace,
63
+ xxlarge: fontSizes.xxlarge + additionalSpace,
64
+ xlarge: fontSizes.xlarge + additionalSpace,
65
+ large: fontSizes.large + additionalSpace,
66
+ medium: fontSizes.medium + additionalSpace,
67
+ small: fontSizes.small + additionalSpace,
68
+ xsmall: fontSizes.xsmall + additionalSpace,
69
+ };
33
70
  };
34
71
 
35
- export { fonts, fontSizes, lineHeights };
72
+ export {
73
+ Fonts,
74
+ FontSizes,
75
+ LineHeights,
76
+ getFonts,
77
+ getFontSizes,
78
+ getLineHeights,
79
+ };
@@ -1,9 +1,17 @@
1
- import globalTheme, { GlobalTheme } from './global';
1
+ import {
2
+ GlobalTheme,
3
+ Scale,
4
+ SystemPalette,
5
+ getGlobalTheme,
6
+ defaultScale,
7
+ defaultSystemPalette,
8
+ } from './global';
2
9
 
3
10
  import getBadgeTheme from './components/badge';
4
11
  import getBottomNavigationTheme from './components/bottomNavigation';
5
12
  import getCardTheme from './components/card';
6
13
  import getDividerTheme from './components/divider';
14
+ import getTabsTheme from './components/tabs';
7
15
  import getIconTheme from './components/icon';
8
16
  import getTypographyTheme from './components/typography';
9
17
  import getFABTheme from './components/fab';
@@ -15,23 +23,31 @@ type Theme = GlobalTheme & {
15
23
  card: ReturnType<typeof getCardTheme>;
16
24
  divider: ReturnType<typeof getDividerTheme>;
17
25
  icon: ReturnType<typeof getIconTheme>;
26
+ tabs: ReturnType<typeof getTabsTheme>;
18
27
  typography: ReturnType<typeof getTypographyTheme>;
19
28
  fab: ReturnType<typeof getFABTheme>;
20
29
  };
21
30
  };
22
31
 
23
- const getTheme = (theme: GlobalTheme = globalTheme): Theme => ({
24
- ...theme,
25
- __hd__: {
26
- badge: getBadgeTheme(theme),
27
- bottomNavigation: getBottomNavigationTheme(theme),
28
- card: getCardTheme(theme),
29
- divider: getDividerTheme(theme),
30
- icon: getIconTheme(theme),
31
- typography: getTypographyTheme(theme),
32
- fab: getFABTheme(theme),
33
- },
34
- });
32
+ const getTheme = (
33
+ scale: Scale = defaultScale,
34
+ systemPallete: SystemPalette = defaultSystemPalette
35
+ ): Theme => {
36
+ const globalTheme = getGlobalTheme(scale, systemPallete);
37
+ return {
38
+ ...globalTheme,
39
+ __hd__: {
40
+ badge: getBadgeTheme(globalTheme),
41
+ bottomNavigation: getBottomNavigationTheme(globalTheme),
42
+ card: getCardTheme(globalTheme),
43
+ divider: getDividerTheme(globalTheme),
44
+ icon: getIconTheme(globalTheme),
45
+ tabs: getTabsTheme(globalTheme),
46
+ typography: getTypographyTheme(globalTheme),
47
+ fab: getFABTheme(globalTheme),
48
+ },
49
+ };
50
+ };
35
51
 
36
52
  const theme = getTheme();
37
53
 
package/src/types.ts ADDED
@@ -0,0 +1,7 @@
1
+ import { BottomNavigationTabType } from './components/BottomNavigation';
2
+ import { IconName } from './components/Icon';
3
+ import { TabType } from './components/Tabs';
4
+
5
+ import { Theme } from './theme';
6
+
7
+ export type { BottomNavigationTabType, IconName, TabType, Theme };
@@ -1,5 +1,5 @@
1
1
  import { Dimensions } from 'react-native';
2
- import { scale, BASE_WIDTH } from '../scale';
2
+ import { scale } from '../scale';
3
3
 
4
4
  jest.unmock('../scale'); // Unmock global mocking of scale for other tests
5
5
 
@@ -11,7 +11,7 @@ describe('scale', () => {
11
11
 
12
12
  const size = 10;
13
13
 
14
- expect(scale(size)).toBe((400 / BASE_WIDTH) * size);
14
+ expect(scale(size)).toBe(10.128205128205128);
15
15
  });
16
16
 
17
17
  it('returns scale based on height when width > height', () => {
@@ -21,6 +21,6 @@ describe('scale', () => {
21
21
 
22
22
  const size = 10;
23
23
 
24
- expect(scale(size)).toBe((350 / BASE_WIDTH) * size);
24
+ expect(scale(size)).toBe(9.487179487179487);
25
25
  });
26
26
  });
@@ -2,6 +2,17 @@ jest.mock('react-native-vector-icons', () => ({
2
2
  createIconSetFromIcoMoon: jest.fn(() => 'HeroIcon'),
3
3
  }));
4
4
 
5
+ jest.mock('react-native', () => {
6
+ const RN = jest.requireActual('react-native');
7
+
8
+ RN.Animated.timing = () => ({
9
+ start: () => jest.fn(),
10
+ stop: () => jest.fn(),
11
+ });
12
+
13
+ return RN;
14
+ });
15
+
5
16
  jest.mock('../src/utils/scale', () => ({
6
17
  scale: jest.fn(size => size),
7
18
  }));
package/tsconfig.json CHANGED
@@ -12,11 +12,7 @@
12
12
  "noImplicitThis": true,
13
13
  "noUnusedLocals": true,
14
14
  "skipLibCheck": true,
15
- "types": ["jest", "styled-components", "styled-components-react-native"],
16
- "baseUrl": ".",
17
- "paths": {
18
- "styled-components-native": ["./src/styled-components.ts"]
19
- }
15
+ "types": ["jest"],
20
16
  },
21
17
  "include": ["src", "playground"],
22
18
  "exclude": ["node_modules"],
@@ -1,2 +1,2 @@
1
- declare const MyComponent: () => JSX.Element;
2
- export default MyComponent;
1
+ declare const BottomNavigationPlayground: () => JSX.Element;
2
+ export default BottomNavigationPlayground;
@@ -0,0 +1,2 @@
1
+ declare const ButtonPlayground: () => JSX.Element;
2
+ export default ButtonPlayground;
@@ -0,0 +1,2 @@
1
+ declare const TabsPlayground: () => JSX.Element;
2
+ export default TabsPlayground;
@@ -1,9 +1,20 @@
1
- import { Text, View } from 'react-native';
1
+ /// <reference types="react" />
2
+ import { View, Text } from 'react-native';
2
3
  declare type ThemeIntent = 'success' | 'warning' | 'danger' | 'info';
3
- declare const StyledView: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
4
+ declare const StyledView: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
5
+ theme?: import("@emotion/react").Theme | undefined;
6
+ as?: import("react").ElementType<any> | undefined;
7
+ } & {
4
8
  themeIntent: ThemeIntent;
5
- }, never>;
6
- declare const StyledText: import("styled-components").StyledComponent<typeof Text, import("../../theme").Theme, {
9
+ }, {}, {
10
+ ref?: import("react").Ref<View> | undefined;
11
+ }>;
12
+ declare const StyledText: import("@emotion/native").StyledComponent<import("react-native").TextProps & {
13
+ theme?: import("@emotion/react").Theme | undefined;
14
+ as?: import("react").ElementType<any> | undefined;
15
+ } & {
7
16
  themeIntent: ThemeIntent;
8
- }, never>;
17
+ }, {}, {
18
+ ref?: import("react").Ref<Text> | undefined;
19
+ }>;
9
20
  export { StyledView, StyledText };
@@ -10,7 +10,7 @@ interface BadgeProps extends ViewProps {
10
10
  */
11
11
  intent?: 'success' | 'warning' | 'danger' | 'info';
12
12
  /**
13
- * Addditional style.
13
+ * Additional style.
14
14
  */
15
15
  style?: StyleProp<ViewStyle>;
16
16
  /**
@@ -1,17 +1,52 @@
1
+ /// <reference types="react" />
1
2
  import { View } from 'react-native';
2
- declare const BottomNavigationTab: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
3
+ declare const BottomNavigationTab: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
4
+ theme?: import("@emotion/react").Theme | undefined;
5
+ as?: import("react").ElementType<any> | undefined;
6
+ } & {
3
7
  themeVisibility?: boolean | undefined;
4
- }, never>;
5
- declare const BottomNavigationContainer: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {}, never>;
6
- declare const ContentWrapper: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {}, never>;
7
- declare const BottomBarWrapper: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
8
+ }, {}, {
9
+ ref?: import("react").Ref<View> | undefined;
10
+ }>;
11
+ declare const BottomNavigationContainer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
12
+ theme?: import("@emotion/react").Theme | undefined;
13
+ as?: import("react").ElementType<any> | undefined;
14
+ }, {}, {
15
+ ref?: import("react").Ref<View> | undefined;
16
+ }>;
17
+ declare const ContentWrapper: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
18
+ theme?: import("@emotion/react").Theme | undefined;
19
+ as?: import("react").ElementType<any> | undefined;
20
+ }, {}, {
21
+ ref?: import("react").Ref<View> | undefined;
22
+ }>;
23
+ declare const BottomBarWrapper: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
24
+ theme?: import("@emotion/react").Theme | undefined;
25
+ as?: import("react").ElementType<any> | undefined;
26
+ } & {
8
27
  themeInsets: {
9
28
  top: number;
10
29
  right: number;
11
30
  bottom: number;
12
31
  left: number;
13
32
  };
14
- }, never>;
15
- declare const BottomBar: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {}, never>;
16
- declare const BottomBarItem: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {}, never>;
17
- export { BottomBar, BottomBarItem, BottomNavigationTab, BottomNavigationContainer, BottomBarWrapper, ContentWrapper, };
33
+ }, {}, {
34
+ ref?: import("react").Ref<View> | undefined;
35
+ }>;
36
+ declare const BottomBar: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
37
+ theme?: import("@emotion/react").Theme | undefined;
38
+ as?: import("react").ElementType<any> | undefined;
39
+ }, {}, {
40
+ ref?: import("react").Ref<View> | undefined;
41
+ }>;
42
+ declare const BottomBarItem: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
43
+ theme?: import("@emotion/react").Theme | undefined;
44
+ as?: import("react").ElementType<any> | undefined;
45
+ }, {}, {
46
+ ref?: import("react").Ref<View> | undefined;
47
+ }>;
48
+ declare const StyledBottomBarText: import("@emotion/native").StyledComponent<import("../Typography/Text").TextProps & {
49
+ theme?: import("@emotion/react").Theme | undefined;
50
+ as?: import("react").ElementType<any> | undefined;
51
+ }, {}, {}>;
52
+ export { BottomBar, BottomBarItem, BottomNavigationTab, BottomNavigationContainer, BottomBarWrapper, ContentWrapper, StyledBottomBarText, };
@@ -1,19 +1,18 @@
1
- import { ComponentProps, ReactNode } from 'react';
1
+ import { ReactNode } from 'react';
2
2
  import { StyleProp, ViewStyle, ViewProps } from 'react-native';
3
- import Icon from '../Icon';
4
- declare type IconType = ComponentProps<typeof Icon>['icon'];
5
- export declare type Tab<V> = {
6
- key: V;
3
+ import { IconName } from '../Icon';
4
+ export declare type BottomNavigationTabType = {
5
+ key: string;
7
6
  title?: string;
8
- icon: IconType;
7
+ icon: IconName;
9
8
  component: ReactNode;
10
9
  testID?: string;
11
10
  };
12
- interface BottomNavigationType<V extends string | number, T extends Tab<V>> extends ViewProps {
11
+ interface BottomNavigationProps extends ViewProps {
13
12
  /**
14
- * Callback which is called on tab change, receiving id of upcoming active Tab.
13
+ * Callback which is called on tab press, receiving key of upcoming active Tab.
15
14
  */
16
- onChange: (key: V) => void;
15
+ onTabPress: (key: string) => void;
17
16
  /**
18
17
  * Whether inactive tabs should be removed and unmounted in React.
19
18
  * Defaults to `false`.
@@ -22,13 +21,19 @@ interface BottomNavigationType<V extends string | number, T extends Tab<V>> exte
22
21
  /**
23
22
  * Current selected tab key.
24
23
  */
25
- selectedTabKey: V;
24
+ selectedTabKey: string;
26
25
  /**
27
- * List of Tab to be rendered. Each Tab must have an unique id.
26
+ * List of Tabs to be rendered. Each Tab must have an unique key.
28
27
  */
29
- tabs: T[];
28
+ tabs: {
29
+ key: string;
30
+ title?: string;
31
+ icon: IconName;
32
+ component: ReactNode;
33
+ testID?: string;
34
+ }[];
30
35
  /**
31
- * Addditional style.
36
+ * Additional style.
32
37
  */
33
38
  style?: StyleProp<ViewStyle>;
34
39
  /**
@@ -36,5 +41,5 @@ interface BottomNavigationType<V extends string | number, T extends Tab<V>> exte
36
41
  */
37
42
  testID?: string;
38
43
  }
39
- declare const BottomNavigation: <V extends string | number, T extends Tab<V>>({ onChange, renderActiveTabOnly, selectedTabKey, tabs, ...nativeProps }: BottomNavigationType<V, T>) => JSX.Element;
44
+ declare const BottomNavigation: ({ onTabPress, renderActiveTabOnly, selectedTabKey, tabs, ...nativeProps }: BottomNavigationProps) => JSX.Element;
40
45
  export default BottomNavigation;
@@ -0,0 +1,34 @@
1
+ import { StyleProp, ViewStyle, TouchableOpacityProps } from 'react-native';
2
+ import { IconProps, IconName } from '../Icon';
3
+ export interface IconButtonProps {
4
+ /**
5
+ * Set how far you can touch from the button.
6
+ */
7
+ hitSlop?: TouchableOpacityProps['hitSlop'];
8
+ /**
9
+ * Name of the Icon.
10
+ */
11
+ icon: IconName;
12
+ /**
13
+ * Intent of the Icon.
14
+ */
15
+ intent?: IconProps['intent'];
16
+ /**
17
+ * Set the handler to handle press event.
18
+ */
19
+ onPress: () => void;
20
+ /**
21
+ * Size of the Icon.
22
+ */
23
+ size?: IconProps['size'];
24
+ /**
25
+ * Additional style.
26
+ */
27
+ style?: StyleProp<ViewStyle>;
28
+ /**
29
+ * Testing id of component.
30
+ */
31
+ testID?: string;
32
+ }
33
+ declare const IconButton: ({ hitSlop, onPress, icon, testID, style, size, intent, }: IconButtonProps) => JSX.Element;
34
+ export default IconButton;
@@ -0,0 +1,4 @@
1
+ declare const Button: {
2
+ readonly Icon: ({ hitSlop, onPress, icon, testID, style, size, intent, }: import("./IconButton").IconButtonProps) => JSX.Element;
3
+ };
4
+ export default Button;
@@ -1,3 +1,9 @@
1
+ /// <reference types="react" />
1
2
  import { View } from 'react-native';
2
- declare const StyledCard: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {}, never>;
3
+ declare const StyledCard: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
4
+ theme?: import("@emotion/react").Theme | undefined;
5
+ as?: import("react").ElementType<any> | undefined;
6
+ }, {}, {
7
+ ref?: import("react").Ref<View> | undefined;
8
+ }>;
3
9
  export { StyledCard };
@@ -1,7 +1,13 @@
1
+ /// <reference types="react" />
1
2
  import { View } from 'react-native';
2
3
  declare type MarginSize = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
3
- declare const StyledDivider: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
4
+ declare const StyledDivider: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
5
+ theme?: import("@emotion/react").Theme | undefined;
6
+ as?: import("react").ElementType<any> | undefined;
7
+ } & {
4
8
  themeMarginHorizontal?: MarginSize | undefined;
5
9
  themeMarginVertical?: MarginSize | undefined;
6
- }, never>;
10
+ }, {}, {
11
+ ref?: import("react").Ref<View> | undefined;
12
+ }>;
7
13
  export { StyledDivider };
@@ -9,7 +9,7 @@ interface DividerProps extends ViewProps {
9
9
  */
10
10
  marginVertical?: 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
11
11
  /**
12
- * Addditional style.
12
+ * Additional style.
13
13
  */
14
14
  style?: StyleProp<ViewStyle>;
15
15
  /**