@momo-kits/step 0.0.52-beta → 0.0.53-beta

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.
Files changed (3) hide show
  1. package/Step.js +165 -33
  2. package/package.json +1 -1
  3. package/publish.sh +1 -1
package/Step.js CHANGED
@@ -6,25 +6,25 @@ import {
6
6
  Colors, Text, IconSource, Image
7
7
  } from '@momo-kits/core';
8
8
 
9
- const CIRCLE_SIZE = 18;
9
+ const CIRCLE_SIZE = 24;
10
10
 
11
11
  const styles = StyleSheet.create({
12
12
  circle: {
13
13
  width: CIRCLE_SIZE,
14
14
  height: CIRCLE_SIZE,
15
- borderWidth: 1,
16
- borderColor: Colors.sepia_05,
17
- borderRadius: 9,
15
+ // borderWidth: 1,
16
+ // borderColor: Colors.sepia_05,
17
+ borderRadius: CIRCLE_SIZE / 2,
18
18
  backgroundColor: 'white'
19
19
  },
20
20
  line: {
21
- height: 1,
21
+ height: 4,
22
22
  backgroundColor: 'white',
23
- borderWidth: 1,
24
- borderRadius: 1,
25
- borderStyle: 'dashed',
23
+ // borderWidth: 1,
24
+ // borderRadius: 1,
25
+ // borderStyle: 'dashed',
26
26
  zIndex: 0,
27
- marginTop: 9
27
+ // marginTop: 8
28
28
  },
29
29
  topRight: {
30
30
  position: 'absolute',
@@ -58,6 +58,10 @@ const styles = StyleSheet.create({
58
58
  justifyContent: 'space-between',
59
59
  flexDirection: 'row',
60
60
  },
61
+ circleColumn: {
62
+ // position: 'absolute',
63
+ justifyContent: 'space-between',
64
+ },
61
65
  titleDefault: {
62
66
  color: Colors.black_12
63
67
  },
@@ -74,31 +78,40 @@ export default class Step extends Component {
74
78
  constructor(props) {
75
79
  super(props);
76
80
  this.state = {
77
- width: 0
81
+ width: 0,
82
+ height: 0
78
83
  };
79
84
  }
80
85
 
81
86
  onLayout = (e) => {
82
- this.setState({ width: e.nativeEvent.layout.width });
87
+ this.setState({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height });
83
88
  }
84
89
 
85
90
  renderLine = () => {
86
- const { lineColor } = this.props;
91
+ const {
92
+ lineColor, lineStyle, currentStep, data
93
+ } = this.props;
87
94
  return (
88
- <View style={[styles.line, { borderColor: lineColor }]}>
89
- <View style={styles.topLeft} />
95
+ <View style={[styles.line, { borderColor: lineColor }, lineStyle]}>
96
+ {/* <View style={styles.topLeft} />
90
97
  <View style={styles.topLeftWidth} />
91
- <View style={styles.topRight} />
98
+ <View style={styles.topRight} /> */}
92
99
  </View>
93
100
  );
94
101
  }
95
102
 
96
103
  circle = (value, index) => {
97
- const { currentStep, tintColor, data } = this.props;
104
+ const {
105
+ currentStep, tintColor, data, lineStyle, isNumber, iconActive,
106
+ iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
107
+ } = this.props;
98
108
  const { width } = this.state;
99
- const icon = currentStep >= (index + 1) ? IconSource.ic_step_active : IconSource.ic_step_coming;
109
+ const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
100
110
  const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
101
111
  const itemWidth = (width - CIRCLE_SIZE) / data?.length;
112
+ const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
113
+ const lineWidth = (width - CIRCLE_SIZE) / (data.length - 1);
114
+ const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
102
115
  let left = 0;
103
116
  let textAlignStyle = { textAlign: 'center' };
104
117
  /**
@@ -119,53 +132,172 @@ export default class Step extends Component {
119
132
  */
120
133
  } else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
121
134
  const textStyle = [textAlignStyle, textFontStyle];
135
+
122
136
  return (
123
- <View>
124
- <Image source={icon} style={[styles.circle, { tintColor }]} />
137
+ <View key={index}>
138
+ {
139
+ data?.length - 1 !== index && (
140
+ <View style={[styles.line, {
141
+ position: 'absolute',
142
+ top: 10,
143
+ backgroundColor: lineActive,
144
+ width: lineWidth,
145
+ height: 4,
146
+ marginTop: 0
147
+ }, lineStyle]}
148
+ />
149
+ )
150
+ }
151
+ {
152
+ isNumber ? (
153
+ <View style={{
154
+ width: CIRCLE_SIZE,
155
+ height: CIRCLE_SIZE,
156
+ borderRadius: CIRCLE_SIZE / 2,
157
+ backgroundColor: backgroundActive,
158
+ borderColor: Colors.pink_09,
159
+ borderWidth: 1,
160
+ alignItems: 'center',
161
+ justifyContent: 'center'
162
+ }}
163
+ >
164
+ <Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
165
+ </View>
166
+ ) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
167
+ }
168
+
125
169
  <View style={{
126
170
  position: 'absolute',
127
171
  width: itemWidth,
128
172
  left,
129
- top: CIRCLE_SIZE + CIRCLE_SIZE / 2
173
+ top: CIRCLE_SIZE + CIRCLE_SIZE / 4
130
174
  }}
131
175
  >
132
- <Text.Title style={textStyle}>{value}</Text.Title>
176
+ <Text.Caption style={[textStyle, bodyStyle]}>{value}</Text.Caption>
133
177
  </View>
134
178
  </View>
135
179
  );
136
180
  }
137
181
 
182
+ circleColumn = (value, index) => {
183
+ const {
184
+ currentStep, tintColor, data, lineStyle, isNumber, iconActive,
185
+ iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
186
+ } = this.props;
187
+ const { height } = this.state;
188
+ const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
189
+ const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
190
+ const itemWidth = (height - CIRCLE_SIZE) / data?.length;
191
+ const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
192
+ const lineWidth = (height - CIRCLE_SIZE) / (data.length - 1);
193
+ const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
194
+ let left = 0;
195
+ let textAlignStyle = { textAlign: 'center' };
196
+ /**
197
+ * item lefr
198
+ */
199
+ if (index === 0) {
200
+ left = 0;
201
+ textAlignStyle = { textAlign: 'left' };
202
+
203
+ /**
204
+ * item right
205
+ */
206
+ } else if (index === data?.length - 1) {
207
+ left = -itemWidth + CIRCLE_SIZE;
208
+ textAlignStyle = { textAlign: 'right' };
209
+ /**
210
+ * center item
211
+ */
212
+ } else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
213
+ const textStyle = [textAlignStyle, textFontStyle];
214
+
215
+ return (
216
+ <View key={index}>
217
+ <View style={{ flexDirection: 'row', alignItems: 'center' }}>
218
+ {
219
+ isNumber ? (
220
+ <View style={{
221
+ width: CIRCLE_SIZE,
222
+ height: CIRCLE_SIZE,
223
+ borderRadius: CIRCLE_SIZE / 2,
224
+ backgroundColor: backgroundActive,
225
+ borderColor: Colors.pink_09,
226
+ borderWidth: 1,
227
+ alignItems: 'center',
228
+ justifyContent: 'center'
229
+ }}
230
+ >
231
+ {
232
+ iconActive ? <Image source={iconActive} style={[styles.circle, { tintColor }, iconStyle]} /> : <Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
233
+ }
234
+ </View>
235
+ ) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
236
+ }
237
+ <Text.Caption style={[{ marginLeft: 10 }, textStyle, bodyStyle]}>{value}</Text.Caption>
238
+ </View>
239
+
240
+ {
241
+ data?.length - 1 !== index && (
242
+ <View style={[styles.line, {
243
+ left: 10,
244
+ backgroundColor: lineActive,
245
+ width: 4,
246
+ height: lineWidth,
247
+ marginTop: 0,
248
+ }, lineStyle]}
249
+ />
250
+ )
251
+ }
252
+
253
+ </View>
254
+ );
255
+ }
256
+
138
257
  renderCircle = () => {
139
- const { data = [] } = this.props;
140
- const views = data.map(this.circle);
141
- return views;
258
+ const { data = [], isVertical } = this.props;
259
+ return data.map(isVertical ? this.circleColumn : this.circle);
142
260
  }
143
261
 
144
262
  render() {
145
- const { width } = this.state;
146
- const { style } = this.props;
263
+ const { width, height } = this.state;
264
+ const { style, isVertical } = this.props;
147
265
  return (
148
266
  <View style={[styles.containerStyle, style]} onLayout={this.onLayout}>
149
- {this.renderLine()}
150
- <View style={[styles.circleRow, { width }]}>
151
- {this.renderCircle()}
152
- </View>
267
+ {/* {this.renderLine()} */}
268
+ {
269
+ isVertical ? (
270
+ <View style={[styles.circleColumn, { height }]}>
271
+ {this.renderCircle()}
272
+ </View>
273
+ ) : (
274
+ <View style={[styles.circleRow, { width }]}>
275
+ {this.renderCircle()}
276
+ </View>
277
+ )
278
+ }
279
+
153
280
  </View>
154
281
  );
155
282
  }
156
283
  }
157
284
 
158
285
  Step.propTypes = {
159
- lineColor: PropTypes.string,
160
286
  data: PropTypes.arrayOf(PropTypes.string),
161
287
  currentStep: PropTypes.number,
162
288
  tintColor: PropTypes.string,
163
289
  style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
290
+ isNumber: PropTypes.bool,
291
+ isVertical: PropTypes.bool,
292
+ iconActive: PropTypes.any,
293
+ iconInActive: PropTypes.any,
294
+ lineColorActive: PropTypes.string,
295
+ lineColorInActive: PropTypes.string,
296
+ bodyStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
164
297
  };
165
298
 
166
299
  Step.defaultProps = {
167
300
  data: [],
168
- lineColor: Colors.sepia_05,
169
301
  currentStep: 0,
170
302
  tintColor: Colors.sepia_05
171
- };
303
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/step",
3
- "version": "0.0.52-beta",
3
+ "version": "0.0.53-beta",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "dependencies": {},
package/publish.sh CHANGED
@@ -26,4 +26,4 @@ cd ..
26
26
  rm -rf dist
27
27
 
28
28
 
29
- # -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/step new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/step"}'
29
+ curl -X POST -H 'Content-Type: application/json' 'https://chat.googleapis.com/v1/spaces/AAAAbP8987c/messages?key=AIzaSyDdI0hCZtE6vySjMm-WEfRq3CPzqKqqsHI&token=UGSFRvk_oYb9uGsAgs31bVvMm6jDkmD8zihGm3eyaQA%3D&threadKey=JoaXTEYaNNkl' -d '{"text": "@momo-kits/step new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/step"}'