@hero-design/rn 7.2.1 → 7.3.1
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/.expo/packager-info.json +1 -1
- package/.expo/prebuild/cached-packages.json +4 -0
- package/.expo/xcodebuild-error.log +2 -0
- package/.expo/xcodebuild.log +11199 -0
- package/.turbo/turbo-build.log +8 -8
- package/.turbo/turbo-build:types.log +2 -0
- package/.turbo/turbo-test.log +131 -0
- package/.turbo/turbo-type-check.log +7 -0
- package/es/index.js +2393 -457
- package/jest.config.js +1 -1
- package/lib/index.js +2407 -466
- 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 +39 -13
- 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 -5
- package/src/components/Card/__tests__/StyledCard.spec.tsx +15 -3
- package/src/components/Card/__tests__/__snapshots__/StyledCard.spec.tsx.snap +34 -2
- 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 +181 -22
- 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 +5 -5
- 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 +15 -0
- 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/Collapse.d.ts +2 -0
- package/types/playground/components/Drawer.d.ts +2 -0
- package/types/playground/components/IconButton.d.ts +2 -0
- package/types/playground/components/Progress.d.ts +2 -0
- package/types/playground/components/Tag.d.ts +2 -0
- package/types/src/components/Avatar/StyledAvatar.d.ts +46 -0
- package/types/src/components/Avatar/__tests__/StyledAvatar.spec.d.ts +1 -0
- package/types/src/components/Avatar/__tests__/index.spec.d.ts +1 -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__/Status.spec.d.ts +1 -0
- package/types/src/components/Badge/index.d.ts +17 -7
- package/types/src/components/Button/Button.d.ts +57 -0
- package/types/src/components/Button/LoadingIndicator/StyledLoadingIndicator.d.ts +20 -0
- package/types/src/components/Button/LoadingIndicator/__tests__/StyledLoadingIndicator.spec.d.ts +1 -0
- package/types/src/components/Button/LoadingIndicator/__tests__/index.spec.d.ts +1 -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/Button/__tests__/Button.spec.d.ts +1 -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/index.d.ts +8 -4
- package/types/src/components/Card/StyledCard.d.ts +9 -1
- 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/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/index.d.ts +5 -1
- 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/index.d.ts +2 -2
- 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/ScrollableTabs.d.ts +3 -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__/ScrollableTabs.spec.d.ts +1 -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/index.d.ts +6 -1
- 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/button.d.ts +37 -0
- package/types/src/theme/components/card.d.ts +3 -3
- 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/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/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/index.d.ts +10 -0
- package/types/src/utils/hooks.d.ts +1 -0
- package/src/components/Card/__tests__/__snapshots__/index.spec.tsx.snap +0 -34
- package/testUtils/setup.ts +0 -18
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
3
|
import { AnimatedFABIcon } from './AnimatedFABIcon';
|
|
4
|
-
import { StyledFABContainer, StyledFABIcon } from './StyledFAB';
|
|
4
|
+
import { StyledFABContainer, StyledFABIcon, StyledFABText } from './StyledFAB';
|
|
5
5
|
import { IconName } from '../Icon';
|
|
6
6
|
|
|
7
7
|
export interface FABProps {
|
|
@@ -10,41 +10,91 @@ export interface FABProps {
|
|
|
10
10
|
*/
|
|
11
11
|
icon: IconName;
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* title of the component.
|
|
15
|
+
*/
|
|
16
|
+
title?: string;
|
|
17
|
+
|
|
13
18
|
/**
|
|
14
19
|
* This function is called on pressing the button.
|
|
15
20
|
*/
|
|
16
21
|
onPress?: () => void;
|
|
22
|
+
|
|
17
23
|
/**
|
|
18
24
|
* Specify if the button is animated.
|
|
19
25
|
*/
|
|
20
26
|
animated?: boolean;
|
|
27
|
+
|
|
21
28
|
/**
|
|
22
29
|
* Specify if the button is in active state. It only works if animated is true.
|
|
23
30
|
*/
|
|
24
31
|
active?: boolean;
|
|
32
|
+
|
|
25
33
|
/**
|
|
26
34
|
* Additional style.
|
|
27
35
|
*/
|
|
28
36
|
style?: StyleProp<ViewStyle>;
|
|
37
|
+
|
|
29
38
|
/**
|
|
30
39
|
* Testing id of the component.
|
|
31
40
|
*/
|
|
32
41
|
testID?: string;
|
|
33
42
|
}
|
|
34
43
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
const IconOnlyContent = ({
|
|
45
|
+
icon,
|
|
46
|
+
animated,
|
|
47
|
+
active,
|
|
48
|
+
}: {
|
|
49
|
+
icon: IconName;
|
|
50
|
+
animated?: boolean;
|
|
51
|
+
|
|
52
|
+
active?: boolean;
|
|
53
|
+
}) => {
|
|
54
|
+
if (animated) {
|
|
55
|
+
return (
|
|
43
56
|
<AnimatedFABIcon active={active} icon={icon} testID="animated-fab-icon" />
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
return <StyledFABIcon icon={icon} testID="styled-fab-icon" />;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const IconWithTextContent = ({
|
|
63
|
+
icon,
|
|
64
|
+
title,
|
|
65
|
+
}: {
|
|
66
|
+
icon: IconName;
|
|
67
|
+
title?: string;
|
|
68
|
+
}) => (
|
|
69
|
+
<>
|
|
70
|
+
<StyledFABIcon size="xsmall" icon={icon} testID="styled-fab-icon" />
|
|
71
|
+
<StyledFABText>{title}</StyledFABText>
|
|
72
|
+
</>
|
|
48
73
|
);
|
|
74
|
+
const FAB = ({
|
|
75
|
+
onPress,
|
|
76
|
+
title,
|
|
77
|
+
icon,
|
|
78
|
+
animated,
|
|
79
|
+
testID,
|
|
80
|
+
active,
|
|
81
|
+
style,
|
|
82
|
+
}: FABProps): JSX.Element => {
|
|
83
|
+
const isIconOnly = !title;
|
|
84
|
+
return (
|
|
85
|
+
<StyledFABContainer
|
|
86
|
+
testID={testID}
|
|
87
|
+
style={style}
|
|
88
|
+
onPress={onPress}
|
|
89
|
+
activeOpacity={0.6}
|
|
90
|
+
>
|
|
91
|
+
{isIconOnly ? (
|
|
92
|
+
<IconOnlyContent animated={animated} active={active} icon={icon} />
|
|
93
|
+
) : (
|
|
94
|
+
<IconWithTextContent icon={icon} title={title} />
|
|
95
|
+
)}
|
|
96
|
+
</StyledFABContainer>
|
|
97
|
+
);
|
|
98
|
+
};
|
|
49
99
|
|
|
50
100
|
export default FAB;
|
|
@@ -1,22 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Text,
|
|
3
|
+
TextProps,
|
|
4
|
+
TouchableHighlight,
|
|
5
|
+
TouchableHighlightProps,
|
|
6
|
+
} from 'react-native';
|
|
2
7
|
import styled from '@emotion/native';
|
|
3
8
|
import Icon, { IconProps } from '../Icon';
|
|
4
9
|
|
|
5
10
|
const StyledFABContainer = styled(TouchableHighlight)<TouchableHighlightProps>(
|
|
6
11
|
({ theme }) => ({
|
|
7
|
-
height: theme.__hd__.fab.sizes.height,
|
|
8
|
-
width: theme.__hd__.fab.sizes.width,
|
|
9
12
|
backgroundColor: theme.__hd__.fab.colors.buttonBackground,
|
|
10
|
-
borderRadius:
|
|
13
|
+
borderRadius: theme.radii.rounded,
|
|
11
14
|
alignItems: 'center',
|
|
12
15
|
justifyContent: 'center',
|
|
13
16
|
overflow: 'hidden',
|
|
17
|
+
alignSelf: 'flex-start',
|
|
18
|
+
paddingHorizontal: theme.__hd__.fab.space.containerPaddingHorizontal,
|
|
19
|
+
paddingVertical: theme.__hd__.fab.space.containerPaddingVertical,
|
|
20
|
+
flexDirection: 'row',
|
|
14
21
|
})
|
|
15
22
|
);
|
|
16
23
|
|
|
17
24
|
const StyledFABIcon = styled(Icon)<IconProps>(({ theme }) => ({
|
|
18
25
|
color: theme.__hd__.fab.colors.icon,
|
|
19
|
-
|
|
26
|
+
lineHeight: theme.__hd__.fab.lineHeights.icon,
|
|
27
|
+
textAlignVertical: 'center',
|
|
28
|
+
textAlign: 'center',
|
|
20
29
|
}));
|
|
21
30
|
|
|
22
|
-
|
|
31
|
+
const StyledFABText = styled(Text)<TextProps>(({ theme }) => ({
|
|
32
|
+
fontFamily: theme.__hd__.fab.fonts.title,
|
|
33
|
+
fontSize: theme.__hd__.fab.fontSizes.title,
|
|
34
|
+
lineHeight: theme.__hd__.fab.lineHeights.title,
|
|
35
|
+
color: theme.__hd__.fab.colors.titleText,
|
|
36
|
+
textAlignVertical: 'center',
|
|
37
|
+
textAlign: 'center',
|
|
38
|
+
marginHorizontal: theme.__hd__.fab.space.titleMarginHorizontal,
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
export { StyledFABContainer, StyledFABIcon, StyledFABText };
|
|
@@ -25,7 +25,9 @@ exports[`AnimatedFABIcon renders correctly when isActive is false 1`] = `
|
|
|
25
25
|
Array [
|
|
26
26
|
Object {
|
|
27
27
|
"color": "#ffffff",
|
|
28
|
-
"
|
|
28
|
+
"lineHeight": 24,
|
|
29
|
+
"textAlign": "center",
|
|
30
|
+
"textAlignVertical": "center",
|
|
29
31
|
},
|
|
30
32
|
Object {},
|
|
31
33
|
],
|
|
@@ -62,7 +64,9 @@ exports[`AnimatedFABIcon renders correctly when isActive is true 1`] = `
|
|
|
62
64
|
Array [
|
|
63
65
|
Object {
|
|
64
66
|
"color": "#ffffff",
|
|
65
|
-
"
|
|
67
|
+
"lineHeight": 24,
|
|
68
|
+
"textAlign": "center",
|
|
69
|
+
"textAlignVertical": "center",
|
|
66
70
|
},
|
|
67
71
|
Object {},
|
|
68
72
|
],
|
|
@@ -15,12 +15,14 @@ exports[`StyledFABContainer renders correctly 1`] = `
|
|
|
15
15
|
Array [
|
|
16
16
|
Object {
|
|
17
17
|
"alignItems": "center",
|
|
18
|
+
"alignSelf": "flex-start",
|
|
18
19
|
"backgroundColor": "#292a2b",
|
|
19
20
|
"borderRadius": 999,
|
|
20
|
-
"
|
|
21
|
+
"flexDirection": "row",
|
|
21
22
|
"justifyContent": "center",
|
|
22
23
|
"overflow": "hidden",
|
|
23
|
-
"
|
|
24
|
+
"paddingHorizontal": 16,
|
|
25
|
+
"paddingVertical": 16,
|
|
24
26
|
},
|
|
25
27
|
undefined,
|
|
26
28
|
]
|
|
@@ -60,7 +62,9 @@ exports[`StyledFABIcon renders correctly 1`] = `
|
|
|
60
62
|
Array [
|
|
61
63
|
Object {
|
|
62
64
|
"color": "#ffffff",
|
|
63
|
-
"
|
|
65
|
+
"lineHeight": 24,
|
|
66
|
+
"textAlign": "center",
|
|
67
|
+
"textAlignVertical": "center",
|
|
64
68
|
},
|
|
65
69
|
undefined,
|
|
66
70
|
],
|
|
@@ -15,12 +15,14 @@ exports[`FAB when animated is false renders StyledFABIcon 1`] = `
|
|
|
15
15
|
Array [
|
|
16
16
|
Object {
|
|
17
17
|
"alignItems": "center",
|
|
18
|
+
"alignSelf": "flex-start",
|
|
18
19
|
"backgroundColor": "#292a2b",
|
|
19
20
|
"borderRadius": 999,
|
|
20
|
-
"
|
|
21
|
+
"flexDirection": "row",
|
|
21
22
|
"justifyContent": "center",
|
|
22
23
|
"overflow": "hidden",
|
|
23
|
-
"
|
|
24
|
+
"paddingHorizontal": 16,
|
|
25
|
+
"paddingVertical": 16,
|
|
24
26
|
},
|
|
25
27
|
Object {
|
|
26
28
|
"backgroundColor": "#292a2b",
|
|
@@ -39,7 +41,9 @@ exports[`FAB when animated is false renders StyledFABIcon 1`] = `
|
|
|
39
41
|
Array [
|
|
40
42
|
Object {
|
|
41
43
|
"color": "#ffffff",
|
|
42
|
-
"
|
|
44
|
+
"lineHeight": 24,
|
|
45
|
+
"textAlign": "center",
|
|
46
|
+
"textAlignVertical": "center",
|
|
43
47
|
},
|
|
44
48
|
undefined,
|
|
45
49
|
],
|
|
@@ -67,12 +71,14 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
|
|
|
67
71
|
Array [
|
|
68
72
|
Object {
|
|
69
73
|
"alignItems": "center",
|
|
74
|
+
"alignSelf": "flex-start",
|
|
70
75
|
"backgroundColor": "#292a2b",
|
|
71
76
|
"borderRadius": 999,
|
|
72
|
-
"
|
|
77
|
+
"flexDirection": "row",
|
|
73
78
|
"justifyContent": "center",
|
|
74
79
|
"overflow": "hidden",
|
|
75
|
-
"
|
|
80
|
+
"paddingHorizontal": 16,
|
|
81
|
+
"paddingVertical": 16,
|
|
76
82
|
},
|
|
77
83
|
Object {
|
|
78
84
|
"backgroundColor": "#292a2b",
|
|
@@ -104,7 +110,9 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
|
|
|
104
110
|
Array [
|
|
105
111
|
Object {
|
|
106
112
|
"color": "#ffffff",
|
|
107
|
-
"
|
|
113
|
+
"lineHeight": 24,
|
|
114
|
+
"textAlign": "center",
|
|
115
|
+
"textAlignVertical": "center",
|
|
108
116
|
},
|
|
109
117
|
Object {},
|
|
110
118
|
],
|
|
@@ -117,3 +125,77 @@ exports[`FAB when animated is true renders animatedFABIcon 1`] = `
|
|
|
117
125
|
</View>
|
|
118
126
|
</View>
|
|
119
127
|
`;
|
|
128
|
+
|
|
129
|
+
exports[`FAB when title has value renders correctly 1`] = `
|
|
130
|
+
<View
|
|
131
|
+
accessible={true}
|
|
132
|
+
focusable={false}
|
|
133
|
+
onClick={[Function]}
|
|
134
|
+
onResponderGrant={[Function]}
|
|
135
|
+
onResponderMove={[Function]}
|
|
136
|
+
onResponderRelease={[Function]}
|
|
137
|
+
onResponderTerminate={[Function]}
|
|
138
|
+
onResponderTerminationRequest={[Function]}
|
|
139
|
+
onStartShouldSetResponder={[Function]}
|
|
140
|
+
style={
|
|
141
|
+
Array [
|
|
142
|
+
Object {
|
|
143
|
+
"alignItems": "center",
|
|
144
|
+
"alignSelf": "flex-start",
|
|
145
|
+
"backgroundColor": "#292a2b",
|
|
146
|
+
"borderRadius": 999,
|
|
147
|
+
"flexDirection": "row",
|
|
148
|
+
"justifyContent": "center",
|
|
149
|
+
"overflow": "hidden",
|
|
150
|
+
"paddingHorizontal": 16,
|
|
151
|
+
"paddingVertical": 16,
|
|
152
|
+
},
|
|
153
|
+
Object {
|
|
154
|
+
"backgroundColor": "#292a2b",
|
|
155
|
+
},
|
|
156
|
+
]
|
|
157
|
+
}
|
|
158
|
+
>
|
|
159
|
+
<HeroIcon
|
|
160
|
+
name="pencil"
|
|
161
|
+
style={
|
|
162
|
+
Array [
|
|
163
|
+
Object {
|
|
164
|
+
"color": "#292a2b",
|
|
165
|
+
"fontSize": 16,
|
|
166
|
+
},
|
|
167
|
+
Array [
|
|
168
|
+
Object {
|
|
169
|
+
"color": "#ffffff",
|
|
170
|
+
"lineHeight": 24,
|
|
171
|
+
"textAlign": "center",
|
|
172
|
+
"textAlignVertical": "center",
|
|
173
|
+
},
|
|
174
|
+
undefined,
|
|
175
|
+
],
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
testID="styled-fab-icon"
|
|
179
|
+
themeIntent="text"
|
|
180
|
+
themeSize="xsmall"
|
|
181
|
+
/>
|
|
182
|
+
<Text
|
|
183
|
+
style={
|
|
184
|
+
Array [
|
|
185
|
+
Object {
|
|
186
|
+
"color": "#ffffff",
|
|
187
|
+
"fontFamily": "BeVietnamPro-SemiBold",
|
|
188
|
+
"fontSize": 16,
|
|
189
|
+
"lineHeight": 24,
|
|
190
|
+
"marginHorizontal": 8,
|
|
191
|
+
"textAlign": "center",
|
|
192
|
+
"textAlignVertical": "center",
|
|
193
|
+
},
|
|
194
|
+
undefined,
|
|
195
|
+
]
|
|
196
|
+
}
|
|
197
|
+
>
|
|
198
|
+
Shout out
|
|
199
|
+
</Text>
|
|
200
|
+
</View>
|
|
201
|
+
`;
|
|
@@ -20,6 +20,22 @@ describe('FAB', () => {
|
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
22
|
|
|
23
|
+
describe('when title has value', () => {
|
|
24
|
+
it('renders correctly', () => {
|
|
25
|
+
const { queryAllByTestId, queryAllByText, toJSON } = renderWithTheme(
|
|
26
|
+
<FAB
|
|
27
|
+
icon="pencil"
|
|
28
|
+
title="Shout out"
|
|
29
|
+
style={{ backgroundColor: theme.colors.backgroundDark }}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect(toJSON()).toMatchSnapshot();
|
|
34
|
+
expect(queryAllByTestId('styled-fab-icon')).toHaveLength(1);
|
|
35
|
+
expect(queryAllByText('Shout out')).toHaveLength(1);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
23
39
|
describe('when animated is false', () => {
|
|
24
40
|
it('renders StyledFABIcon', () => {
|
|
25
41
|
const { queryAllByTestId, toJSON } = renderWithTheme(
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Animated, StyleProp, ViewStyle, ViewProps } from 'react-native';
|
|
3
|
+
|
|
4
|
+
import { StyledWrapper, StyledInner } from './StyledProgressBar';
|
|
5
|
+
|
|
6
|
+
export interface ProgressBarProps extends ViewProps {
|
|
7
|
+
/**
|
|
8
|
+
* The progress completion percentage: 0-100.
|
|
9
|
+
*/
|
|
10
|
+
value: number;
|
|
11
|
+
/**
|
|
12
|
+
* Set intent for your progress.
|
|
13
|
+
*/
|
|
14
|
+
intent?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
15
|
+
/**
|
|
16
|
+
* Additional style.
|
|
17
|
+
*/
|
|
18
|
+
style?: StyleProp<ViewStyle>;
|
|
19
|
+
/*
|
|
20
|
+
* Testing id of the component.
|
|
21
|
+
* */
|
|
22
|
+
testID?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const ProgressBar = ({
|
|
26
|
+
value,
|
|
27
|
+
intent = 'primary',
|
|
28
|
+
style,
|
|
29
|
+
testID,
|
|
30
|
+
...nativeProps
|
|
31
|
+
}: ProgressBarProps): JSX.Element => {
|
|
32
|
+
const [width, setWidth] = useState(0);
|
|
33
|
+
const progressAnimatedValue = useRef<Animated.Value>(new Animated.Value(0));
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const animation = Animated.timing(progressAnimatedValue.current, {
|
|
37
|
+
toValue: value,
|
|
38
|
+
useNativeDriver: true,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
animation.start();
|
|
42
|
+
|
|
43
|
+
return () => animation.stop();
|
|
44
|
+
}, [value]);
|
|
45
|
+
|
|
46
|
+
const interpolateTranslateX = progressAnimatedValue.current.interpolate({
|
|
47
|
+
inputRange: [0, 100],
|
|
48
|
+
outputRange: [-width, 0],
|
|
49
|
+
extrapolate: 'clamp',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const interpolateBorderRadius = progressAnimatedValue.current.interpolate({
|
|
53
|
+
inputRange: [99, 100], // Transition range to remove bother when reached 100%
|
|
54
|
+
outputRange: [999, 0],
|
|
55
|
+
extrapolate: 'clamp',
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<StyledWrapper {...nativeProps} testID={testID} style={style}>
|
|
60
|
+
<StyledInner
|
|
61
|
+
themeIntent={intent}
|
|
62
|
+
onLayout={({ nativeEvent }) => setWidth(nativeEvent.layout.width)}
|
|
63
|
+
style={{
|
|
64
|
+
transform: [{ translateX: interpolateTranslateX }],
|
|
65
|
+
borderTopRightRadius: interpolateBorderRadius,
|
|
66
|
+
borderBottomRightRadius: interpolateBorderRadius,
|
|
67
|
+
}}
|
|
68
|
+
/>
|
|
69
|
+
</StyledWrapper>
|
|
70
|
+
);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default ProgressBar;
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { useTheme } from '@emotion/react';
|
|
2
|
+
import React, { useEffect, useRef } from 'react';
|
|
3
|
+
import {
|
|
4
|
+
Animated,
|
|
5
|
+
View,
|
|
6
|
+
StyleSheet,
|
|
7
|
+
ViewProps,
|
|
8
|
+
StyleProp,
|
|
9
|
+
ViewStyle,
|
|
10
|
+
} from 'react-native';
|
|
11
|
+
import {
|
|
12
|
+
DonutCircle,
|
|
13
|
+
HalfCircleInnerFG,
|
|
14
|
+
HalfCircleInnerBG,
|
|
15
|
+
HalfCircleWrapper,
|
|
16
|
+
StrokeEnd,
|
|
17
|
+
} from './StyledProgressCircle';
|
|
18
|
+
import { ThemeIntent } from './types';
|
|
19
|
+
import Typography from '../Typography';
|
|
20
|
+
|
|
21
|
+
export interface ProgressCircleProps extends ViewProps {
|
|
22
|
+
/**
|
|
23
|
+
* The progress completion percentage: 0-100.
|
|
24
|
+
*/
|
|
25
|
+
value: number;
|
|
26
|
+
/**
|
|
27
|
+
* Set intent for your progress.
|
|
28
|
+
*/
|
|
29
|
+
intent?: 'primary' | 'success' | 'warning' | 'danger' | 'info';
|
|
30
|
+
/**
|
|
31
|
+
* Additional style.
|
|
32
|
+
*/
|
|
33
|
+
style?: StyleProp<ViewStyle>;
|
|
34
|
+
/*
|
|
35
|
+
* Testing id of the component.
|
|
36
|
+
* */
|
|
37
|
+
testID?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const HalfCircle = ({
|
|
41
|
+
type,
|
|
42
|
+
themeIntent = 'primary',
|
|
43
|
+
}: {
|
|
44
|
+
type: 'background' | 'foreground';
|
|
45
|
+
themeIntent?: ThemeIntent;
|
|
46
|
+
}) => (
|
|
47
|
+
<HalfCircleWrapper>
|
|
48
|
+
{type === 'background' ? (
|
|
49
|
+
<HalfCircleInnerBG />
|
|
50
|
+
) : (
|
|
51
|
+
<HalfCircleInnerFG themeIntent={themeIntent} />
|
|
52
|
+
)}
|
|
53
|
+
</HalfCircleWrapper>
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
const ProgressCircle = ({
|
|
57
|
+
value,
|
|
58
|
+
intent = 'primary',
|
|
59
|
+
style,
|
|
60
|
+
testID,
|
|
61
|
+
...nativeProps
|
|
62
|
+
}: ProgressCircleProps): JSX.Element => {
|
|
63
|
+
const theme = useTheme();
|
|
64
|
+
const { radius } = theme.__hd__.progress.sizes;
|
|
65
|
+
const progressAnimatedValue = useRef<Animated.Value>(new Animated.Value(0));
|
|
66
|
+
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
const animation = Animated.timing(progressAnimatedValue.current, {
|
|
69
|
+
toValue: value,
|
|
70
|
+
useNativeDriver: true,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
animation.start();
|
|
74
|
+
|
|
75
|
+
return () => animation.stop();
|
|
76
|
+
}, [value]);
|
|
77
|
+
|
|
78
|
+
// Animate progress circle: 0% => 50%
|
|
79
|
+
const interpolateRotateRightHalf = progressAnimatedValue.current.interpolate({
|
|
80
|
+
inputRange: [0, 50],
|
|
81
|
+
outputRange: ['0deg', '180deg'],
|
|
82
|
+
extrapolate: 'clamp',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const interpolateOpacityRightHalf = progressAnimatedValue.current.interpolate(
|
|
86
|
+
{
|
|
87
|
+
inputRange: [50, 51], // Transition between left and right half
|
|
88
|
+
outputRange: [1, 0],
|
|
89
|
+
extrapolate: 'clamp',
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
// Animate progress circle: 50% => 100%
|
|
94
|
+
const interpolateRotateSecondHalf = progressAnimatedValue.current.interpolate(
|
|
95
|
+
{
|
|
96
|
+
inputRange: [50, 100],
|
|
97
|
+
outputRange: ['0deg', '180deg'],
|
|
98
|
+
extrapolate: 'clamp',
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
// Curve at the end of progress stroke
|
|
103
|
+
const interpolateDotRotate = progressAnimatedValue.current.interpolate({
|
|
104
|
+
inputRange: [0, 100],
|
|
105
|
+
outputRange: ['0deg', '360deg'],
|
|
106
|
+
extrapolate: 'clamp',
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<View {...nativeProps} testID={testID} style={style}>
|
|
111
|
+
<View
|
|
112
|
+
style={{
|
|
113
|
+
flexDirection: 'row',
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
<View>
|
|
117
|
+
<HalfCircle type="foreground" themeIntent={intent} />
|
|
118
|
+
<Animated.View
|
|
119
|
+
style={{
|
|
120
|
+
...StyleSheet.absoluteFillObject,
|
|
121
|
+
transform: [
|
|
122
|
+
{ translateX: radius / 2 },
|
|
123
|
+
{ rotate: interpolateRotateSecondHalf },
|
|
124
|
+
{ translateX: -radius / 2 },
|
|
125
|
+
],
|
|
126
|
+
}}
|
|
127
|
+
>
|
|
128
|
+
<HalfCircle type="background" />
|
|
129
|
+
</Animated.View>
|
|
130
|
+
</View>
|
|
131
|
+
<View style={{ transform: [{ rotate: '180deg' }], zIndex: 1 }}>
|
|
132
|
+
<HalfCircle type="foreground" themeIntent={intent} />
|
|
133
|
+
<Animated.View
|
|
134
|
+
style={{
|
|
135
|
+
...StyleSheet.absoluteFillObject,
|
|
136
|
+
transform: [
|
|
137
|
+
{ translateX: radius / 2 },
|
|
138
|
+
{ rotate: interpolateRotateRightHalf },
|
|
139
|
+
{ translateX: -radius / 2 },
|
|
140
|
+
],
|
|
141
|
+
opacity: interpolateOpacityRightHalf,
|
|
142
|
+
}}
|
|
143
|
+
>
|
|
144
|
+
<HalfCircle type="background" />
|
|
145
|
+
</Animated.View>
|
|
146
|
+
</View>
|
|
147
|
+
<StrokeEnd themeIntent={intent} />
|
|
148
|
+
<Animated.View
|
|
149
|
+
style={{
|
|
150
|
+
...StyleSheet.absoluteFillObject,
|
|
151
|
+
zIndex: 2,
|
|
152
|
+
transform: [{ rotate: interpolateDotRotate }],
|
|
153
|
+
}}
|
|
154
|
+
>
|
|
155
|
+
<StrokeEnd themeIntent={intent} />
|
|
156
|
+
</Animated.View>
|
|
157
|
+
<DonutCircle>
|
|
158
|
+
<Typography.Text fontSize="xlarge">{`${value}%`}</Typography.Text>
|
|
159
|
+
</DonutCircle>
|
|
160
|
+
</View>
|
|
161
|
+
</View>
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
export default ProgressCircle;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Animated, View, ViewProps } from 'react-native';
|
|
2
|
+
import styled from '@emotion/native';
|
|
3
|
+
|
|
4
|
+
import { ThemeIntent } from './types';
|
|
5
|
+
|
|
6
|
+
const StyledWrapper = styled(View)<ViewProps>(({ theme }) => ({
|
|
7
|
+
height: theme.__hd__.progress.sizes.barHeight,
|
|
8
|
+
alignSelf: 'stretch',
|
|
9
|
+
backgroundColor: theme.__hd__.progress.colors.background,
|
|
10
|
+
overflow: 'hidden',
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
const StyledInner = styled(Animated.View)<{ themeIntent: ThemeIntent }>(
|
|
14
|
+
({ theme, themeIntent }) => ({
|
|
15
|
+
flex: 1,
|
|
16
|
+
alignSelf: 'stretch',
|
|
17
|
+
backgroundColor: theme.__hd__.progress.colors[themeIntent],
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
export { StyledWrapper, StyledInner };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { View, ViewProps } from 'react-native';
|
|
2
|
+
import styled from '@emotion/native';
|
|
3
|
+
|
|
4
|
+
import { ThemeIntent } from './types';
|
|
5
|
+
|
|
6
|
+
const HalfCircleWrapper = styled(View)<ViewProps>(({ theme }) => ({
|
|
7
|
+
width: theme.__hd__.progress.sizes.radius,
|
|
8
|
+
height: theme.__hd__.progress.sizes.radius * 2,
|
|
9
|
+
overflow: 'hidden',
|
|
10
|
+
}));
|
|
11
|
+
|
|
12
|
+
const HalfCircleInnerFG = styled(View)<{ themeIntent: ThemeIntent }>(
|
|
13
|
+
({ theme, themeIntent }) => ({
|
|
14
|
+
width: theme.__hd__.progress.sizes.radius * 2,
|
|
15
|
+
height: theme.__hd__.progress.sizes.radius * 2,
|
|
16
|
+
backgroundColor: theme.__hd__.progress.colors[themeIntent],
|
|
17
|
+
borderRadius: theme.__hd__.progress.radii.default,
|
|
18
|
+
})
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const HalfCircleInnerBG = styled(View)<ViewProps>(({ theme }) => ({
|
|
22
|
+
width: theme.__hd__.progress.sizes.radius * 2,
|
|
23
|
+
height: theme.__hd__.progress.sizes.radius * 2,
|
|
24
|
+
backgroundColor: theme.__hd__.progress.colors.background,
|
|
25
|
+
borderRadius: theme.__hd__.progress.radii.default,
|
|
26
|
+
}));
|
|
27
|
+
|
|
28
|
+
const DonutCircle = styled(View)<ViewProps>(({ theme }) => ({
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
top: theme.__hd__.progress.sizes.strokeWidth,
|
|
31
|
+
left: theme.__hd__.progress.sizes.strokeWidth,
|
|
32
|
+
width:
|
|
33
|
+
theme.__hd__.progress.sizes.radius * 2 -
|
|
34
|
+
theme.__hd__.progress.sizes.strokeWidth * 2,
|
|
35
|
+
height:
|
|
36
|
+
theme.__hd__.progress.sizes.radius * 2 -
|
|
37
|
+
theme.__hd__.progress.sizes.strokeWidth * 2,
|
|
38
|
+
zIndex: 3,
|
|
39
|
+
backgroundColor: theme.__hd__.progress.colors.innerBackground,
|
|
40
|
+
borderRadius: theme.__hd__.progress.radii.default,
|
|
41
|
+
alignItems: 'center',
|
|
42
|
+
justifyContent: 'center',
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
const StrokeEnd = styled(View)<{ themeIntent: ThemeIntent }>(
|
|
46
|
+
({ theme, themeIntent }) => ({
|
|
47
|
+
position: 'absolute',
|
|
48
|
+
top: 0,
|
|
49
|
+
left:
|
|
50
|
+
theme.__hd__.progress.sizes.radius -
|
|
51
|
+
theme.__hd__.progress.sizes.strokeWidth / 2,
|
|
52
|
+
width: theme.__hd__.progress.sizes.strokeWidth,
|
|
53
|
+
height: theme.__hd__.progress.sizes.strokeWidth,
|
|
54
|
+
borderRadius: theme.__hd__.progress.radii.default,
|
|
55
|
+
backgroundColor: theme.__hd__.progress.colors[themeIntent],
|
|
56
|
+
zIndex: 2,
|
|
57
|
+
})
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
export {
|
|
61
|
+
DonutCircle,
|
|
62
|
+
HalfCircleWrapper,
|
|
63
|
+
HalfCircleInnerFG,
|
|
64
|
+
HalfCircleInnerBG,
|
|
65
|
+
StrokeEnd,
|
|
66
|
+
};
|