@momo-kits/step 0.92.21-beta.1 → 0.92.21-beta.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/StepsHorizontal.tsx +59 -19
- package/package.json +1 -1
- package/publish.sh +1 -1
- package/types.ts +2 -0
package/StepsHorizontal.tsx
CHANGED
|
@@ -1,35 +1,65 @@
|
|
|
1
1
|
import React, {FC} from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
2
|
+
import {FlexAlignType, View} from 'react-native';
|
|
3
3
|
import {Step, StepsProps} from './types';
|
|
4
4
|
import StepIcon from './StepIcon';
|
|
5
5
|
import {Spacing, Text} from '@momo-kits/foundation';
|
|
6
6
|
import {getStepColor, getStepTypo} from './utils';
|
|
7
7
|
import styles from './styles';
|
|
8
8
|
|
|
9
|
+
type TextAlign = 'left' | 'right' | 'center';
|
|
10
|
+
|
|
9
11
|
const StepsHorizontal: FC<StepsProps> = ({
|
|
10
12
|
steps,
|
|
11
13
|
size,
|
|
12
14
|
activeIndex,
|
|
13
15
|
useNumber = false,
|
|
16
|
+
align = 'center',
|
|
14
17
|
}) => {
|
|
15
18
|
const renderStepItem = (i: Step, ii: number) => {
|
|
16
19
|
const {title, description, error, time} = steps[ii];
|
|
17
20
|
let typoStyle = getStepTypo(activeIndex, ii, error, size);
|
|
21
|
+
let alignItems: FlexAlignType = 'center';
|
|
22
|
+
let textAlign: TextAlign = 'center';
|
|
23
|
+
|
|
24
|
+
if (align === 'left') {
|
|
25
|
+
alignItems = 'flex-start';
|
|
26
|
+
textAlign = 'left';
|
|
27
|
+
} else if (align === 'right') {
|
|
28
|
+
alignItems = 'flex-end';
|
|
29
|
+
textAlign = 'right';
|
|
30
|
+
} else if (align === 'stretch') {
|
|
31
|
+
if (ii === 0) {
|
|
32
|
+
alignItems = 'flex-start';
|
|
33
|
+
textAlign = 'left';
|
|
34
|
+
} else if (ii === steps.length - 1) {
|
|
35
|
+
textAlign = 'right';
|
|
36
|
+
alignItems = 'flex-end';
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const haveMarginRight =
|
|
41
|
+
ii !== steps.length - 1 && align !== 'center' && align !== 'stretch';
|
|
18
42
|
|
|
19
43
|
return (
|
|
20
|
-
<View
|
|
44
|
+
<View
|
|
45
|
+
key={`Step ${ii}`}
|
|
46
|
+
style={{
|
|
47
|
+
flex: 1,
|
|
48
|
+
alignItems,
|
|
49
|
+
marginRight: haveMarginRight ? Spacing.XS : 0,
|
|
50
|
+
}}>
|
|
21
51
|
{!!time && (
|
|
22
52
|
<Text
|
|
23
|
-
style={
|
|
53
|
+
style={{textAlign}}
|
|
24
54
|
color={typoStyle.time.color}
|
|
25
55
|
typography={typoStyle.time.typography}>
|
|
26
56
|
{time}
|
|
27
57
|
</Text>
|
|
28
58
|
)}
|
|
29
|
-
{renderStepIcon(i, ii)}
|
|
59
|
+
{renderStepIcon(i, ii, align)}
|
|
30
60
|
{!!title && (
|
|
31
61
|
<Text
|
|
32
|
-
style={[styles.title,
|
|
62
|
+
style={[styles.title, {textAlign}]}
|
|
33
63
|
color={typoStyle.title.color}
|
|
34
64
|
typography={typoStyle.title.typography}>
|
|
35
65
|
{title}
|
|
@@ -37,7 +67,7 @@ const StepsHorizontal: FC<StepsProps> = ({
|
|
|
37
67
|
)}
|
|
38
68
|
{!!description && (
|
|
39
69
|
<Text
|
|
40
|
-
style={
|
|
70
|
+
style={{textAlign}}
|
|
41
71
|
color={typoStyle.description.color}
|
|
42
72
|
typography={typoStyle.description.typography}>
|
|
43
73
|
{description}
|
|
@@ -47,16 +77,20 @@ const StepsHorizontal: FC<StepsProps> = ({
|
|
|
47
77
|
);
|
|
48
78
|
};
|
|
49
79
|
|
|
50
|
-
const renderStepIcon = (i: Step, ii: number) => {
|
|
80
|
+
const renderStepIcon = (i: Step, ii: number, align: string = 'center') => {
|
|
51
81
|
const {error} = steps[ii];
|
|
52
82
|
|
|
53
83
|
const stepStyle = getStepColor(activeIndex, ii, error, steps.length);
|
|
54
84
|
const {backgroundColor, borderColor, lineColorRight, lineColorLeft} =
|
|
55
85
|
stepStyle;
|
|
56
86
|
|
|
87
|
+
const lineLeftHide = (align === 'stretch' && ii === 0) || align === 'left';
|
|
88
|
+
const lineRightHide =
|
|
89
|
+
(align === 'stretch' && ii === steps.length - 1) || align === 'right';
|
|
90
|
+
|
|
57
91
|
return (
|
|
58
92
|
<View style={styles.rowStep}>
|
|
59
|
-
{
|
|
93
|
+
{!lineLeftHide && (
|
|
60
94
|
<View
|
|
61
95
|
style={[
|
|
62
96
|
styles.lineHorizontal,
|
|
@@ -66,25 +100,31 @@ const StepsHorizontal: FC<StepsProps> = ({
|
|
|
66
100
|
},
|
|
67
101
|
]}
|
|
68
102
|
/>
|
|
69
|
-
}
|
|
103
|
+
)}
|
|
70
104
|
<StepIcon
|
|
71
105
|
size={size}
|
|
72
106
|
error={error}
|
|
73
107
|
backgroundColor={backgroundColor}
|
|
74
108
|
borderColor={borderColor}
|
|
75
|
-
style={{
|
|
109
|
+
style={{
|
|
110
|
+
marginRight: !lineRightHide ? Spacing.XS : 0,
|
|
111
|
+
marginLeft: !lineLeftHide ? Spacing.XS : 0,
|
|
112
|
+
marginVertical: Spacing.XS,
|
|
113
|
+
}}
|
|
76
114
|
index={ii}
|
|
77
115
|
useNumber={useNumber}
|
|
78
116
|
/>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
117
|
+
{!lineRightHide && (
|
|
118
|
+
<View
|
|
119
|
+
style={[
|
|
120
|
+
styles.lineHorizontal,
|
|
121
|
+
styles.radiusLeft,
|
|
122
|
+
{
|
|
123
|
+
backgroundColor: lineColorRight,
|
|
124
|
+
},
|
|
125
|
+
]}
|
|
126
|
+
/>
|
|
127
|
+
)}
|
|
88
128
|
</View>
|
|
89
129
|
);
|
|
90
130
|
};
|
package/package.json
CHANGED
package/publish.sh
CHANGED
|
@@ -11,7 +11,7 @@ if [ "$1" == "stable" ]; then
|
|
|
11
11
|
npm version patch
|
|
12
12
|
npm publish --tag stable --access=public
|
|
13
13
|
elif [ "$1" == "latest" ]; then
|
|
14
|
-
npm version $(npm view @momo-kits/
|
|
14
|
+
npm version $(npm view @momo-kits/foundation@latest version)
|
|
15
15
|
npm version prerelease --preid=rc
|
|
16
16
|
npm publish --tag latest --access=public
|
|
17
17
|
else
|