@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 CHANGED
@@ -43,7 +43,7 @@ const StepIcon: FC<StepIconProps> = ({
43
43
  if (useNumber) {
44
44
  return (
45
45
  <Text
46
- style={{position: 'absolute'}}
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, aspectRatio: 1}]}
68
+ style={[styles.currIcon, {width: contentIconSize}]}
69
69
  />
70
70
  );
71
71
  }
@@ -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
- flex: 1,
65
- alignItems,
66
- marginRight: haveMarginRight ? Spacing.XS : 0,
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
- minHeight: timeHeight,
74
- justifyContent: 'flex-end',
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
- align: string = 'center',
118
- disabled?: boolean
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
- disabled
132
+ stepDisabled
128
133
  );
129
134
  const {backgroundColor, borderColor, lineColorRight, lineColorLeft} =
130
135
  stepStyle;
131
136
 
132
137
  const lineLeftHide =
133
- (align === 'stretch' && index === 0) || align === 'left';
138
+ (stepAlign === 'stretch' && index === 0) || stepAlign === 'left';
134
139
  const lineRightHide =
135
- (align === 'stretch' && index === steps.length - 1) || align === 'right';
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={disabled ? Colors.pink_08 : backgroundColor}
154
- borderColor={disabled ? Colors.pink_10 : borderColor}
161
+ backgroundColor={stepDisabled ? Colors.pink_08 : backgroundColor}
162
+ borderColor={stepDisabled ? Colors.pink_10 : borderColor}
155
163
  style={{
156
- marginRight: !lineRightHide ? Spacing.XS : 0,
157
- marginLeft: !lineLeftHide ? Spacing.XS : 0,
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={{flexDirection: 'row'}}>
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 lineColor =
33
- activeIndex > index
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={{ flex: 1 }}>
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={{ marginRight: Spacing.S, flex: 1 }}
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={{ width: '100%' }}>
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
- "name": "@momo-kits/step",
3
- "version": "0.167.1-duotest.1",
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
- }
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
- const defaultTypo =
38
- !!size && stepType === 'vertical'
39
- ? 'body_default_regular'
40
- : 'description_default_regular';
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 checkSizeAndStepType(stepType, size)
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 checkSizeAndStepType(stepType, size)
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: !!size
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,