@hero-design/rn 7.1.3-alpha3 → 7.1.3-alpha6
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/es/index.js +328 -128
- package/lib/index.js +328 -126
- package/package.json +1 -1
- package/playground/components/BottomNavigation.tsx +8 -8
- package/playground/components/Button.tsx +67 -0
- package/playground/components/FAB.tsx +4 -1
- package/playground/components/Tabs.tsx +45 -0
- package/playground/index.tsx +10 -4
- package/src/components/Badge/StyledBadge.tsx +3 -5
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +52 -20
- package/src/components/Badge/index.tsx +3 -1
- package/src/components/BottomNavigation/StyledBottomNavigation.tsx +7 -0
- package/src/components/BottomNavigation/__tests__/BottomNavigation.spec.tsx +1 -1
- package/src/components/BottomNavigation/index.tsx +14 -18
- package/src/components/Button/IconButton.tsx +62 -0
- package/src/components/Button/__tests__/__snapshots__/index.spec.tsx.snap +43 -0
- package/src/components/Button/__tests__/index.spec.tsx +29 -0
- package/src/components/Button/index.tsx +5 -0
- package/src/components/FAB/ActionGroup/StyledActionGroup.tsx +1 -1
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +1 -1
- package/src/components/Tabs/StyledTabs.tsx +72 -0
- package/src/components/Tabs/__tests__/Tabs.spec.tsx +79 -0
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.spec.tsx.snap +295 -0
- package/src/components/Tabs/index.tsx +177 -0
- package/src/index.ts +4 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +16 -6
- package/src/theme/components/badge.ts +1 -9
- package/src/theme/components/bottomNavigation.ts +5 -1
- package/src/theme/components/fab.ts +2 -2
- package/src/theme/components/tabs.ts +20 -0
- package/src/theme/index.ts +3 -0
- package/src/utils/__tests__/scale.spec.ts +3 -3
- package/src/utils/scale.ts +4 -1
- 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 +2 -2
- package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +2 -1
- package/types/src/components/BottomNavigation/index.d.ts +10 -10
- package/types/src/components/Button/IconButton.d.ts +34 -0
- package/types/src/components/Button/__tests__/index.spec.d.ts +1 -0
- package/types/src/components/Button/index.d.ts +4 -0
- package/types/src/components/Tabs/StyledTabs.d.ts +23 -0
- package/types/src/components/Tabs/__tests__/Tabs.spec.d.ts +1 -0
- package/types/src/components/Tabs/index.d.ts +40 -0
- package/types/src/index.d.ts +3 -1
- package/types/src/theme/components/badge.d.ts +0 -6
- package/types/src/theme/components/bottomNavigation.d.ts +3 -0
- package/types/src/theme/components/tabs.d.ts +15 -0
- package/types/src/theme/index.d.ts +2 -0
- package/types/src/utils/scale.d.ts +2 -1
|
@@ -17,7 +17,11 @@ const getBottomNavigationTheme = (theme: GlobalTheme) => {
|
|
|
17
17
|
elevation: 10,
|
|
18
18
|
};
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const space = {
|
|
21
|
+
titleMarginTop: `${theme.space.xsmall}px`,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return { colors, shadows, sizes, space };
|
|
21
25
|
};
|
|
22
26
|
|
|
23
27
|
export default getBottomNavigationTheme;
|
|
@@ -35,11 +35,11 @@ const getFABTheme = (theme: GlobalTheme) => {
|
|
|
35
35
|
actionItemPaddingRight: `${theme.space.medium}px`,
|
|
36
36
|
actionItemPaddingTop: `${theme.space.small}px`,
|
|
37
37
|
actionItemPaddingBottom: `${theme.space.small}px`,
|
|
38
|
-
actionItemMargin: `${theme.space.
|
|
38
|
+
actionItemMargin: `${theme.space.xsmall}px`,
|
|
39
39
|
actionItemMarginRight: `${theme.space.large}px`,
|
|
40
40
|
actionItemTextPaddingLeft: `${theme.space.small}px`,
|
|
41
41
|
headerTextMarginRight: `${theme.space.large}px`,
|
|
42
|
-
headerTextMarginBottom: `${theme.space.
|
|
42
|
+
headerTextMarginBottom: `${theme.space.medium}px`,
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
const radii = {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { GlobalTheme } from '../global';
|
|
2
|
+
|
|
3
|
+
const getTabsTheme = (theme: GlobalTheme) => {
|
|
4
|
+
const colors = {
|
|
5
|
+
background: theme.colors.primary,
|
|
6
|
+
active: theme.colors.invertedText,
|
|
7
|
+
inactive: `${theme.colors.invertedText}50`,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const space = {
|
|
11
|
+
flatListHorizontalPadding: `${theme.space.small}px`,
|
|
12
|
+
titleMarginLeft: `${theme.space.small}px`,
|
|
13
|
+
itemHorizontalPadding: `${theme.space.medium}px`,
|
|
14
|
+
itemVerticalPadding: `${theme.space.large}px`,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return { colors, space };
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default getTabsTheme;
|
package/src/theme/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import getBadgeTheme from './components/badge';
|
|
|
4
4
|
import getBottomNavigationTheme from './components/bottomNavigation';
|
|
5
5
|
import getCardTheme from './components/card';
|
|
6
6
|
import getDividerTheme from './components/divider';
|
|
7
|
+
import getTabsTheme from './components/tabs';
|
|
7
8
|
import getIconTheme from './components/icon';
|
|
8
9
|
import getTypographyTheme from './components/typography';
|
|
9
10
|
import getFABTheme from './components/fab';
|
|
@@ -15,6 +16,7 @@ type Theme = GlobalTheme & {
|
|
|
15
16
|
card: ReturnType<typeof getCardTheme>;
|
|
16
17
|
divider: ReturnType<typeof getDividerTheme>;
|
|
17
18
|
icon: ReturnType<typeof getIconTheme>;
|
|
19
|
+
tabs: ReturnType<typeof getTabsTheme>;
|
|
18
20
|
typography: ReturnType<typeof getTypographyTheme>;
|
|
19
21
|
fab: ReturnType<typeof getFABTheme>;
|
|
20
22
|
};
|
|
@@ -28,6 +30,7 @@ const getTheme = (theme: GlobalTheme = globalTheme): Theme => ({
|
|
|
28
30
|
card: getCardTheme(theme),
|
|
29
31
|
divider: getDividerTheme(theme),
|
|
30
32
|
icon: getIconTheme(theme),
|
|
33
|
+
tabs: getTabsTheme(theme),
|
|
31
34
|
typography: getTypographyTheme(theme),
|
|
32
35
|
fab: getFABTheme(theme),
|
|
33
36
|
},
|
|
@@ -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/src/utils/scale.ts
CHANGED
|
@@ -2,9 +2,12 @@ import { Dimensions } from 'react-native';
|
|
|
2
2
|
|
|
3
3
|
export const BASE_WIDTH = 390; // Based on iPhone 13's viewport size
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const horizontalScale = (size: number) => {
|
|
6
6
|
const { width, height } = Dimensions.get('window');
|
|
7
7
|
const shortDimension = width < height ? width : height;
|
|
8
8
|
|
|
9
9
|
return (shortDimension / BASE_WIDTH) * size;
|
|
10
10
|
};
|
|
11
|
+
|
|
12
|
+
export const scale = (size: number, factor: number = 0.5) =>
|
|
13
|
+
size + (horizontalScale(size) - size) * factor;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
1
|
+
declare const BottomNavigationPlayground: () => JSX.Element;
|
|
2
|
+
export default BottomNavigationPlayground;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { View } from 'react-native';
|
|
2
2
|
declare type ThemeIntent = 'success' | 'warning' | 'danger' | 'info';
|
|
3
3
|
declare const StyledView: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
|
|
4
4
|
themeIntent: ThemeIntent;
|
|
5
5
|
}, never>;
|
|
6
|
-
declare const StyledText: import("styled-components").StyledComponent<
|
|
6
|
+
declare const StyledText: import("styled-components").StyledComponent<({ children, fontSize, fontWeight, intent, ...nativeProps }: import("../Typography/Text").TextProps) => JSX.Element, import("../../theme").Theme, {
|
|
7
7
|
themeIntent: ThemeIntent;
|
|
8
8
|
}, never>;
|
|
9
9
|
export { StyledView, StyledText };
|
|
@@ -14,4 +14,5 @@ declare const BottomBarWrapper: import("styled-components").StyledComponent<type
|
|
|
14
14
|
}, never>;
|
|
15
15
|
declare const BottomBar: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {}, never>;
|
|
16
16
|
declare const BottomBarItem: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {}, never>;
|
|
17
|
-
|
|
17
|
+
declare const StyledBottomBarText: import("styled-components").StyledComponent<({ children, fontSize, fontWeight, intent, ...nativeProps }: import("../Typography/Text").TextProps) => JSX.Element, import("../../theme").Theme, {}, never>;
|
|
18
|
+
export { BottomBar, BottomBarItem, BottomNavigationTab, BottomNavigationContainer, BottomBarWrapper, ContentWrapper, StyledBottomBarText, };
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
2
|
import { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
3
|
-
import
|
|
4
|
-
declare type IconType =
|
|
5
|
-
export declare type Tab
|
|
6
|
-
key:
|
|
3
|
+
import { IconProps } from '../Icon';
|
|
4
|
+
declare type IconType = IconProps['icon'];
|
|
5
|
+
export declare type Tab = {
|
|
6
|
+
key: string;
|
|
7
7
|
title?: string;
|
|
8
8
|
icon: IconType;
|
|
9
9
|
component: ReactNode;
|
|
10
10
|
testID?: string;
|
|
11
11
|
};
|
|
12
|
-
interface BottomNavigationType
|
|
12
|
+
interface BottomNavigationType extends ViewProps {
|
|
13
13
|
/**
|
|
14
14
|
* Callback which is called on tab change, receiving id of upcoming active Tab.
|
|
15
15
|
*/
|
|
16
|
-
onChange: (key:
|
|
16
|
+
onChange: (key: string) => void;
|
|
17
17
|
/**
|
|
18
18
|
* Whether inactive tabs should be removed and unmounted in React.
|
|
19
19
|
* Defaults to `false`.
|
|
@@ -22,11 +22,11 @@ interface BottomNavigationType<V extends string | number, T extends Tab<V>> exte
|
|
|
22
22
|
/**
|
|
23
23
|
* Current selected tab key.
|
|
24
24
|
*/
|
|
25
|
-
selectedTabKey:
|
|
25
|
+
selectedTabKey: string;
|
|
26
26
|
/**
|
|
27
27
|
* List of Tab to be rendered. Each Tab must have an unique id.
|
|
28
28
|
*/
|
|
29
|
-
tabs:
|
|
29
|
+
tabs: Tab[];
|
|
30
30
|
/**
|
|
31
31
|
* Addditional style.
|
|
32
32
|
*/
|
|
@@ -36,5 +36,5 @@ interface BottomNavigationType<V extends string | number, T extends Tab<V>> exte
|
|
|
36
36
|
*/
|
|
37
37
|
testID?: string;
|
|
38
38
|
}
|
|
39
|
-
declare const BottomNavigation:
|
|
39
|
+
declare const BottomNavigation: ({ onChange, renderActiveTabOnly, selectedTabKey, tabs, ...nativeProps }: BottomNavigationType) => JSX.Element;
|
|
40
40
|
export default BottomNavigation;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle, TouchableOpacityProps } from 'react-native';
|
|
2
|
+
import { IconProps } 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: IconProps['icon'];
|
|
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
|
+
* Addditional 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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { View, FlatList } from 'react-native';
|
|
2
|
+
declare const TabScreen: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
|
|
3
|
+
themeVisibility?: boolean | undefined;
|
|
4
|
+
}, never>;
|
|
5
|
+
declare const TabContainer: 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 HeaderTabWrapper: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {
|
|
8
|
+
themeInsets: {
|
|
9
|
+
top: number;
|
|
10
|
+
right: number;
|
|
11
|
+
bottom: number;
|
|
12
|
+
left: number;
|
|
13
|
+
};
|
|
14
|
+
}, never>;
|
|
15
|
+
declare const StyledFlatList: new <T>() => FlatList<T>;
|
|
16
|
+
declare const HeaderTabItem: import("styled-components").StyledComponent<typeof View, import("../../theme").Theme, {}, never>;
|
|
17
|
+
declare const StyledHeaderTabIcon: import("styled-components").StyledComponent<({ icon, style, size, intent, testID, }: import("../Icon").IconProps) => JSX.Element, import("../../theme").Theme, {
|
|
18
|
+
themeActive: boolean;
|
|
19
|
+
}, never>;
|
|
20
|
+
declare const StyledHeaderTabText: import("styled-components").StyledComponent<({ children, fontSize, fontWeight, intent, ...nativeProps }: import("../Typography/Text").TextProps) => JSX.Element, import("../../theme").Theme, {
|
|
21
|
+
themeActive: boolean;
|
|
22
|
+
}, never>;
|
|
23
|
+
export { StyledFlatList, HeaderTabItem, TabScreen, TabContainer, HeaderTabWrapper, ContentWrapper, StyledHeaderTabIcon, StyledHeaderTabText, };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
3
|
+
import { IconProps } from '../Icon';
|
|
4
|
+
declare type IconType = IconProps['icon'];
|
|
5
|
+
export declare type Tab = {
|
|
6
|
+
key: string;
|
|
7
|
+
title: string;
|
|
8
|
+
icon: IconType;
|
|
9
|
+
component: ReactNode;
|
|
10
|
+
testID?: string;
|
|
11
|
+
};
|
|
12
|
+
interface TabType extends ViewProps {
|
|
13
|
+
/**
|
|
14
|
+
* Callback which is called on tab change, receiving id of upcoming active Tab.
|
|
15
|
+
*/
|
|
16
|
+
onChange: (key: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Whether inactive tabs should be removed and unmounted in React.
|
|
19
|
+
* Defaults to `false`.
|
|
20
|
+
*/
|
|
21
|
+
renderActiveTabOnly?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Current selected tab key.
|
|
24
|
+
*/
|
|
25
|
+
selectedTabKey: string;
|
|
26
|
+
/**
|
|
27
|
+
* List of Tab to be rendered. Each Tab must have an unique id.
|
|
28
|
+
*/
|
|
29
|
+
tabs: Tab[];
|
|
30
|
+
/**
|
|
31
|
+
* Addditional style.
|
|
32
|
+
*/
|
|
33
|
+
style?: StyleProp<ViewStyle>;
|
|
34
|
+
/**
|
|
35
|
+
* Testing id of the component.
|
|
36
|
+
*/
|
|
37
|
+
testID?: string;
|
|
38
|
+
}
|
|
39
|
+
declare const Tabs: ({ onChange, renderActiveTabOnly, selectedTabKey, tabs, ...nativeProps }: TabType) => JSX.Element;
|
|
40
|
+
export default Tabs;
|
package/types/src/index.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ import Badge from './components/Badge';
|
|
|
5
5
|
import BottomNavigation from './components/BottomNavigation';
|
|
6
6
|
import Card from './components/Card';
|
|
7
7
|
import Divider from './components/Divider';
|
|
8
|
+
import Tabs from './components/Tabs';
|
|
8
9
|
import Icon from './components/Icon';
|
|
9
10
|
import Typography from './components/Typography';
|
|
10
11
|
import FAB from './components/FAB';
|
|
11
|
-
|
|
12
|
+
import Button from './components/Button';
|
|
13
|
+
export { theme, getTheme, useTheme, scale, ThemeProvider, Badge, BottomNavigation, Card, Divider, Icon, Tabs, Typography, FAB, Button, };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { GlobalTheme } from '../global';
|
|
2
|
+
declare const getTabsTheme: (theme: GlobalTheme) => {
|
|
3
|
+
colors: {
|
|
4
|
+
background: string;
|
|
5
|
+
active: string;
|
|
6
|
+
inactive: string;
|
|
7
|
+
};
|
|
8
|
+
space: {
|
|
9
|
+
flatListHorizontalPadding: string;
|
|
10
|
+
titleMarginLeft: string;
|
|
11
|
+
itemHorizontalPadding: string;
|
|
12
|
+
itemVerticalPadding: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
export default getTabsTheme;
|
|
@@ -3,6 +3,7 @@ import getBadgeTheme from './components/badge';
|
|
|
3
3
|
import getBottomNavigationTheme from './components/bottomNavigation';
|
|
4
4
|
import getCardTheme from './components/card';
|
|
5
5
|
import getDividerTheme from './components/divider';
|
|
6
|
+
import getTabsTheme from './components/tabs';
|
|
6
7
|
import getIconTheme from './components/icon';
|
|
7
8
|
import getTypographyTheme from './components/typography';
|
|
8
9
|
import getFABTheme from './components/fab';
|
|
@@ -13,6 +14,7 @@ declare type Theme = GlobalTheme & {
|
|
|
13
14
|
card: ReturnType<typeof getCardTheme>;
|
|
14
15
|
divider: ReturnType<typeof getDividerTheme>;
|
|
15
16
|
icon: ReturnType<typeof getIconTheme>;
|
|
17
|
+
tabs: ReturnType<typeof getTabsTheme>;
|
|
16
18
|
typography: ReturnType<typeof getTypographyTheme>;
|
|
17
19
|
fab: ReturnType<typeof getFABTheme>;
|
|
18
20
|
};
|