@momo-kits/step 0.167.1-duotest.1 → 0.167.1-rc.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/StepIcon.tsx +2 -2
- package/StepsHorizontal.tsx +27 -19
- package/StepsVertical.tsx +8 -24
- package/package.json +15 -15
- package/styles.ts +32 -0
- package/utils.ts +8 -13
package/StepIcon.tsx
CHANGED
|
@@ -43,7 +43,7 @@ const StepIcon: FC<StepIconProps> = ({
|
|
|
43
43
|
if (useNumber) {
|
|
44
44
|
return (
|
|
45
45
|
<Text
|
|
46
|
-
style={
|
|
46
|
+
style={styles.numberLabel}
|
|
47
47
|
typography={'header_xs_semibold'}
|
|
48
48
|
color={Colors.black_01}>
|
|
49
49
|
{index + 1}
|
|
@@ -65,7 +65,7 @@ const StepIcon: FC<StepIconProps> = ({
|
|
|
65
65
|
// render default Icon
|
|
66
66
|
return (
|
|
67
67
|
<View
|
|
68
|
-
style={[styles.currIcon, {width: contentIconSize
|
|
68
|
+
style={[styles.currIcon, {width: contentIconSize}]}
|
|
69
69
|
/>
|
|
70
70
|
);
|
|
71
71
|
}
|
package/StepsHorizontal.tsx
CHANGED
|
@@ -56,23 +56,28 @@ const StepsHorizontal: FC<StepsProps> = ({
|
|
|
56
56
|
|
|
57
57
|
const haveMarginRight =
|
|
58
58
|
index !== steps.length - 1 && align !== 'center' && align !== 'stretch';
|
|
59
|
+
const marginRight = haveMarginRight ? Spacing.XS : 0;
|
|
59
60
|
|
|
60
61
|
return (
|
|
61
62
|
<TouchableOpacity
|
|
62
63
|
key={`Step ${index}`}
|
|
63
|
-
style={
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
style={[
|
|
65
|
+
styles.flex1,
|
|
66
|
+
{
|
|
67
|
+
alignItems,
|
|
68
|
+
marginRight,
|
|
69
|
+
},
|
|
70
|
+
]}
|
|
68
71
|
disabled={disabled || !onPress}
|
|
69
72
|
onPress={() => onPress && onPress(item, index)}
|
|
70
73
|
accessibilityLabel={`${accessibilityLabel}-touch-${index}`}>
|
|
71
74
|
<View
|
|
72
|
-
style={
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
style={[
|
|
76
|
+
styles.timeContainer,
|
|
77
|
+
{
|
|
78
|
+
minHeight: timeHeight,
|
|
79
|
+
},
|
|
80
|
+
]}>
|
|
76
81
|
{!!time && (
|
|
77
82
|
<Text
|
|
78
83
|
onLayout={onTimesLayout}
|
|
@@ -114,8 +119,8 @@ const StepsHorizontal: FC<StepsProps> = ({
|
|
|
114
119
|
const renderStepIcon = (
|
|
115
120
|
item: Step,
|
|
116
121
|
index: number,
|
|
117
|
-
|
|
118
|
-
|
|
122
|
+
stepAlign: string = 'center',
|
|
123
|
+
stepDisabled?: boolean
|
|
119
124
|
) => {
|
|
120
125
|
const {error} = item;
|
|
121
126
|
|
|
@@ -124,15 +129,18 @@ const StepsHorizontal: FC<StepsProps> = ({
|
|
|
124
129
|
index,
|
|
125
130
|
error,
|
|
126
131
|
steps.length,
|
|
127
|
-
|
|
132
|
+
stepDisabled
|
|
128
133
|
);
|
|
129
134
|
const {backgroundColor, borderColor, lineColorRight, lineColorLeft} =
|
|
130
135
|
stepStyle;
|
|
131
136
|
|
|
132
137
|
const lineLeftHide =
|
|
133
|
-
(
|
|
138
|
+
(stepAlign === 'stretch' && index === 0) || stepAlign === 'left';
|
|
134
139
|
const lineRightHide =
|
|
135
|
-
(
|
|
140
|
+
(stepAlign === 'stretch' && index === steps.length - 1) ||
|
|
141
|
+
stepAlign === 'right';
|
|
142
|
+
const iconMarginRight = !lineRightHide ? Spacing.XS : 0;
|
|
143
|
+
const iconMarginLeft = !lineLeftHide ? Spacing.XS : 0;
|
|
136
144
|
|
|
137
145
|
return (
|
|
138
146
|
<View style={styles.rowStep}>
|
|
@@ -150,11 +158,11 @@ const StepsHorizontal: FC<StepsProps> = ({
|
|
|
150
158
|
<StepIcon
|
|
151
159
|
size={size}
|
|
152
160
|
error={error}
|
|
153
|
-
backgroundColor={
|
|
154
|
-
borderColor={
|
|
161
|
+
backgroundColor={stepDisabled ? Colors.pink_08 : backgroundColor}
|
|
162
|
+
borderColor={stepDisabled ? Colors.pink_10 : borderColor}
|
|
155
163
|
style={{
|
|
156
|
-
marginRight:
|
|
157
|
-
marginLeft:
|
|
164
|
+
marginRight: iconMarginRight,
|
|
165
|
+
marginLeft: iconMarginLeft,
|
|
158
166
|
marginVertical: Spacing.XS,
|
|
159
167
|
}}
|
|
160
168
|
index={index}
|
|
@@ -178,7 +186,7 @@ const StepsHorizontal: FC<StepsProps> = ({
|
|
|
178
186
|
};
|
|
179
187
|
|
|
180
188
|
return (
|
|
181
|
-
<View style={
|
|
189
|
+
<View style={styles.row}>
|
|
182
190
|
{steps.map((item, index) => {
|
|
183
191
|
return renderStepItem(item, index);
|
|
184
192
|
})}
|
package/StepsVertical.tsx
CHANGED
|
@@ -29,10 +29,8 @@ const StepsVertical: FC<StepsProps> = ({
|
|
|
29
29
|
const typoStyle = GetStepTypo(activeIndex, index, error, size, 'vertical');
|
|
30
30
|
|
|
31
31
|
const { backgroundColor, borderColor } = stepStyle;
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
? theme.colors.primary + '33'
|
|
35
|
-
: theme.colors.border.default;
|
|
32
|
+
const { primary, border } = theme.colors;
|
|
33
|
+
const lineColor = activeIndex > index ? primary + '33' : border.default;
|
|
36
34
|
|
|
37
35
|
/**
|
|
38
36
|
* build description
|
|
@@ -55,21 +53,12 @@ const StepsVertical: FC<StepsProps> = ({
|
|
|
55
53
|
return (
|
|
56
54
|
<TouchableOpacity
|
|
57
55
|
key={`Step ${index}`}
|
|
58
|
-
style={
|
|
59
|
-
flexDirection: 'row',
|
|
60
|
-
marginBottom: Spacing.XS,
|
|
61
|
-
}}
|
|
56
|
+
style={styles.verticalItem}
|
|
62
57
|
disabled={disabled || !onPress}
|
|
63
58
|
onPress={() => onPress && onPress(item, index)}
|
|
64
59
|
accessibilityLabel={`${accessibilityLabel}-touch-${index}`}
|
|
65
60
|
>
|
|
66
|
-
<View
|
|
67
|
-
style={{
|
|
68
|
-
alignItems: 'center',
|
|
69
|
-
marginRight: Spacing.M,
|
|
70
|
-
minHeight: 48,
|
|
71
|
-
}}
|
|
72
|
-
>
|
|
61
|
+
<View style={styles.stepIconColumn}>
|
|
73
62
|
<StepIcon
|
|
74
63
|
size={size}
|
|
75
64
|
error={error}
|
|
@@ -88,16 +77,11 @@ const StepsVertical: FC<StepsProps> = ({
|
|
|
88
77
|
/>
|
|
89
78
|
)}
|
|
90
79
|
</View>
|
|
91
|
-
<View style={
|
|
92
|
-
<View
|
|
93
|
-
style={{
|
|
94
|
-
flexDirection: 'row',
|
|
95
|
-
justifyContent: 'space-between',
|
|
96
|
-
}}
|
|
97
|
-
>
|
|
80
|
+
<View style={styles.flex1}>
|
|
81
|
+
<View style={styles.titleRow}>
|
|
98
82
|
<Text
|
|
99
83
|
numberOfLines={2}
|
|
100
|
-
style={
|
|
84
|
+
style={styles.verticalTitle}
|
|
101
85
|
color={
|
|
102
86
|
disabled ? theme.colors.text.disable : typoStyle.title.color
|
|
103
87
|
}
|
|
@@ -122,7 +106,7 @@ const StepsVertical: FC<StepsProps> = ({
|
|
|
122
106
|
);
|
|
123
107
|
};
|
|
124
108
|
return (
|
|
125
|
-
<View style={
|
|
109
|
+
<View style={styles.fullWidth}>
|
|
126
110
|
{steps.map((item, index: number) => {
|
|
127
111
|
return renderStepItem(item, index);
|
|
128
112
|
})}
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
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.167.1-rc.2",
|
|
4
|
+
"private": false,
|
|
5
|
+
"main": "index.tsx",
|
|
6
|
+
"peerDependencies": {
|
|
7
|
+
"@momo-kits/foundation": "latest",
|
|
8
|
+
"react": "*",
|
|
9
|
+
"react-native": "*"
|
|
10
|
+
},
|
|
11
|
+
"license": "MoMo",
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"registry": "https://registry.npmjs.org/"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {}
|
|
16
|
+
}
|
package/styles.ts
CHANGED
|
@@ -44,4 +44,36 @@ export default StyleSheet.create({
|
|
|
44
44
|
borderRadius: Radius.L,
|
|
45
45
|
aspectRatio: 1,
|
|
46
46
|
},
|
|
47
|
+
row: {
|
|
48
|
+
flexDirection: 'row',
|
|
49
|
+
},
|
|
50
|
+
flex1: {
|
|
51
|
+
flex: 1,
|
|
52
|
+
},
|
|
53
|
+
fullWidth: {
|
|
54
|
+
width: '100%',
|
|
55
|
+
},
|
|
56
|
+
numberLabel: {
|
|
57
|
+
position: 'absolute',
|
|
58
|
+
},
|
|
59
|
+
timeContainer: {
|
|
60
|
+
justifyContent: 'flex-end',
|
|
61
|
+
},
|
|
62
|
+
verticalItem: {
|
|
63
|
+
flexDirection: 'row',
|
|
64
|
+
marginBottom: Spacing.XS,
|
|
65
|
+
},
|
|
66
|
+
stepIconColumn: {
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
marginRight: Spacing.M,
|
|
69
|
+
minHeight: 48,
|
|
70
|
+
},
|
|
71
|
+
titleRow: {
|
|
72
|
+
flexDirection: 'row',
|
|
73
|
+
justifyContent: 'space-between',
|
|
74
|
+
},
|
|
75
|
+
verticalTitle: {
|
|
76
|
+
marginRight: Spacing.S,
|
|
77
|
+
flex: 1,
|
|
78
|
+
},
|
|
47
79
|
});
|
package/utils.ts
CHANGED
|
@@ -34,23 +34,20 @@ const getTypoTitle = (
|
|
|
34
34
|
size?: 'small' | 'large',
|
|
35
35
|
stepType?: 'vertical' | 'horizontal'
|
|
36
36
|
): Typography => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
let defaultTypo: Typography = 'description_default_regular';
|
|
38
|
+
if (size && stepType === 'vertical') {
|
|
39
|
+
defaultTypo = 'body_default_regular';
|
|
40
|
+
}
|
|
41
|
+
const isCompact = checkSizeAndStepType(stepType, size);
|
|
41
42
|
|
|
42
43
|
switch (status) {
|
|
43
44
|
case 'current':
|
|
44
45
|
case 'error': {
|
|
45
|
-
return
|
|
46
|
-
? 'header_xs_semibold'
|
|
47
|
-
: 'header_s_semibold';
|
|
46
|
+
return isCompact ? 'header_xs_semibold' : 'header_s_semibold';
|
|
48
47
|
}
|
|
49
48
|
case 'incomplete':
|
|
50
49
|
case 'completed': {
|
|
51
|
-
return
|
|
52
|
-
? 'description_default_regular'
|
|
53
|
-
: 'body_default_regular';
|
|
50
|
+
return isCompact ? 'description_default_regular' : 'body_default_regular';
|
|
54
51
|
}
|
|
55
52
|
default: {
|
|
56
53
|
return defaultTypo;
|
|
@@ -74,9 +71,7 @@ export const GetStepTypo = (
|
|
|
74
71
|
};
|
|
75
72
|
let description: StepTypo = {
|
|
76
73
|
color: theme.colors.text.hint,
|
|
77
|
-
typography:
|
|
78
|
-
? 'description_xs_regular'
|
|
79
|
-
: 'description_default_regular',
|
|
74
|
+
typography: size ? 'description_xs_regular' : 'description_default_regular',
|
|
80
75
|
};
|
|
81
76
|
let time: StepTypo = {
|
|
82
77
|
color: theme.colors.text.hint,
|