@momo-kits/step 0.0.59-beta → 0.0.59-beta.1

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/Step.web.js CHANGED
@@ -1,302 +1,61 @@
1
1
  import React, { Component } from 'react';
2
- import { View, StyleSheet, Image } from 'react-native';
2
+
3
3
  import PropTypes from 'prop-types';
4
- import { ColorCore as Colors } from '../../core/colors/colorCore';
5
- import Text from '../../core/components/typography';
4
+ import HorizontalStep from './Step.horizontal.web.js';
5
+ import VerticalStep from './Step.vertical.web.js';
6
+ import Colors from '../../core/colors';
6
7
  import { Icons as IconSource } from '../../core/icons';
7
8
 
8
- const CIRCLE_SIZE = 24;
9
-
10
- const styles = StyleSheet.create({
11
- circle: {
12
- width: CIRCLE_SIZE,
13
- height: CIRCLE_SIZE,
14
- // borderWidth: 1,
15
- // borderColor: Colors.sepia_05,
16
- borderRadius: CIRCLE_SIZE / 2,
17
- backgroundColor: 'white'
18
- },
19
- line: {
20
- height: 4,
21
- backgroundColor: 'white',
22
- // borderWidth: 1,
23
- // borderRadius: 1,
24
- // borderStyle: 'dashed',
25
- zIndex: 0,
26
- // marginTop: 8
27
- },
28
- topRight: {
29
- position: 'absolute',
30
- right: -1,
31
- top: -1,
32
- width: 1,
33
- height: '100%',
34
- backgroundColor: 'white',
35
- zIndex: 1
36
- },
37
- topLeft: {
38
- position: 'absolute',
39
- left: -1,
40
- top: -1,
41
- width: '100%',
42
- height: 1,
43
- backgroundColor: 'white',
44
- zIndex: 1
45
- },
46
- topLeftWidth: {
47
- position: 'absolute',
48
- left: -1,
49
- top: -1,
50
- width: 1,
51
- height: '100%',
52
- backgroundColor: 'white',
53
- zIndex: 1
54
- },
55
- circleRow: {
56
- position: 'absolute',
57
- justifyContent: 'space-between',
58
- flexDirection: 'row',
59
- },
60
- circleColumn: {
61
- // position: 'absolute',
62
- justifyContent: 'space-between',
63
- },
64
- titleDefault: {
65
- color: Colors.black_12
66
- },
67
- titleActive: {
68
- color: Colors.black_17,
69
- fontWeight: 'bold'
70
- },
71
- containerStyle: {
72
- minHeight: CIRCLE_SIZE + 20 + CIRCLE_SIZE
73
- }
74
- });
75
-
76
9
  export default class Step extends Component {
77
10
  constructor(props) {
78
11
  super(props);
79
- this.state = {
80
- width: 0,
81
- height: 0
82
- };
83
- }
84
-
85
- onLayout = (e) => {
86
- this.setState({ width: e.nativeEvent.layout.width, height: e.nativeEvent.layout.height });
87
- }
88
-
89
- renderLine = () => {
90
- const {
91
- lineColor, lineStyle, currentStep, data
92
- } = this.props;
93
- return (
94
- <View style={[styles.line, { borderColor: lineColor }, lineStyle]}>
95
- {/* <View style={styles.topLeft} />
96
- <View style={styles.topLeftWidth} />
97
- <View style={styles.topRight} /> */}
98
- </View>
99
- );
100
- }
101
-
102
- circle = (value, index) => {
103
- const {
104
- currentStep, tintColor, data, lineStyle, isNumber, iconActive,
105
- iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
106
- } = this.props;
107
- const { width } = this.state;
108
- const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
109
- const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
110
- const itemWidth = (width - CIRCLE_SIZE) / data?.length;
111
- const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
112
- const lineWidth = (width - CIRCLE_SIZE) / (data.length - 1);
113
- const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
114
- let left = 0;
115
- let textAlignStyle = { textAlign: 'center' };
116
- /**
117
- * item lefr
118
- */
119
- if (index === 0) {
120
- left = 0;
121
- textAlignStyle = { textAlign: 'left' };
122
-
123
- /**
124
- * item right
125
- */
126
- } else if (index === data?.length - 1) {
127
- left = -itemWidth + CIRCLE_SIZE;
128
- textAlignStyle = { textAlign: 'right' };
129
- /**
130
- * center item
131
- */
132
- } else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
133
- const textStyle = [textAlignStyle, textFontStyle];
134
-
135
- return (
136
- <View key={index}>
137
- {
138
- data?.length - 1 !== index && (
139
- <View style={[styles.line, {
140
- position: 'absolute',
141
- top: 10,
142
- backgroundColor: lineActive,
143
- width: lineWidth,
144
- height: 4,
145
- marginTop: 0
146
- }, lineStyle]}
147
- />
148
- )
149
- }
150
- {
151
- isNumber ? (
152
- <View style={{
153
- width: CIRCLE_SIZE,
154
- height: CIRCLE_SIZE,
155
- borderRadius: CIRCLE_SIZE / 2,
156
- backgroundColor: backgroundActive,
157
- borderColor: Colors.pink_09,
158
- borderWidth: 1,
159
- alignItems: 'center',
160
- justifyContent: 'center'
161
- }}
162
- >
163
- <Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
164
- </View>
165
- ) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
166
- }
167
-
168
- <View style={{
169
- position: 'absolute',
170
- width: itemWidth,
171
- left,
172
- top: CIRCLE_SIZE + CIRCLE_SIZE / 4
173
- }}
174
- >
175
- <Text.Caption style={[textStyle, bodyStyle]}>{value}</Text.Caption>
176
- </View>
177
- </View>
178
- );
179
- }
180
-
181
- circleColumn = (value, index) => {
182
- const {
183
- currentStep, tintColor, data, lineStyle, isNumber, iconActive,
184
- iconInActive, lineColorActive, lineColorInActive, bodyStyle, iconStyle
185
- } = this.props;
186
- const { height } = this.state;
187
- const icon = currentStep >= (index + 1) ? iconActive || IconSource.ic_step_active : iconInActive || IconSource.ic_step_coming;
188
- const textFontStyle = currentStep >= (index + 1) ? styles.titleActive : styles.titleDefault;
189
- const itemWidth = (height - CIRCLE_SIZE) / data?.length;
190
- const lineActive = currentStep >= (index + 1) ? lineColorActive || isNumber ? Colors.pink_09 : Colors.sepia_05 : lineColorInActive || Colors.black_02;
191
- const lineWidth = (height - CIRCLE_SIZE) / (data.length - 1);
192
- const backgroundActive = currentStep >= (index + 1) ? Colors.pink_05_b : Colors.black_09;
193
- let left = 0;
194
- let textAlignStyle = { textAlign: 'center' };
195
- /**
196
- * item lefr
197
- */
198
- if (index === 0) {
199
- left = 0;
200
- textAlignStyle = { textAlign: 'left' };
201
-
202
- /**
203
- * item right
204
- */
205
- } else if (index === data?.length - 1) {
206
- left = -itemWidth + CIRCLE_SIZE;
207
- textAlignStyle = { textAlign: 'right' };
208
- /**
209
- * center item
210
- */
211
- } else { left = -itemWidth / 2 + CIRCLE_SIZE / 2; }
212
- const textStyle = [textAlignStyle, textFontStyle];
213
-
214
- return (
215
- <View key={index}>
216
- <View style={{ flexDirection: 'row', alignItems: 'center' }}>
217
- {
218
- isNumber ? (
219
- <View style={{
220
- width: CIRCLE_SIZE,
221
- height: CIRCLE_SIZE,
222
- borderRadius: CIRCLE_SIZE / 2,
223
- backgroundColor: backgroundActive,
224
- borderColor: Colors.pink_09,
225
- borderWidth: 1,
226
- alignItems: 'center',
227
- justifyContent: 'center'
228
- }}
229
- >
230
- {
231
- iconActive ? <Image source={iconActive} style={[styles.circle, { tintColor }, iconStyle]} /> : <Text.SubTitle style={{ color: 'white' }} weight="bold">{index + 1}</Text.SubTitle>
232
- }
233
- </View>
234
- ) : <Image source={icon} style={[styles.circle, { tintColor }, iconStyle]} />
235
- }
236
- <Text.Caption style={[{ marginLeft: 10 }, textStyle, bodyStyle]}>{value}</Text.Caption>
237
- </View>
238
-
239
- {
240
- data?.length - 1 !== index && (
241
- <View style={[styles.line, {
242
- left: 10,
243
- backgroundColor: lineActive,
244
- width: 4,
245
- height: lineWidth,
246
- marginTop: 0,
247
- }, lineStyle]}
248
- />
249
- )
250
- }
251
-
252
- </View>
253
- );
254
- }
255
-
256
- renderCircle = () => {
257
- const { data = [], isVertical } = this.props;
258
- return data.map(isVertical ? this.circleColumn : this.circle);
259
12
  }
260
13
 
261
14
  render() {
262
- const { width, height } = this.state;
263
- const { style, isVertical } = this.props;
264
- return (
265
- <View style={[styles.containerStyle, style]} onLayout={this.onLayout}>
266
- {/* {this.renderLine()} */}
267
- {
268
- isVertical ? (
269
- <View style={[styles.circleColumn, { height }]}>
270
- {this.renderCircle()}
271
- </View>
272
- ) : (
273
- <View style={[styles.circleRow, { width }]}>
274
- {this.renderCircle()}
275
- </View>
276
- )
277
- }
278
-
279
- </View>
280
- );
15
+ const { isVertical } = this.props;
16
+ let DefaultComponent = HorizontalStep;
17
+ if (isVertical) {
18
+ DefaultComponent = VerticalStep;
19
+ }
20
+ return <DefaultComponent {...this.props} />;
281
21
  }
282
22
  }
283
23
 
284
24
  Step.propTypes = {
285
- data: PropTypes.arrayOf(PropTypes.string),
25
+ titles: PropTypes.array,
286
26
  currentStep: PropTypes.number,
287
- tintColor: PropTypes.string,
288
27
  style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
289
- isNumber: PropTypes.bool,
28
+ items: PropTypes.array,
290
29
  isVertical: PropTypes.bool,
291
30
  iconActive: PropTypes.any,
292
- iconInActive: PropTypes.any,
31
+ iconChecked: PropTypes.any,
32
+ iconUnchecked: PropTypes.any,
33
+ circleColorActive: PropTypes.string,
34
+ circleColorChecked: PropTypes.string,
35
+ circleColorUnchecked: PropTypes.string,
36
+ circleBorderColorActive: PropTypes.string,
37
+ circleBorderColorChecked: PropTypes.string,
38
+ circleBorderColorUnchecked: PropTypes.string,
293
39
  lineColorActive: PropTypes.string,
294
40
  lineColorInActive: PropTypes.string,
295
- bodyStyle: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
41
+ titleStyle: PropTypes.object,
42
+ descriptionStyle: PropTypes.object,
43
+ dateStyle: PropTypes.object,
296
44
  };
297
45
 
298
46
  Step.defaultProps = {
299
- data: [],
47
+ titles: [],
300
48
  currentStep: 0,
301
- tintColor: Colors.sepia_05
302
- };
49
+ isVertical: false,
50
+ iconActive: 'index + 1',
51
+ iconChecked: IconSource.ic_check_24,
52
+ iconUnchecked: 'index + 1',
53
+ circleColorActive: '#d82d8b',
54
+ circleColorChecked: '#ffadd2',
55
+ circleColorUnchecked: Colors.black_06,
56
+ circleBorderColorActive: Colors.pink_09,
57
+ circleBorderColorChecked: Colors.pink_09,
58
+ circleBorderColorUnchecked: Colors.black_04,
59
+ lineColorActive: '#ffd6e7',
60
+ lineColorInActive: Colors.black_04,
61
+ };
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
- "name": "@momo-kits/step",
3
- "version": "0.0.59-beta",
4
- "private": false,
5
- "main": "index.js",
6
- "dependencies": {},
7
- "peerDependencies": {
8
- "react-native": ">=0.55",
9
- "prop-types": "^15.7.2",
10
- "react": "16.9.0",
11
- "@momo-kits/core": ">=0.0.5-beta"
12
- },
13
- "devDependencies": {},
14
- "license": "MoMo"
2
+ "name": "@momo-kits/step",
3
+ "version": "0.0.59-beta.1",
4
+ "private": false,
5
+ "main": "index.js",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "react-native": ">=0.55",
9
+ "prop-types": "^15.7.2",
10
+ "react": "16.9.0",
11
+ "@momo-kits/core": ">=0.0.5-beta"
12
+ },
13
+ "devDependencies": {},
14
+ "license": "MoMo"
15
15
  }
package/publish.sh CHANGED
@@ -21,7 +21,7 @@ rsync -r --verbose --exclude '*.mdx' --exclude '*Demo.js' --exclude 'props-type
21
21
  #npm login
22
22
  #publish dist to npm
23
23
  cd dist
24
- npm publish --access=public
24
+ npm publish --tag beta --access=public
25
25
  cd ..
26
26
  rm -rf dist
27
27