@momo-kits/step 0.89.6 → 0.92.1-beta.4
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/StepIcon.tsx +28 -4
- package/StepsHorizontal.tsx +15 -3
- package/StepsVertical.tsx +18 -2
- package/package.json +15 -15
- package/styles.ts +15 -7
- package/types.ts +6 -0
- package/utils.ts +1 -1
package/StepIcon.tsx
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import React, {FC, useContext} from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
2
|
+
import {TextStyle, View} from 'react-native';
|
|
3
3
|
import {StepIconProps} from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ApplicationContext,
|
|
7
|
+
Colors,
|
|
8
|
+
Icon,
|
|
9
|
+
Text,
|
|
10
|
+
Typography,
|
|
11
|
+
} from '@momo-kits/foundation';
|
|
6
12
|
|
|
7
13
|
const StepIcon: FC<StepIconProps> = ({
|
|
8
14
|
size = 'large',
|
|
@@ -10,20 +16,38 @@ const StepIcon: FC<StepIconProps> = ({
|
|
|
10
16
|
borderColor,
|
|
11
17
|
error,
|
|
12
18
|
style,
|
|
19
|
+
useNumber,
|
|
20
|
+
index,
|
|
13
21
|
}) => {
|
|
14
|
-
const {theme} = useContext(ApplicationContext);
|
|
15
22
|
let iconStyle = styles.stepIcon;
|
|
16
23
|
let checkIconSize = 16;
|
|
17
24
|
let iconSource = error ? 'navigation_close' : 'notifications_check';
|
|
25
|
+
let typography: Typography = 'header_xs_semibold';
|
|
18
26
|
|
|
19
27
|
if (size === 'small') {
|
|
20
28
|
iconStyle = styles.stepIconSmall;
|
|
21
29
|
checkIconSize = 12;
|
|
30
|
+
typography = 'label_s_medium';
|
|
22
31
|
}
|
|
23
32
|
return (
|
|
24
33
|
<View
|
|
25
34
|
style={[iconStyle, styles.center, {backgroundColor, borderColor}, style]}>
|
|
26
|
-
|
|
35
|
+
{useNumber ? (
|
|
36
|
+
<Text
|
|
37
|
+
style={{
|
|
38
|
+
position: 'absolute',
|
|
39
|
+
}}
|
|
40
|
+
typography={typography}
|
|
41
|
+
color={Colors.black_01}>
|
|
42
|
+
{index + 1}
|
|
43
|
+
</Text>
|
|
44
|
+
) : (
|
|
45
|
+
<Icon
|
|
46
|
+
size={checkIconSize}
|
|
47
|
+
color={Colors.black_01}
|
|
48
|
+
source={iconSource}
|
|
49
|
+
/>
|
|
50
|
+
)}
|
|
27
51
|
</View>
|
|
28
52
|
);
|
|
29
53
|
};
|
package/StepsHorizontal.tsx
CHANGED
|
@@ -2,17 +2,27 @@ import React, {FC} from 'react';
|
|
|
2
2
|
import {View} from 'react-native';
|
|
3
3
|
import {Step, StepsProps} from './types';
|
|
4
4
|
import StepIcon from './StepIcon';
|
|
5
|
-
import {Spacing, Text} from '@momo-kits/foundation';
|
|
5
|
+
import {Spacing, Text, getAccessibilityID} from '@momo-kits/foundation';
|
|
6
6
|
import {getStepColor, getStepTypo} from './utils';
|
|
7
7
|
import styles from './styles';
|
|
8
8
|
|
|
9
|
-
const StepsHorizontal: FC<StepsProps> = ({
|
|
9
|
+
const StepsHorizontal: FC<StepsProps> = ({
|
|
10
|
+
steps,
|
|
11
|
+
size,
|
|
12
|
+
activeIndex,
|
|
13
|
+
useNumber = false,
|
|
14
|
+
}) => {
|
|
10
15
|
const renderStepItem = (i: Step, ii: number) => {
|
|
11
16
|
const {title, description, error, time} = steps[ii];
|
|
12
17
|
let typoStyle = getStepTypo(activeIndex, ii, error, size);
|
|
18
|
+
const {status} = getStepColor(activeIndex, ii, error, steps.length);
|
|
19
|
+
const accessibilityID = getAccessibilityID?.(`ic_step_${ii}_${status}`);
|
|
13
20
|
|
|
14
21
|
return (
|
|
15
|
-
<View
|
|
22
|
+
<View
|
|
23
|
+
{...accessibilityID}
|
|
24
|
+
key={`Step ${ii}`}
|
|
25
|
+
style={{flex: 1, alignItems: 'center'}}>
|
|
16
26
|
{!!time && (
|
|
17
27
|
<Text
|
|
18
28
|
style={styles.textCenter}
|
|
@@ -68,6 +78,8 @@ const StepsHorizontal: FC<StepsProps> = ({steps, size, activeIndex}) => {
|
|
|
68
78
|
backgroundColor={backgroundColor}
|
|
69
79
|
borderColor={borderColor}
|
|
70
80
|
style={{marginHorizontal: Spacing.XS, marginVertical: Spacing.XS}}
|
|
81
|
+
index={ii}
|
|
82
|
+
useNumber={useNumber}
|
|
71
83
|
/>
|
|
72
84
|
<View
|
|
73
85
|
style={[
|
package/StepsVertical.tsx
CHANGED
|
@@ -2,17 +2,30 @@ import React, {FC, useContext} from 'react';
|
|
|
2
2
|
import {View} from 'react-native';
|
|
3
3
|
import {Step, StepsProps} from './types';
|
|
4
4
|
import {getStepColor, getStepTypo} from './utils';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
ApplicationContext,
|
|
7
|
+
getAccessibilityID,
|
|
8
|
+
Spacing,
|
|
9
|
+
Text,
|
|
10
|
+
} from '@momo-kits/foundation';
|
|
6
11
|
import styles from './styles';
|
|
7
12
|
import StepIcon from './StepIcon';
|
|
8
13
|
|
|
9
|
-
const StepsVertical: FC<StepsProps> = ({
|
|
14
|
+
const StepsVertical: FC<StepsProps> = ({
|
|
15
|
+
steps,
|
|
16
|
+
activeIndex,
|
|
17
|
+
size,
|
|
18
|
+
useNumber = false,
|
|
19
|
+
}) => {
|
|
10
20
|
const {theme} = useContext(ApplicationContext);
|
|
21
|
+
|
|
11
22
|
const renderStepItem = (i: Step, ii: number) => {
|
|
12
23
|
const {error, description, title, time} = steps[ii];
|
|
13
24
|
|
|
14
25
|
const stepStyle = getStepColor(activeIndex, ii, error, steps.length);
|
|
15
26
|
let typoStyle = getStepTypo(activeIndex, ii, error, size);
|
|
27
|
+
const {status} = getStepColor(activeIndex, ii, error, steps.length);
|
|
28
|
+
const accessibilityID = getAccessibilityID?.(`ic_step_${ii}_${status}`);
|
|
16
29
|
|
|
17
30
|
const {backgroundColor, borderColor} = stepStyle;
|
|
18
31
|
const lineColor =
|
|
@@ -21,6 +34,7 @@ const StepsVertical: FC<StepsProps> = ({steps, activeIndex, size}) => {
|
|
|
21
34
|
: theme.colors.background.default;
|
|
22
35
|
return (
|
|
23
36
|
<View
|
|
37
|
+
{...accessibilityID}
|
|
24
38
|
key={`Step ${ii}`}
|
|
25
39
|
style={{
|
|
26
40
|
flexDirection: 'row',
|
|
@@ -37,6 +51,8 @@ const StepsVertical: FC<StepsProps> = ({steps, activeIndex, size}) => {
|
|
|
37
51
|
error={error}
|
|
38
52
|
backgroundColor={backgroundColor}
|
|
39
53
|
borderColor={borderColor}
|
|
54
|
+
useNumber={useNumber}
|
|
55
|
+
index={ii}
|
|
40
56
|
/>
|
|
41
57
|
{ii !== steps.length - 1 && (
|
|
42
58
|
<View
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
"name": "@momo-kits/step",
|
|
3
|
+
"version": "0.92.1-beta.4",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.tsx",
|
|
6
|
+
"dependencies": {},
|
|
7
|
+
"peerDependencies": {
|
|
8
|
+
"@momo-kits/foundation": "latest",
|
|
9
|
+
"prop-types": "^15.7.2",
|
|
10
|
+
"react": "16.9.0",
|
|
11
|
+
"react-native": ">=0.55"
|
|
12
|
+
},
|
|
13
|
+
"devDependencies": {
|
|
14
|
+
"@momo-platform/versions": "4.1.11"
|
|
15
|
+
},
|
|
16
|
+
"license": "MoMo"
|
|
17
17
|
}
|
package/styles.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Colors, Radius, Spacing} from '@momo-kits/foundation';
|
|
2
|
+
import {Colors, Radius, scaleSize, Spacing} from '@momo-kits/foundation';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
stepIcon: {
|
|
6
|
-
width: 24,
|
|
7
|
-
height: 24,
|
|
6
|
+
width: scaleSize(24),
|
|
7
|
+
height: scaleSize(24),
|
|
8
8
|
borderWidth: 2,
|
|
9
|
-
borderRadius: Radius.
|
|
9
|
+
borderRadius: scaleSize(Radius.L),
|
|
10
10
|
},
|
|
11
11
|
stepIconSmall: {
|
|
12
|
-
width: 16,
|
|
13
|
-
height: 16,
|
|
12
|
+
width: scaleSize(16),
|
|
13
|
+
height: scaleSize(16),
|
|
14
14
|
borderWidth: 2,
|
|
15
|
-
borderRadius: Radius.
|
|
15
|
+
borderRadius: scaleSize(Radius.M),
|
|
16
16
|
},
|
|
17
17
|
lineHorizontal: {
|
|
18
18
|
height: 2,
|
|
@@ -45,4 +45,12 @@ export default StyleSheet.create({
|
|
|
45
45
|
textCenter: {
|
|
46
46
|
textAlign: 'center',
|
|
47
47
|
},
|
|
48
|
+
largeText: {
|
|
49
|
+
fontSize: scaleSize(12),
|
|
50
|
+
lineHeight: scaleSize(16),
|
|
51
|
+
},
|
|
52
|
+
smallText: {
|
|
53
|
+
fontSize: scaleSize(8),
|
|
54
|
+
lineHeight: scaleSize(12),
|
|
55
|
+
},
|
|
48
56
|
});
|
package/types.ts
CHANGED
|
@@ -28,6 +28,8 @@ export type StepsProps = {
|
|
|
28
28
|
* starting from 0 for the first step.
|
|
29
29
|
*/
|
|
30
30
|
activeIndex: number;
|
|
31
|
+
|
|
32
|
+
useNumber?: boolean;
|
|
31
33
|
};
|
|
32
34
|
|
|
33
35
|
/**
|
|
@@ -93,4 +95,8 @@ export type StepIconProps = {
|
|
|
93
95
|
* Can be used to adjust the visual presentation or layout.
|
|
94
96
|
*/
|
|
95
97
|
style?: ViewStyle;
|
|
98
|
+
|
|
99
|
+
useNumber?: boolean;
|
|
100
|
+
|
|
101
|
+
index: number;
|
|
96
102
|
};
|
package/utils.ts
CHANGED