@hero-design/rn 7.2.2 → 7.3.2
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/.turbo/turbo-build.log +2 -2
- package/es/index.js +2389 -449
- package/jest.config.js +1 -1
- package/lib/index.js +2410 -465
- package/package.json +4 -2
- package/playground/components/Avatar.tsx +102 -0
- package/playground/components/Badge.tsx +146 -9
- package/playground/components/Button.tsx +138 -35
- package/playground/components/Card.tsx +36 -1
- package/playground/components/Collapse.tsx +99 -0
- package/playground/components/Drawer.tsx +32 -0
- package/playground/components/FAB.tsx +15 -0
- package/playground/components/IconButton.tsx +67 -0
- package/playground/components/Progress.tsx +95 -0
- package/playground/components/Tabs.tsx +106 -14
- package/playground/components/Tag.tsx +45 -0
- package/playground/index.tsx +18 -0
- package/src/components/Avatar/StyledAvatar.tsx +61 -0
- package/src/components/Avatar/__tests__/StyledAvatar.spec.tsx +48 -0
- package/src/components/Avatar/__tests__/__snapshots__/StyledAvatar.spec.tsx.snap +87 -0
- package/src/components/Avatar/__tests__/__snapshots__/index.spec.tsx.snap +88 -0
- package/src/components/Avatar/__tests__/index.spec.tsx +26 -0
- package/src/components/Avatar/index.tsx +71 -0
- package/src/components/Badge/Status.tsx +77 -0
- package/src/components/Badge/StyledBadge.tsx +38 -26
- package/src/components/Badge/__tests__/Badge.spec.tsx +16 -0
- package/src/components/Badge/__tests__/Status.spec.tsx +27 -0
- package/src/components/Badge/__tests__/__snapshots__/Badge.spec.tsx.snap +133 -52
- package/src/components/Badge/__tests__/__snapshots__/Status.spec.tsx.snap +89 -0
- package/src/components/Badge/index.tsx +77 -19
- package/src/components/Button/Button.tsx +163 -0
- package/src/components/Button/LoadingIndicator/StyledLoadingIndicator.tsx +58 -0
- package/src/components/Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.tsx +20 -0
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/StyledLoadingIndicator.spec.tsx.snap +101 -0
- package/src/components/Button/LoadingIndicator/__tests__/__snapshots__/index.spec.tsx.snap +606 -0
- package/src/components/Button/LoadingIndicator/__tests__/index.spec.tsx +24 -0
- package/src/components/Button/LoadingIndicator/index.tsx +140 -0
- package/src/components/Button/StyledButton.tsx +254 -0
- package/src/components/Button/__tests__/Button.spec.tsx +86 -0
- package/src/components/Button/__tests__/{index.spec.tsx → IconButton.spec.tsx} +0 -0
- package/src/components/Button/__tests__/StyledButton.spec.tsx +154 -0
- package/src/components/Button/__tests__/__snapshots__/{index.spec.tsx.snap → IconButton.spec.tsx.snap} +0 -0
- package/src/components/Button/__tests__/__snapshots__/StyledButton.spec.tsx.snap +895 -0
- package/src/components/Button/index.tsx +10 -2
- package/src/components/Card/StyledCard.tsx +27 -4
- package/src/components/Card/__tests__/StyledCard.spec.tsx +15 -3
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +34 -1
- package/src/components/Card/__tests__/index.spec.tsx +16 -21
- package/src/components/Card/index.tsx +15 -2
- package/src/components/Collapse/StyledCollapse.tsx +15 -0
- package/src/components/Collapse/__tests__/StyledCollapse.spec.tsx +26 -0
- package/src/components/Collapse/__tests__/__snapshots__/StyledCollapse.spec.tsx.snap +37 -0
- package/src/components/Collapse/__tests__/__snapshots__/index.spec.tsx.snap +84 -0
- package/src/components/Collapse/__tests__/index.spec.tsx +42 -0
- package/src/components/Collapse/index.tsx +109 -0
- package/src/components/Divider/index.tsx +1 -1
- package/src/components/Drawer/StyledDrawer.tsx +39 -0
- package/src/components/Drawer/__tests__/__snapshots__/index.spec.tsx.snap +244 -0
- package/src/components/Drawer/__tests__/index.spec.tsx +37 -0
- package/src/components/Drawer/index.tsx +93 -0
- package/src/components/FAB/ActionGroup/__tests__/__snapshots__/index.spec.tsx.snap +78 -62
- package/src/components/FAB/ActionGroup/__tests__/index.spec.tsx +2 -0
- package/src/components/FAB/ActionGroup/index.tsx +13 -0
- package/src/components/FAB/FAB.tsx +63 -13
- package/src/components/FAB/StyledFAB.tsx +25 -6
- package/src/components/FAB/__tests__/__snapshots__/AnimatedFABIcon.spec.tsx.snap +6 -2
- package/src/components/FAB/__tests__/__snapshots__/StyledFAB.spec.tsx.snap +7 -3
- package/src/components/FAB/__tests__/__snapshots__/index.spec.tsx.snap +88 -6
- package/src/components/FAB/__tests__/index.spec.tsx +16 -0
- package/src/components/Progress/ProgressBar.tsx +73 -0
- package/src/components/Progress/ProgressCircle.tsx +165 -0
- package/src/components/Progress/StyledProgressBar.tsx +21 -0
- package/src/components/Progress/StyledProgressCircle.tsx +66 -0
- package/src/components/Progress/__tests__/__snapshots__/index.spec.js.snap +641 -0
- package/src/components/Progress/__tests__/index.spec.js +46 -0
- package/src/components/Progress/index.tsx +6 -0
- package/src/components/Progress/types.ts +1 -0
- package/src/components/Tabs/ActiveTabIndicator.tsx +37 -0
- package/src/components/Tabs/ScrollableTabs.tsx +216 -0
- package/src/components/Tabs/StyledScrollableTabs.tsx +60 -0
- package/src/components/Tabs/StyledTabs.tsx +30 -44
- package/src/components/Tabs/__tests__/ScrollableTabs.spec.tsx +84 -0
- package/src/components/Tabs/__tests__/__snapshots__/ScrollableTabs.spec.tsx.snap +591 -0
- package/src/components/Tabs/__tests__/__snapshots__/index.spec.tsx.snap +317 -224
- package/src/components/Tabs/__tests__/index.spec.tsx +22 -21
- package/src/components/Tabs/index.tsx +155 -114
- package/src/components/Tabs/utils.ts +13 -0
- package/src/components/Tag/StyledTag.tsx +35 -0
- package/src/components/Tag/__tests__/Tag.spec.tsx +41 -0
- package/src/components/Tag/__tests__/__snapshots__/Tag.spec.tsx.snap +153 -0
- package/src/components/Tag/index.tsx +41 -0
- package/src/components/Typography/Text/index.tsx +1 -1
- package/src/index.ts +10 -0
- package/src/theme/__tests__/__snapshots__/index.spec.ts.snap +182 -20
- package/src/theme/components/avatar.ts +40 -0
- package/src/theme/components/badge.ts +14 -16
- package/src/theme/components/button.ts +57 -0
- package/src/theme/components/card.ts +8 -2
- package/src/theme/components/drawer.ts +24 -0
- package/src/theme/components/fab.ts +9 -2
- package/src/theme/components/progress.ts +27 -0
- package/src/theme/components/tabs.ts +22 -7
- package/src/theme/components/tag.ts +39 -0
- package/src/theme/global/borders.ts +13 -1
- package/src/theme/global/colors.ts +6 -1
- package/src/theme/global/index.ts +3 -1
- package/src/theme/global/scale.ts +3 -0
- package/src/theme/index.ts +16 -1
- package/src/utils/hooks.ts +10 -0
- package/testUtils/setup.tsx +43 -0
- package/types/playground/components/Avatar.d.ts +2 -0
- package/types/playground/components/Badge.d.ts +0 -0
- package/types/playground/components/BottomNavigation.d.ts +0 -0
- package/types/playground/components/Button.d.ts +0 -0
- package/types/playground/components/Card.d.ts +0 -0
- package/types/playground/components/Collapse.d.ts +2 -0
- package/types/playground/components/Divider.d.ts +0 -0
- package/types/playground/components/Drawer.d.ts +2 -0
- package/types/playground/components/FAB.d.ts +0 -0
- package/types/playground/components/Icon.d.ts +0 -0
- package/types/playground/components/IconButton.d.ts +2 -0
- package/types/playground/components/Progress.d.ts +2 -0
- package/types/playground/components/Tabs.d.ts +0 -0
- package/types/playground/components/Tag.d.ts +2 -0
- package/types/playground/components/Typography.d.ts +0 -0
- package/types/playground/index.d.ts +0 -0
- package/types/src/components/Avatar/StyledAvatar.d.ts +46 -0
- package/types/src/components/{BottomNavigation/__tests__/BottomNavigation.spec.d.ts → Avatar/__tests__/StyledAvatar.spec.d.ts} +0 -0
- package/types/src/components/{Card/__tests__/Card.spec.d.ts → Avatar/__tests__/index.spec.d.ts} +0 -0
- package/types/src/components/Avatar/index.d.ts +25 -0
- package/types/src/components/Badge/Status.d.ts +24 -0
- package/types/src/components/Badge/StyledBadge.d.ts +17 -9
- package/types/src/components/Badge/__tests__/Badge.spec.d.ts +0 -0
- package/types/src/components/{FAB/__tests__/StyledFABContainer.spec.d.ts → Badge/__tests__/Status.spec.d.ts} +0 -0
- package/types/src/components/Badge/index.d.ts +17 -7
- package/types/src/components/BottomNavigation/StyledBottomNavigation.d.ts +0 -0
- package/types/src/components/BottomNavigation/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/BottomNavigation/index.d.ts +0 -0
- package/types/src/components/Button/Button.d.ts +57 -0
- package/types/src/components/Button/IconButton.d.ts +0 -0
- package/types/src/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +20 -0
- package/types/src/components/{FAB/__tests__/StyledFABIcon.spec.d.ts → Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.d.ts} +0 -0
- package/types/src/components/{Icon/__tests__/Icon.spec.d.ts → Button/LoadingIndicator/__tests__/index.spec.d.ts} +0 -0
- package/types/src/components/Button/LoadingIndicator/index.d.ts +26 -0
- package/types/src/components/Button/StyledButton.d.ts +40 -0
- package/types/src/components/{Tabs/__tests__/Tabs.spec.d.ts → Button/__tests__/Button.spec.d.ts} +0 -0
- package/types/src/components/Button/__tests__/IconButton.spec.d.ts +1 -0
- package/types/src/components/Button/__tests__/StyledButton.spec.d.ts +1 -0
- package/types/src/components/Button/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/Button/index.d.ts +8 -4
- package/types/src/components/Card/StyledCard.d.ts +9 -1
- package/types/src/components/Card/__tests__/StyledCard.spec.d.ts +0 -0
- package/types/src/components/Card/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/Card/index.d.ts +5 -1
- package/types/src/components/Collapse/StyledCollapse.d.ts +15 -0
- package/types/src/components/Collapse/__tests__/StyledCollapse.spec.d.ts +1 -0
- package/types/src/components/Collapse/__tests__/index.spec.d.ts +1 -0
- package/types/src/components/Collapse/index.d.ts +23 -0
- package/types/src/components/Divider/StyledDivider.d.ts +0 -0
- package/types/src/components/Divider/__tests__/StyledDivider.spec.d.ts +0 -0
- package/types/src/components/Divider/index.d.ts +0 -0
- package/types/src/components/Drawer/StyledDrawer.d.ts +25 -0
- package/types/src/components/Drawer/__tests__/index.spec.d.ts +1 -0
- package/types/src/components/Drawer/index.d.ts +25 -0
- package/types/src/components/FAB/ActionGroup/ActionItem.d.ts +0 -0
- package/types/src/components/FAB/ActionGroup/StyledActionGroup.d.ts +0 -0
- package/types/src/components/FAB/ActionGroup/StyledActionItem.d.ts +0 -0
- package/types/src/components/FAB/ActionGroup/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/FAB/ActionGroup/index.d.ts +5 -1
- package/types/src/components/FAB/AnimatedFABIcon.d.ts +0 -0
- package/types/src/components/FAB/FAB.d.ts +5 -1
- package/types/src/components/FAB/StyledFAB.d.ts +8 -2
- package/types/src/components/FAB/__tests__/AnimatedFABIcon.spec.d.ts +0 -0
- package/types/src/components/FAB/__tests__/StyledFAB.spec.d.ts +0 -0
- package/types/src/components/FAB/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/FAB/index.d.ts +2 -2
- package/types/src/components/Icon/HeroIcon/index.d.ts +0 -0
- package/types/src/components/Icon/IconList.d.ts +0 -0
- package/types/src/components/Icon/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/Icon/index.d.ts +0 -0
- package/types/src/components/Icon/utils.d.ts +1 -1
- package/types/src/components/Progress/ProgressBar.d.ts +18 -0
- package/types/src/components/Progress/ProgressCircle.d.ts +18 -0
- package/types/src/components/Progress/StyledProgressBar.d.ts +18 -0
- package/types/src/components/Progress/StyledProgressCircle.d.ts +38 -0
- package/types/src/components/Progress/__tests__/index.spec.d.ts +1 -0
- package/types/src/components/Progress/index.d.ts +5 -0
- package/types/src/components/Progress/types.d.ts +1 -0
- package/types/src/components/Tabs/ActiveTabIndicator.d.ts +8 -0
- package/types/src/components/Tabs/ScrollableTab.d.ts +3 -0
- package/types/src/components/Tabs/ScrollableTabs.d.ts +3 -0
- package/types/src/components/Tabs/StyledScrollableTab.d.ts +61 -0
- package/types/src/components/Tabs/StyledScrollableTabs.d.ts +61 -0
- package/types/src/components/Tabs/StyledTabs.d.ts +22 -22
- package/types/src/components/Tabs/__tests__/ScrollableTab.spec.d.ts +1 -0
- package/types/src/components/Tabs/__tests__/ScrollableTabs.spec.d.ts +1 -0
- package/types/src/components/Tabs/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/Tabs/index.d.ts +28 -19
- package/types/src/components/Tabs/utils.d.ts +2 -0
- package/types/src/components/Tag/StyledTag.d.ts +20 -0
- package/types/src/components/Tag/__tests__/Tag.spec.d.ts +1 -0
- package/types/src/components/Tag/index.d.ts +21 -0
- package/types/src/components/Typography/Text/StyledText.d.ts +0 -0
- package/types/src/components/Typography/Text/__tests__/StyledText.spec.d.ts +0 -0
- package/types/src/components/Typography/Text/__tests__/index.spec.d.ts +0 -0
- package/types/src/components/Typography/Text/index.d.ts +0 -0
- package/types/src/components/Typography/index.d.ts +0 -0
- package/types/src/index.d.ts +6 -1
- package/types/src/testHelpers/renderWithTheme.d.ts +0 -0
- package/types/src/theme/__tests__/index.spec.d.ts +0 -0
- package/types/src/theme/components/avatar.d.ts +32 -0
- package/types/src/theme/components/badge.d.ts +12 -13
- package/types/src/theme/components/bottomNavigation.d.ts +0 -0
- package/types/src/theme/components/button.d.ts +37 -0
- package/types/src/theme/components/card.d.ts +5 -1
- package/types/src/theme/components/divider.d.ts +0 -0
- package/types/src/theme/components/drawer.d.ts +21 -0
- package/types/src/theme/components/fab.d.ts +8 -1
- package/types/src/theme/components/icon.d.ts +0 -0
- package/types/src/theme/components/progress.d.ts +21 -0
- package/types/src/theme/components/tabs.d.ts +14 -2
- package/types/src/theme/components/tag.d.ts +30 -0
- package/types/src/theme/components/typography.d.ts +0 -0
- package/types/src/theme/global/borders.d.ts +7 -1
- package/types/src/theme/global/colors.d.ts +6 -1
- package/types/src/theme/global/index.d.ts +7 -1
- package/types/src/theme/global/scale.d.ts +1 -0
- package/types/src/theme/global/space.d.ts +0 -0
- package/types/src/theme/global/typography.d.ts +0 -0
- package/types/src/theme/index.d.ts +10 -0
- package/types/src/types.d.ts +0 -0
- package/types/src/utils/__tests__/scale.spec.d.ts +0 -0
- package/types/src/utils/helpers.d.ts +0 -0
- package/types/src/utils/hooks.d.ts +1 -0
- package/types/src/utils/scale.d.ts +0 -0
- package/.expo/README.md +0 -15
- package/.expo/packager-info.json +0 -10
- package/.expo/settings.json +0 -10
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +0 -33
- package/testUtils/setup.ts +0 -18
- package/types/src/components/FAB/StyledFABContainer.d.ts +0 -3
- package/types/src/components/FAB/StyledFABIcon.d.ts +0 -3
- package/types/src/styled-components.d.ts +0 -6
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Avatar renders correctly 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
Array [
|
|
7
|
+
Object {
|
|
8
|
+
"borderColor": "#7622d7",
|
|
9
|
+
"borderRadius": 16,
|
|
10
|
+
"borderWidth": 1,
|
|
11
|
+
"height": 32,
|
|
12
|
+
"overflow": "hidden",
|
|
13
|
+
"width": 32,
|
|
14
|
+
},
|
|
15
|
+
undefined,
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
testID="avatar"
|
|
19
|
+
themeIntent="primary"
|
|
20
|
+
themeSize="small"
|
|
21
|
+
>
|
|
22
|
+
<Image
|
|
23
|
+
resizeMode="cover"
|
|
24
|
+
source={
|
|
25
|
+
Object {
|
|
26
|
+
"uri": "https://i.pravatar.cc/300",
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
style={
|
|
30
|
+
Array [
|
|
31
|
+
Object {
|
|
32
|
+
"height": 32,
|
|
33
|
+
"width": 32,
|
|
34
|
+
},
|
|
35
|
+
undefined,
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
themeSize="small"
|
|
39
|
+
/>
|
|
40
|
+
</View>
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
exports[`Avatar trigger press function correctly 1`] = `
|
|
44
|
+
<View
|
|
45
|
+
accessible={true}
|
|
46
|
+
collapsable={false}
|
|
47
|
+
focusable={true}
|
|
48
|
+
nativeID="animatedComponent"
|
|
49
|
+
onClick={[Function]}
|
|
50
|
+
onResponderGrant={[Function]}
|
|
51
|
+
onResponderMove={[Function]}
|
|
52
|
+
onResponderRelease={[Function]}
|
|
53
|
+
onResponderTerminate={[Function]}
|
|
54
|
+
onResponderTerminationRequest={[Function]}
|
|
55
|
+
onStartShouldSetResponder={[Function]}
|
|
56
|
+
style={
|
|
57
|
+
Object {
|
|
58
|
+
"borderColor": "#7622d7",
|
|
59
|
+
"borderRadius": 16,
|
|
60
|
+
"borderWidth": 1,
|
|
61
|
+
"height": 32,
|
|
62
|
+
"opacity": 1,
|
|
63
|
+
"overflow": "hidden",
|
|
64
|
+
"width": 32,
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
testID="avatar"
|
|
68
|
+
>
|
|
69
|
+
<Image
|
|
70
|
+
resizeMode="cover"
|
|
71
|
+
source={
|
|
72
|
+
Object {
|
|
73
|
+
"uri": "https://i.pravatar.cc/300",
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
style={
|
|
77
|
+
Array [
|
|
78
|
+
Object {
|
|
79
|
+
"height": 32,
|
|
80
|
+
"width": 32,
|
|
81
|
+
},
|
|
82
|
+
undefined,
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
themeSize="small"
|
|
86
|
+
/>
|
|
87
|
+
</View>
|
|
88
|
+
`;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { fireEvent } from '@testing-library/react-native';
|
|
3
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
|
+
import Avatar from '..';
|
|
5
|
+
|
|
6
|
+
describe('Avatar', () => {
|
|
7
|
+
const source = { uri: 'https://i.pravatar.cc/300' };
|
|
8
|
+
const pressFn = jest.fn();
|
|
9
|
+
|
|
10
|
+
it('renders correctly', () => {
|
|
11
|
+
const wrapper = renderWithTheme(<Avatar testID="avatar" source={source} />);
|
|
12
|
+
expect(wrapper.queryAllByTestId('avatar')).toHaveLength(1);
|
|
13
|
+
|
|
14
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('trigger press function correctly', () => {
|
|
18
|
+
const wrapper = renderWithTheme(
|
|
19
|
+
<Avatar testID="avatar" source={source} onPress={pressFn} />
|
|
20
|
+
);
|
|
21
|
+
fireEvent.press(wrapper.getByTestId('avatar'));
|
|
22
|
+
|
|
23
|
+
expect(wrapper.toJSON()).toMatchSnapshot();
|
|
24
|
+
expect(pressFn).toBeCalled();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ImageSourcePropType,
|
|
3
|
+
StyleProp,
|
|
4
|
+
ViewProps,
|
|
5
|
+
ViewStyle,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import {
|
|
9
|
+
StyledImage,
|
|
10
|
+
StyledPressable,
|
|
11
|
+
StyledText,
|
|
12
|
+
StyledTextWrapper,
|
|
13
|
+
StyledView,
|
|
14
|
+
} from './StyledAvatar';
|
|
15
|
+
|
|
16
|
+
interface AvatarProps extends ViewProps {
|
|
17
|
+
/** Callback function when pressing component. */
|
|
18
|
+
onPress?: () => void;
|
|
19
|
+
/** Image source to be displayed on avatar. */
|
|
20
|
+
source?: ImageSourcePropType;
|
|
21
|
+
/** Renders title in the placeholder. */
|
|
22
|
+
title?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Intent of the Icon.
|
|
25
|
+
*/
|
|
26
|
+
intent?: 'primary' | 'info' | 'danger' | 'success' | 'warning';
|
|
27
|
+
/** Size of the avatar. */
|
|
28
|
+
size?: 'small' | 'medium' | 'large' | 'xlarge';
|
|
29
|
+
/**
|
|
30
|
+
* Addditional style.
|
|
31
|
+
*/
|
|
32
|
+
style?: StyleProp<ViewStyle>;
|
|
33
|
+
/**
|
|
34
|
+
* Testing id of the component.
|
|
35
|
+
*/
|
|
36
|
+
testID?: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const Avatar = ({
|
|
40
|
+
onPress,
|
|
41
|
+
source,
|
|
42
|
+
testID,
|
|
43
|
+
style,
|
|
44
|
+
title,
|
|
45
|
+
size = 'small',
|
|
46
|
+
intent = 'primary',
|
|
47
|
+
}: AvatarProps) => {
|
|
48
|
+
const Wrapper = onPress ? StyledPressable : StyledView;
|
|
49
|
+
return title !== undefined || source !== undefined ? (
|
|
50
|
+
<Wrapper
|
|
51
|
+
testID={testID}
|
|
52
|
+
onPress={onPress}
|
|
53
|
+
themeIntent={intent}
|
|
54
|
+
themeSize={size}
|
|
55
|
+
style={style}
|
|
56
|
+
>
|
|
57
|
+
{title !== undefined && source === undefined && (
|
|
58
|
+
<StyledTextWrapper>
|
|
59
|
+
<StyledText themeIntent={intent} themeSize={size}>
|
|
60
|
+
{title}
|
|
61
|
+
</StyledText>
|
|
62
|
+
</StyledTextWrapper>
|
|
63
|
+
)}
|
|
64
|
+
{source !== undefined && (
|
|
65
|
+
<StyledImage resizeMode="cover" source={source} themeSize={size} />
|
|
66
|
+
)}
|
|
67
|
+
</Wrapper>
|
|
68
|
+
) : null;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default Avatar;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { View, StyleProp, ViewStyle, ViewProps, Animated } from 'react-native';
|
|
2
|
+
import React, { ReactNode } from 'react';
|
|
3
|
+
import { StyledStatus } from './StyledBadge';
|
|
4
|
+
|
|
5
|
+
export interface StatusProps extends ViewProps {
|
|
6
|
+
/*
|
|
7
|
+
* The Status Badge's content.
|
|
8
|
+
*/
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
/**
|
|
11
|
+
* Whether the Status Badge is visible.
|
|
12
|
+
*/
|
|
13
|
+
visible?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
/**
|
|
16
|
+
* Visual intent color to apply to Status Badge.
|
|
17
|
+
*/
|
|
18
|
+
intent?: 'success' | 'warning' | 'danger' | 'info' | 'archived';
|
|
19
|
+
/**
|
|
20
|
+
* Additional style.
|
|
21
|
+
*/
|
|
22
|
+
style?: StyleProp<ViewStyle>;
|
|
23
|
+
/**
|
|
24
|
+
* Testing id of the component.
|
|
25
|
+
*/
|
|
26
|
+
testID?: string;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const Status = ({
|
|
30
|
+
children,
|
|
31
|
+
visible = true,
|
|
32
|
+
intent = 'danger',
|
|
33
|
+
style,
|
|
34
|
+
testID,
|
|
35
|
+
...nativeProps
|
|
36
|
+
}: StatusProps): JSX.Element => {
|
|
37
|
+
const { current: opacity } = React.useRef<Animated.Value>(
|
|
38
|
+
new Animated.Value(visible ? 1 : 0)
|
|
39
|
+
);
|
|
40
|
+
const isFirstRendering = React.useRef<boolean>(true);
|
|
41
|
+
|
|
42
|
+
React.useEffect(() => {
|
|
43
|
+
// Do not run animation on very first rendering
|
|
44
|
+
if (isFirstRendering.current) {
|
|
45
|
+
isFirstRendering.current = false;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
Animated.timing(opacity, {
|
|
50
|
+
toValue: visible ? 1 : 0,
|
|
51
|
+
duration: 150,
|
|
52
|
+
useNativeDriver: true,
|
|
53
|
+
}).start();
|
|
54
|
+
}, [visible, opacity]);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<View {...nativeProps} style={style} testID={testID}>
|
|
58
|
+
{children}
|
|
59
|
+
<StyledStatus
|
|
60
|
+
style={{
|
|
61
|
+
opacity,
|
|
62
|
+
transform: [
|
|
63
|
+
{
|
|
64
|
+
scale: opacity.interpolate({
|
|
65
|
+
inputRange: [0, 1],
|
|
66
|
+
outputRange: [0.5, 1],
|
|
67
|
+
}),
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
}}
|
|
71
|
+
themeIntent={intent}
|
|
72
|
+
/>
|
|
73
|
+
</View>
|
|
74
|
+
);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default Status;
|
|
@@ -1,32 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Animated, Text } from 'react-native';
|
|
2
2
|
import styled from '@emotion/native';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
warning: 'warningBackground',
|
|
7
|
-
danger: 'dangerBackground',
|
|
8
|
-
info: 'infoBackground',
|
|
9
|
-
} as const;
|
|
4
|
+
type ThemeIntent = 'success' | 'warning' | 'danger' | 'info' | 'archived';
|
|
5
|
+
type ThemePadding = 'narrowContent' | 'wideContent';
|
|
10
6
|
|
|
11
|
-
|
|
7
|
+
const StyledView = styled(Animated.View)<{
|
|
8
|
+
themeIntent: ThemeIntent;
|
|
9
|
+
themePadding: ThemePadding;
|
|
10
|
+
}>(({ themeIntent, themePadding, theme }) => ({
|
|
11
|
+
height: theme.__hd__.badge.sizes.height,
|
|
12
|
+
minWidth: theme.__hd__.badge.sizes.minWidth,
|
|
13
|
+
alignItems: 'center',
|
|
14
|
+
justifyContent: 'center',
|
|
15
|
+
backgroundColor: theme.__hd__.badge.colors[themeIntent],
|
|
16
|
+
borderRadius: theme.radii.rounded,
|
|
17
|
+
paddingHorizontal:
|
|
18
|
+
themePadding === 'wideContent'
|
|
19
|
+
? theme.__hd__.badge.space.horizontalPadding
|
|
20
|
+
: undefined,
|
|
21
|
+
}));
|
|
12
22
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
})
|
|
22
|
-
);
|
|
23
|
+
const StyledText = styled(Text)(({ theme }) => ({
|
|
24
|
+
fontFamily: theme.__hd__.badge.fonts.default,
|
|
25
|
+
fontSize: theme.__hd__.badge.fontSizes.default,
|
|
26
|
+
color: theme.__hd__.badge.colors.text,
|
|
27
|
+
includeFontPadding: false,
|
|
28
|
+
textAlignVertical: 'center',
|
|
29
|
+
textAlign: 'center',
|
|
30
|
+
}));
|
|
23
31
|
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
const StyledStatus = styled(Animated.View)<{
|
|
33
|
+
themeIntent: ThemeIntent;
|
|
34
|
+
}>(({ themeIntent, theme }) => ({
|
|
35
|
+
position: 'absolute',
|
|
36
|
+
top: theme.__hd__.badge.space.statusPositionTop,
|
|
37
|
+
right: theme.__hd__.badge.space.statusPositionRight,
|
|
38
|
+
height: theme.__hd__.badge.sizes.statusHeight,
|
|
39
|
+
width: theme.__hd__.badge.sizes.statusWidth,
|
|
40
|
+
backgroundColor: theme.__hd__.badge.colors[themeIntent],
|
|
41
|
+
borderRadius: theme.radii.rounded,
|
|
42
|
+
}));
|
|
31
43
|
|
|
32
|
-
export { StyledView, StyledText };
|
|
44
|
+
export { StyledView, StyledText, StyledStatus };
|
|
@@ -38,4 +38,20 @@ describe('Badge', () => {
|
|
|
38
38
|
expect(toJSON()).toMatchSnapshot();
|
|
39
39
|
expect(getByText('SUBMITTED')).toBeDefined();
|
|
40
40
|
});
|
|
41
|
+
|
|
42
|
+
it('renders correctly with custom props', () => {
|
|
43
|
+
const { getByText, getByTestId, toJSON } = renderWithTheme(
|
|
44
|
+
<Badge
|
|
45
|
+
content={90}
|
|
46
|
+
intent="success"
|
|
47
|
+
max={50}
|
|
48
|
+
visible
|
|
49
|
+
testID="number-badge"
|
|
50
|
+
/>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
expect(toJSON()).toMatchSnapshot();
|
|
54
|
+
expect(getByTestId('number-badge')).toBeDefined();
|
|
55
|
+
expect(getByText('50+')).toBeDefined();
|
|
56
|
+
});
|
|
41
57
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
3
|
+
import Badge from '..';
|
|
4
|
+
import Typography from '../../Typography';
|
|
5
|
+
import Icon from '../../Icon';
|
|
6
|
+
|
|
7
|
+
describe('Status Badge', () => {
|
|
8
|
+
it('renders correctly', () => {
|
|
9
|
+
const { getByTestId, toJSON } = renderWithTheme(
|
|
10
|
+
<Badge.Status>
|
|
11
|
+
<Icon icon="activate" testID="activate-icon" />
|
|
12
|
+
</Badge.Status>
|
|
13
|
+
);
|
|
14
|
+
expect(toJSON()).toMatchSnapshot();
|
|
15
|
+
expect(getByTestId('activate-icon')).toBeDefined();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('renders correctly with intent', () => {
|
|
19
|
+
const { getByText, toJSON } = renderWithTheme(
|
|
20
|
+
<Badge.Status intent="success">
|
|
21
|
+
<Typography.Text>Activity</Typography.Text>
|
|
22
|
+
</Badge.Status>
|
|
23
|
+
);
|
|
24
|
+
expect(toJSON()).toMatchSnapshot();
|
|
25
|
+
expect(getByText('Activity')).toBeDefined();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -2,33 +2,42 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Badge has danger style when intent is danger 1`] = `
|
|
4
4
|
<View
|
|
5
|
+
collapsable={false}
|
|
6
|
+
nativeID="animatedComponent"
|
|
5
7
|
style={
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
Object {
|
|
9
|
+
"alignItems": "center",
|
|
10
|
+
"backgroundColor": "#de350b",
|
|
11
|
+
"borderRadius": 999,
|
|
12
|
+
"height": 20,
|
|
13
|
+
"justifyContent": "center",
|
|
14
|
+
"minWidth": 20,
|
|
15
|
+
"opacity": 1,
|
|
16
|
+
"paddingHorizontal": 8,
|
|
17
|
+
"transform": Array [
|
|
18
|
+
Object {
|
|
19
|
+
"scale": 1,
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
}
|
|
17
23
|
}
|
|
18
24
|
themeIntent="danger"
|
|
25
|
+
themePadding="wideContent"
|
|
19
26
|
>
|
|
20
27
|
<Text
|
|
21
28
|
style={
|
|
22
29
|
Array [
|
|
23
30
|
Object {
|
|
24
|
-
"color": "#
|
|
31
|
+
"color": "#ffffff",
|
|
25
32
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
26
33
|
"fontSize": 12,
|
|
34
|
+
"includeFontPadding": false,
|
|
35
|
+
"textAlign": "center",
|
|
36
|
+
"textAlignVertical": "center",
|
|
27
37
|
},
|
|
28
38
|
undefined,
|
|
29
39
|
]
|
|
30
40
|
}
|
|
31
|
-
themeIntent="danger"
|
|
32
41
|
>
|
|
33
42
|
DECLINED
|
|
34
43
|
</Text>
|
|
@@ -37,33 +46,42 @@ exports[`Badge has danger style when intent is danger 1`] = `
|
|
|
37
46
|
|
|
38
47
|
exports[`Badge has info style when intent is info 1`] = `
|
|
39
48
|
<View
|
|
49
|
+
collapsable={false}
|
|
50
|
+
nativeID="animatedComponent"
|
|
40
51
|
style={
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
Object {
|
|
53
|
+
"alignItems": "center",
|
|
54
|
+
"backgroundColor": "#4568fb",
|
|
55
|
+
"borderRadius": 999,
|
|
56
|
+
"height": 20,
|
|
57
|
+
"justifyContent": "center",
|
|
58
|
+
"minWidth": 20,
|
|
59
|
+
"opacity": 1,
|
|
60
|
+
"paddingHorizontal": 8,
|
|
61
|
+
"transform": Array [
|
|
62
|
+
Object {
|
|
63
|
+
"scale": 1,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}
|
|
52
67
|
}
|
|
53
68
|
themeIntent="info"
|
|
69
|
+
themePadding="wideContent"
|
|
54
70
|
>
|
|
55
71
|
<Text
|
|
56
72
|
style={
|
|
57
73
|
Array [
|
|
58
74
|
Object {
|
|
59
|
-
"color": "#
|
|
75
|
+
"color": "#ffffff",
|
|
60
76
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
61
77
|
"fontSize": 12,
|
|
78
|
+
"includeFontPadding": false,
|
|
79
|
+
"textAlign": "center",
|
|
80
|
+
"textAlignVertical": "center",
|
|
62
81
|
},
|
|
63
82
|
undefined,
|
|
64
83
|
]
|
|
65
84
|
}
|
|
66
|
-
themeIntent="info"
|
|
67
85
|
>
|
|
68
86
|
SUBMITTED
|
|
69
87
|
</Text>
|
|
@@ -72,33 +90,42 @@ exports[`Badge has info style when intent is info 1`] = `
|
|
|
72
90
|
|
|
73
91
|
exports[`Badge has success style when intent is success 1`] = `
|
|
74
92
|
<View
|
|
93
|
+
collapsable={false}
|
|
94
|
+
nativeID="animatedComponent"
|
|
75
95
|
style={
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
96
|
+
Object {
|
|
97
|
+
"alignItems": "center",
|
|
98
|
+
"backgroundColor": "#017d6d",
|
|
99
|
+
"borderRadius": 999,
|
|
100
|
+
"height": 20,
|
|
101
|
+
"justifyContent": "center",
|
|
102
|
+
"minWidth": 20,
|
|
103
|
+
"opacity": 1,
|
|
104
|
+
"paddingHorizontal": 8,
|
|
105
|
+
"transform": Array [
|
|
106
|
+
Object {
|
|
107
|
+
"scale": 1,
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
}
|
|
87
111
|
}
|
|
88
112
|
themeIntent="success"
|
|
113
|
+
themePadding="wideContent"
|
|
89
114
|
>
|
|
90
115
|
<Text
|
|
91
116
|
style={
|
|
92
117
|
Array [
|
|
93
118
|
Object {
|
|
94
|
-
"color": "#
|
|
119
|
+
"color": "#ffffff",
|
|
95
120
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
96
121
|
"fontSize": 12,
|
|
122
|
+
"includeFontPadding": false,
|
|
123
|
+
"textAlign": "center",
|
|
124
|
+
"textAlignVertical": "center",
|
|
97
125
|
},
|
|
98
126
|
undefined,
|
|
99
127
|
]
|
|
100
128
|
}
|
|
101
|
-
themeIntent="success"
|
|
102
129
|
>
|
|
103
130
|
APPROVED
|
|
104
131
|
</Text>
|
|
@@ -107,35 +134,89 @@ exports[`Badge has success style when intent is success 1`] = `
|
|
|
107
134
|
|
|
108
135
|
exports[`Badge has warning style when intent is warning 1`] = `
|
|
109
136
|
<View
|
|
137
|
+
collapsable={false}
|
|
138
|
+
nativeID="animatedComponent"
|
|
110
139
|
style={
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
140
|
+
Object {
|
|
141
|
+
"alignItems": "center",
|
|
142
|
+
"backgroundColor": "#d98a2c",
|
|
143
|
+
"borderRadius": 999,
|
|
144
|
+
"height": 20,
|
|
145
|
+
"justifyContent": "center",
|
|
146
|
+
"minWidth": 20,
|
|
147
|
+
"opacity": 1,
|
|
148
|
+
"paddingHorizontal": 8,
|
|
149
|
+
"transform": Array [
|
|
150
|
+
Object {
|
|
151
|
+
"scale": 1,
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
}
|
|
122
155
|
}
|
|
123
156
|
themeIntent="warning"
|
|
157
|
+
themePadding="wideContent"
|
|
124
158
|
>
|
|
125
159
|
<Text
|
|
126
160
|
style={
|
|
127
161
|
Array [
|
|
128
162
|
Object {
|
|
129
|
-
"color": "#
|
|
163
|
+
"color": "#ffffff",
|
|
130
164
|
"fontFamily": "BeVietnamPro-SemiBold",
|
|
131
165
|
"fontSize": 12,
|
|
166
|
+
"includeFontPadding": false,
|
|
167
|
+
"textAlign": "center",
|
|
168
|
+
"textAlignVertical": "center",
|
|
132
169
|
},
|
|
133
170
|
undefined,
|
|
134
171
|
]
|
|
135
172
|
}
|
|
136
|
-
themeIntent="warning"
|
|
137
173
|
>
|
|
138
174
|
PENDING
|
|
139
175
|
</Text>
|
|
140
176
|
</View>
|
|
141
177
|
`;
|
|
178
|
+
|
|
179
|
+
exports[`Badge renders correctly with custom props 1`] = `
|
|
180
|
+
<View
|
|
181
|
+
collapsable={false}
|
|
182
|
+
nativeID="animatedComponent"
|
|
183
|
+
style={
|
|
184
|
+
Object {
|
|
185
|
+
"alignItems": "center",
|
|
186
|
+
"backgroundColor": "#017d6d",
|
|
187
|
+
"borderRadius": 999,
|
|
188
|
+
"height": 20,
|
|
189
|
+
"justifyContent": "center",
|
|
190
|
+
"minWidth": 20,
|
|
191
|
+
"opacity": 1,
|
|
192
|
+
"paddingHorizontal": 8,
|
|
193
|
+
"transform": Array [
|
|
194
|
+
Object {
|
|
195
|
+
"scale": 1,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
testID="number-badge"
|
|
201
|
+
themeIntent="success"
|
|
202
|
+
themePadding="wideContent"
|
|
203
|
+
>
|
|
204
|
+
<Text
|
|
205
|
+
style={
|
|
206
|
+
Array [
|
|
207
|
+
Object {
|
|
208
|
+
"color": "#ffffff",
|
|
209
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
210
|
+
"fontSize": 12,
|
|
211
|
+
"includeFontPadding": false,
|
|
212
|
+
"textAlign": "center",
|
|
213
|
+
"textAlignVertical": "center",
|
|
214
|
+
},
|
|
215
|
+
undefined,
|
|
216
|
+
]
|
|
217
|
+
}
|
|
218
|
+
>
|
|
219
|
+
50+
|
|
220
|
+
</Text>
|
|
221
|
+
</View>
|
|
222
|
+
`;
|