@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.
- package/.eslintrc.json +0 -6
- package/.expo/packager-info.json +1 -1
- package/babel.config.js +0 -14
- package/es/index.js +2787 -8941
- package/jest-setup.ts +0 -1
- package/jest.config.js +2 -4
- package/lib/index.js +2822 -8956
- package/package.json +5 -7
- package/playground/components/BottomNavigation.tsx +14 -11
- package/playground/components/Button.tsx +67 -0
- package/playground/components/Card.tsx +141 -107
- package/playground/components/Tabs.tsx +44 -0
- package/playground/index.tsx +13 -7
- package/src/components/Badge/StyledBadge.tsx +19 -21
- package/src/components/Badge/__tests__/Badge.spec.tsx +9 -18
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +76 -96
- package/src/components/Badge/index.tsx +1 -1
- package/src/components/BottomNavigation/StyledBottomNavigation.tsx +44 -42
- package/src/components/BottomNavigation/__tests__/__snapshots__/{BottomNavigation.spec.tsx.snap → index.spec.tsx.snap} +130 -96
- package/src/components/BottomNavigation/__tests__/{BottomNavigation.spec.tsx → index.spec.tsx} +4 -4
- package/src/components/BottomNavigation/index.tsx +28 -32
- package/src/components/Button/IconButton.tsx +62 -0
- package/src/components/Button/__tests__/__snapshots__/index.spec.tsx.snap +46 -0
- package/src/components/Button/__tests__/index.spec.tsx +23 -0
- package/src/components/Button/index.tsx +5 -0
- package/src/components/Card/StyledCard.tsx +6 -6
- package/src/components/Card/__tests__/StyledCard.spec.tsx +2 -7
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +8 -11
- package/src/components/Card/__tests__/__snapshots__/{Card.spec.tsx.snap → index.spec.tsx.snap} +2 -8
- package/src/components/Card/__tests__/index.spec.tsx +35 -0
- package/src/components/Divider/StyledDivider.tsx +18 -60
- package/src/components/Divider/__tests__/StyledDivider.spec.tsx +5 -10
- package/src/components/Divider/__tests__/__snapshots__/StyledDivider.spec.tsx.snap +106 -70
- package/src/components/Divider/index.tsx +1 -1
- package/src/components/FAB/ActionGroup/ActionItem.tsx +2 -4
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +36 -37
- package/src/components/FAB/ActionGroup/StyledActionItem.tsx +26 -24
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +271 -245
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +29 -33
- package/src/components/FAB/ActionGroup/index.tsx +1 -5
- package/src/components/FAB/AnimatedFABIcon.tsx +1 -1
- package/src/components/FAB/FAB.tsx +5 -9
- package/src/components/FAB/StyledFAB.tsx +22 -0
- package/src/components/FAB/__tests__/AnimatedFABIcon.spec.tsx +3 -6
- package/src/components/FAB/__tests__/StyledFAB.spec.tsx +24 -0
- package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +14 -10
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +72 -0
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +16 -17
- package/src/components/FAB/__tests__/index.spec.tsx +21 -26
- package/src/components/Icon/HeroIcon/index.tsx +5 -7
- package/src/components/Icon/__tests__/__snapshots__/{Icon.spec.tsx.snap → index.spec.tsx.snap} +21 -12
- package/src/components/Icon/__tests__/index.spec.tsx +25 -0
- package/src/components/Icon/index.tsx +1 -1
- package/src/components/Tabs/StyledTabs.tsx +70 -0
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +321 -0
- package/src/components/Tabs/__tests__/index.spec.tsx +79 -0
- package/src/components/Tabs/index.tsx +185 -0
- package/src/components/Typography/Text/StyledText.tsx +19 -64
- package/src/components/Typography/Text/__tests__/__snapshots__/StyledText.spec.tsx.snap +90 -63
- package/src/emotion.d.ts +6 -0
- package/src/index.ts +9 -3
- package/src/testHelpers/renderWithTheme.tsx +2 -1
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +70 -48
- package/src/theme/components/badge.ts +10 -9
- package/src/theme/components/bottomNavigation.ts +7 -3
- package/src/theme/components/card.ts +2 -2
- package/src/theme/components/divider.ts +6 -6
- package/src/theme/components/fab.ts +19 -17
- package/src/theme/components/tabs.ts +20 -0
- package/src/theme/components/typography.ts +4 -4
- package/src/theme/global/borders.ts +8 -2
- package/src/theme/global/colors.ts +3 -1
- package/src/theme/global/index.ts +31 -17
- package/src/theme/global/scale.ts +18 -0
- package/src/theme/global/space.ts +23 -13
- package/src/theme/global/typography.ts +71 -27
- package/src/theme/index.ts +29 -13
- package/src/types.ts +7 -0
- package/src/utils/__tests__/scale.spec.ts +3 -3
- package/testUtils/setup.ts +11 -0
- package/tsconfig.json +1 -5
- package/types/playground/components/BottomNavigation.d.ts +2 -2
- package/types/playground/components/Button.d.ts +2 -0
- package/types/playground/components/Tabs.d.ts +2 -0
- package/types/src/components/Badge/StyledBadge.d.ts +16 -5
- package/types/src/components/Badge/index.d.ts +1 -1
- package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +44 -9
- package/types/src/components/{Typography/Text/__test__ → BottomNavigation/__tests__}/index.spec.d.ts +0 -0
- package/types/src/components/BottomNavigation/index.d.ts +19 -14
- package/types/src/components/Button/IconButton.d.ts +34 -0
- package/types/{theme → src/components/Button}/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/Button/index.d.ts +4 -0
- package/types/src/components/Card/StyledCard.d.ts +7 -1
- package/types/{components/Card/__tests__/Card.spec.d.ts → src/components/Card/__tests__/index.spec.d.ts} +0 -0
- package/types/src/components/Divider/StyledDivider.d.ts +8 -2
- package/types/src/components/Divider/index.d.ts +1 -1
- package/types/src/components/FAB/ActionGroup/StyledActionGroup.d.ts +25 -7
- package/types/src/components/FAB/ActionGroup/StyledActionItem.d.ts +11 -2
- package/types/src/components/FAB/ActionGroup/index.d.ts +1 -1
- package/types/src/components/FAB/FAB.d.ts +4 -4
- package/types/src/components/FAB/StyledFAB.d.ts +14 -0
- package/types/{components/Card/__tests__/StyledCard.spec.d.ts → src/components/FAB/__tests__/StyledFAB.spec.d.ts} +0 -0
- package/types/src/components/Icon/HeroIcon/index.d.ts +8 -2
- package/types/{components/Divider/__tests__/StyledDivider.spec.d.ts → src/components/Icon/__tests__/index.spec.d.ts} +0 -0
- package/types/src/components/Icon/index.d.ts +1 -1
- package/types/src/components/Icon/utils.d.ts +1 -1
- package/types/src/components/Tabs/StyledTabs.d.ts +55 -0
- package/types/{components/ExampleComponent/__tests__/StyledView.spec.d.ts → src/components/Tabs/__tests__/index.spec.d.ts} +0 -0
- package/types/src/components/Tabs/index.d.ts +45 -0
- package/types/src/components/Typography/Text/StyledText.d.ts +8 -2
- package/types/src/index.d.ts +6 -3
- package/types/src/theme/components/badge.d.ts +8 -7
- package/types/src/theme/components/bottomNavigation.d.ts +8 -2
- package/types/src/theme/components/card.d.ts +2 -2
- package/types/src/theme/components/divider.d.ts +6 -6
- package/types/src/theme/components/fab.d.ts +19 -17
- package/types/src/theme/components/tabs.d.ts +15 -0
- package/types/src/theme/components/typography.d.ts +4 -4
- package/types/src/theme/global/borders.d.ts +4 -3
- package/types/src/theme/global/colors.d.ts +2 -2
- package/types/src/theme/global/index.d.ts +10 -45
- package/types/src/theme/global/scale.d.ts +8 -0
- package/types/src/theme/global/space.d.ts +8 -7
- package/types/src/theme/global/typography.d.ts +9 -16
- package/types/src/theme/index.d.ts +4 -2
- package/types/src/types.d.ts +5 -0
- package/lib/assets/fonts/be-vietnam-pro-light.ttf +0 -0
- package/lib/assets/fonts/be-vietnam-pro-regular.ttf +0 -0
- package/lib/assets/fonts/be-vietnam-pro-semibold.ttf +0 -0
- package/src/components/Card/__tests__/Card.spec.tsx +0 -36
- package/src/components/FAB/StyledFABContainer.tsx +0 -14
- package/src/components/FAB/StyledFABIcon.tsx +0 -9
- package/src/components/FAB/__tests__/StyledFABContainer.spec.tsx +0 -18
- package/src/components/FAB/__tests__/StyledFABIcon.spec.tsx +0 -16
- package/src/components/FAB/__tests__/__snapshots__/StyledFABContainer.spec.tsx.snap +0 -46
- package/src/components/FAB/__tests__/__snapshots__/StyledFABIcon.spec.tsx.snap +0 -21
- package/src/components/Icon/__tests__/Icon.spec.tsx +0 -36
- package/src/styled-components.ts +0 -14
- package/src/styled.d.ts +0 -7
- package/types/components/Card/StyledCard.d.ts +0 -3
- package/types/components/Card/index.d.ts +0 -5
- package/types/components/Divider/StyledDivider.d.ts +0 -7
- package/types/components/Divider/index.d.ts +0 -12
- package/types/components/ExampleComponent/StyledView.d.ts +0 -7
- package/types/components/ExampleComponent/index.d.ts +0 -16
- package/types/index.d.ts +0 -5
- package/types/src/components/BottomNavigation/__tests__/BottomNavigation.spec.d.ts +0 -1
- package/types/src/components/Card/__tests__/Card.spec.d.ts +0 -1
- package/types/src/components/FAB/StyledFABContainer.d.ts +0 -3
- package/types/src/components/FAB/StyledFABIcon.d.ts +0 -3
- package/types/src/components/FAB/__tests__/StyledFABContainer.spec.d.ts +0 -1
- package/types/src/components/FAB/__tests__/StyledFABIcon.spec.d.ts +0 -1
- package/types/src/components/Icon/__tests__/Icon.spec.d.ts +0 -1
- package/types/src/components/Typography/Text/__test__/StyledText.spec.d.ts +0 -1
- package/types/src/styled-components.d.ts +0 -6
- package/types/styled-components.d.ts +0 -6
- package/types/theme/components/card.d.ts +0 -10
- package/types/theme/components/divider.d.ts +0 -17
- package/types/theme/components/exampleComponent.d.ts +0 -14
- package/types/theme/global/borders.d.ts +0 -4
- package/types/theme/global/colors.d.ts +0 -26
- package/types/theme/global/index.d.ts +0 -63
- package/types/theme/global/space.d.ts +0 -12
- package/types/theme/global/typography.d.ts +0 -21
- package/types/theme/index.d.ts +0 -13
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
14
|
+
return {
|
|
15
|
+
colors: {
|
|
16
|
+
...systemPalette,
|
|
17
|
+
},
|
|
18
|
+
fonts,
|
|
19
|
+
fontSizes,
|
|
20
|
+
lineHeights,
|
|
21
|
+
borderWidths,
|
|
22
|
+
space,
|
|
23
|
+
};
|
|
24
|
+
};
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
type GlobalTheme = ReturnType<typeof getGlobalTheme>;
|
|
20
27
|
|
|
21
|
-
export
|
|
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
|
-
|
|
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
|
|
6
|
-
xxsmall: scale(
|
|
7
|
-
xsmall: scale(
|
|
8
|
-
small: scale(
|
|
9
|
-
medium: scale(
|
|
10
|
-
large: scale(
|
|
11
|
-
xlarge: scale(
|
|
12
|
-
xxlarge: scale(
|
|
13
|
-
xxxlarge: scale(
|
|
14
|
-
xxxxlarge: scale(
|
|
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 {
|
|
27
|
+
export { Space, getSpace };
|
|
@@ -1,35 +1,79 @@
|
|
|
1
1
|
import { scale } from '../../utils/scale';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
interface Fonts {
|
|
4
|
+
light: string;
|
|
5
|
+
regular: string;
|
|
6
|
+
semiBold: string;
|
|
7
|
+
}
|
|
4
8
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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 {
|
|
72
|
+
export {
|
|
73
|
+
Fonts,
|
|
74
|
+
FontSizes,
|
|
75
|
+
LineHeights,
|
|
76
|
+
getFonts,
|
|
77
|
+
getFontSizes,
|
|
78
|
+
getLineHeights,
|
|
79
|
+
};
|
package/src/theme/index.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import
|
|
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 = (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
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
|
|
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(
|
|
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(
|
|
24
|
+
expect(scale(size)).toBe(9.487179487179487);
|
|
25
25
|
});
|
|
26
26
|
});
|
package/testUtils/setup.ts
CHANGED
|
@@ -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"
|
|
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
|
|
2
|
-
export default
|
|
1
|
+
declare const BottomNavigationPlayground: () => JSX.Element;
|
|
2
|
+
export default BottomNavigationPlayground;
|
|
@@ -1,9 +1,20 @@
|
|
|
1
|
-
|
|
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("
|
|
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
|
-
},
|
|
6
|
-
|
|
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
|
-
},
|
|
17
|
+
}, {}, {
|
|
18
|
+
ref?: import("react").Ref<Text> | undefined;
|
|
19
|
+
}>;
|
|
9
20
|
export { StyledView, StyledText };
|
|
@@ -1,17 +1,52 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { View } from 'react-native';
|
|
2
|
-
declare const BottomNavigationTab: import("
|
|
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
|
-
},
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
declare const
|
|
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
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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, };
|
package/types/src/components/{Typography/Text/__test__ → BottomNavigation/__tests__}/index.spec.d.ts
RENAMED
|
File without changes
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
3
|
-
import
|
|
4
|
-
declare type
|
|
5
|
-
|
|
6
|
-
key: V;
|
|
3
|
+
import { IconName } from '../Icon';
|
|
4
|
+
export declare type BottomNavigationTabType = {
|
|
5
|
+
key: string;
|
|
7
6
|
title?: string;
|
|
8
|
-
icon:
|
|
7
|
+
icon: IconName;
|
|
9
8
|
component: ReactNode;
|
|
10
9
|
testID?: string;
|
|
11
10
|
};
|
|
12
|
-
interface
|
|
11
|
+
interface BottomNavigationProps extends ViewProps {
|
|
13
12
|
/**
|
|
14
|
-
* Callback which is called on tab
|
|
13
|
+
* Callback which is called on tab press, receiving key of upcoming active Tab.
|
|
15
14
|
*/
|
|
16
|
-
|
|
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:
|
|
24
|
+
selectedTabKey: string;
|
|
26
25
|
/**
|
|
27
|
-
* List of
|
|
26
|
+
* List of Tabs to be rendered. Each Tab must have an unique key.
|
|
28
27
|
*/
|
|
29
|
-
tabs:
|
|
28
|
+
tabs: {
|
|
29
|
+
key: string;
|
|
30
|
+
title?: string;
|
|
31
|
+
icon: IconName;
|
|
32
|
+
component: ReactNode;
|
|
33
|
+
testID?: string;
|
|
34
|
+
}[];
|
|
30
35
|
/**
|
|
31
|
-
*
|
|
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:
|
|
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;
|
|
File without changes
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { View } from 'react-native';
|
|
2
|
-
declare const StyledCard: import("
|
|
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 };
|
|
File without changes
|
|
@@ -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("
|
|
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
|
-
},
|
|
10
|
+
}, {}, {
|
|
11
|
+
ref?: import("react").Ref<View> | undefined;
|
|
12
|
+
}>;
|
|
7
13
|
export { StyledDivider };
|