@momo-kits/step 0.0.43-beta.23 → 0.0.43-beta.24

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.
@@ -0,0 +1,260 @@
1
+ import React, { Component } from 'react';
2
+ import { View, StyleSheet, Dimensions } from 'react-native';
3
+
4
+ import PropTypes, { string } from 'prop-types';
5
+ import { Colors, Text, IconSource, Image, Icon } from '@momo-kits/core';
6
+ import { getUrlByTime } from '../../core/components/image/utils';
7
+ import { ScrollView } from 'react-native-gesture-handler';
8
+ import { transform } from 'lodash';
9
+
10
+ const CIRCLE_SIZE = 24;
11
+ const SCREEN_WIDTH = Dimensions.get('window').width;
12
+
13
+ // this is layout of each item (flexdirection row)
14
+ // this is left container (flex 0.2, )
15
+ // this is value label
16
+ // this is image
17
+ // this is caption label
18
+ // this is desc label
19
+ // this is right container (flex 0.8)
20
+ // this is line (width flex = 1 or width 100 percent)
21
+
22
+ const styles = StyleSheet.create({
23
+ circle: {
24
+ width: CIRCLE_SIZE,
25
+ height: CIRCLE_SIZE,
26
+ borderRadius: CIRCLE_SIZE / 2,
27
+ borderWidth: 2,
28
+ padding: 4,
29
+ },
30
+ checkedCircle: {
31
+ width: CIRCLE_SIZE,
32
+ height: CIRCLE_SIZE,
33
+ borderRadius: CIRCLE_SIZE / 2,
34
+ backgroundColor: '#ffadd2',
35
+ borderWidth: 2,
36
+ borderColor: Colors.pink_09,
37
+ },
38
+ titleDefault: {
39
+ color: Colors.black_12,
40
+ fontWeight: 'normal',
41
+ },
42
+ titleActive: {
43
+ color: Colors.black_17,
44
+ fontWeight: 'bold',
45
+ },
46
+ containerStyle: {
47
+ minHeight: CIRCLE_SIZE + 20 + CIRCLE_SIZE,
48
+ },
49
+ description: {
50
+ fontSize: 12,
51
+ color: Colors.black_12,
52
+ marginBottom: 16,
53
+ paddingTop: 4,
54
+ paddingLeft: 11,
55
+ },
56
+ date: {
57
+ fontSize: 10,
58
+ color: Colors.black_12,
59
+ },
60
+ number: {
61
+ fontSize: 12,
62
+ color: 'white',
63
+ textAlign: 'center',
64
+ lineHeight: 13,
65
+ },
66
+ lineHorizontal: {
67
+ height: 2,
68
+ marginTop: 26,
69
+ width: '100%',
70
+ },
71
+ minHeight: {
72
+ minHeight: 12,
73
+ marginBottom: 4,
74
+ },
75
+ });
76
+
77
+ export default class HorizontalStep extends Component {
78
+ constructor(props) {
79
+ super(props);
80
+ this.state = {
81
+ width: 0,
82
+ height: 0,
83
+ };
84
+ }
85
+
86
+ onLayout = (e) => {
87
+ this.setState({
88
+ width: e.nativeEvent.layout.width,
89
+ height: e.nativeEvent.layout.height,
90
+ });
91
+ };
92
+
93
+ circleStep = (index) => {
94
+ return (
95
+ <View style={[styles.circle]}>
96
+ <Text style={styles.number}>{index}</Text>
97
+ </View>
98
+ );
99
+ };
100
+
101
+ circleColumn = (value, index) => {
102
+ const {
103
+ currentStep,
104
+ titles,
105
+ iconActive,
106
+ iconInActive,
107
+ lineColorActive,
108
+ lineColorInActive,
109
+ items,
110
+ currentStepColor,
111
+ date,
112
+ isVertical,
113
+ titleFontSize,
114
+ } = this.props;
115
+ const icon =
116
+ currentStep >= index + 2
117
+ ? iconActive || IconSource.ic_check_24
118
+ : iconInActive || index + 1;
119
+ var circleColor =
120
+ currentStep >= index + 1 ? currentStepColor : Colors.black_06;
121
+ var circleBorderColor =
122
+ currentStep >= index + 1 ? Colors.pink_09 : Colors.black_04;
123
+ const textFontStyle =
124
+ currentStep === index + 1
125
+ ? styles.titleActive
126
+ : styles.titleDefault;
127
+ const lineActive =
128
+ currentStep >= index + 2
129
+ ? lineColorActive
130
+ ? Colors.pink_09
131
+ : '#ffd6e7'
132
+ : lineColorInActive || Colors.black_04;
133
+ const minHeight = !isVertical && styles.minHeight;
134
+ const lineWidth = Math.round(
135
+ (SCREEN_WIDTH - 10 - CIRCLE_SIZE - 4) / titles.length,
136
+ );
137
+ const lineRight = parseInt(`-${lineWidth / 2 - 10}`);
138
+ return (
139
+ <View
140
+ key={index}
141
+ style={{
142
+ flexDirection: 'row',
143
+ flex: 1,
144
+ justifyContent: 'center',
145
+ }}>
146
+ <View
147
+ style={{
148
+ flexDirection: 'column',
149
+ alignItems: 'center',
150
+ }}>
151
+ {currentStep >= index + 1 ? (
152
+ <Text style={[styles.date, { marginBottom: 4 }]}>
153
+ {date}
154
+ </Text>
155
+ ) : (
156
+ <View style={minHeight}></View>
157
+ )}
158
+ {currentStep <= index + 1 ? (
159
+ <View>
160
+ {/* image */}
161
+ <View
162
+ style={[
163
+ styles.circle,
164
+ {
165
+ backgroundColor: circleColor,
166
+ borderColor: circleBorderColor,
167
+ },
168
+ ]}>
169
+ <Text style={styles.number}>{icon}</Text>
170
+ </View>
171
+ </View>
172
+ ) : (
173
+ <View>
174
+ <Image
175
+ source={icon}
176
+ style={[
177
+ styles.checkedCircle,
178
+ { tintColor: '#ffd6e7' },
179
+ ]}
180
+ />
181
+ </View>
182
+ )}
183
+ <View>
184
+ <Text.Caption
185
+ style={[
186
+ { marginTop: 4, fontSize: titleFontSize },
187
+ textFontStyle,
188
+ ]}>
189
+ {value}
190
+ </Text.Caption>
191
+ </View>
192
+
193
+ <View>
194
+ <Text style={[{ fontSize: 10 }]}>{items[index]}</Text>
195
+ </View>
196
+ </View>
197
+ {titles?.length - 1 !== index && (
198
+ <View
199
+ style={{
200
+ position: 'absolute',
201
+ right: lineRight,
202
+ width: lineWidth,
203
+ zIndex: -1,
204
+ }}>
205
+ <View
206
+ style={[
207
+ styles.lineHorizontal,
208
+ {
209
+ backgroundColor: lineActive,
210
+ },
211
+ ]}
212
+ />
213
+ </View>
214
+ )}
215
+ </View>
216
+ );
217
+ };
218
+
219
+ renderCircle = () => {
220
+ const { titles = [[]] } = this.props;
221
+ return titles.map(this.circleColumn);
222
+ };
223
+
224
+ render() {
225
+ const { style = {} } = this.props;
226
+ return (
227
+ <ScrollView>
228
+ <View
229
+ style={[styles.containerStyle, style]}
230
+ onLayout={this.onLayout}>
231
+ <View
232
+ style={{
233
+ flexDirection: 'row',
234
+ }}>
235
+ {this.renderCircle()}
236
+ </View>
237
+ </View>
238
+ </ScrollView>
239
+ );
240
+ }
241
+ }
242
+
243
+ HorizontalStep.propTypes = {
244
+ titles: PropTypes.array,
245
+ currentStep: PropTypes.number,
246
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
247
+ items: PropTypes.array,
248
+ isVertical: PropTypes.bool,
249
+ iconActive: PropTypes.any,
250
+ iconInActive: PropTypes.any,
251
+ lineColorActive: PropTypes.string,
252
+ lineColorInActive: PropTypes.string,
253
+ borderColorActive: PropTypes.string,
254
+ borderColorInActive: PropTypes.string,
255
+ };
256
+
257
+ HorizontalStep.defaultProps = {
258
+ titles: [],
259
+ currentStep: 0,
260
+ };
package/Step.js CHANGED
@@ -1,226 +1,20 @@
1
1
  import React, { Component } from 'react';
2
- import { View, StyleSheet } from 'react-native';
3
-
4
2
  import PropTypes from 'prop-types';
5
- import { Colors, Text, IconSource, Image } from '@momo-kits/core';
6
- import { ScrollView } from 'react-native-gesture-handler';
7
-
8
- const CIRCLE_SIZE = 24;
9
-
10
- const styles = StyleSheet.create({
11
- circle: {
12
- width: CIRCLE_SIZE,
13
- height: CIRCLE_SIZE,
14
- borderRadius: CIRCLE_SIZE / 2,
15
- borderWidth: 2,
16
- padding: 4,
17
- },
18
- checkedCircle: {
19
- width: CIRCLE_SIZE,
20
- height: CIRCLE_SIZE,
21
- borderRadius: CIRCLE_SIZE / 2,
22
- backgroundColor: '#ffadd2',
23
- borderWidth: 2,
24
- borderColor: Colors.pink_09,
25
- },
26
- titleDefault: {
27
- color: Colors.black_12,
28
- fontSize: 14,
29
- fontWeight: 'normal',
30
- },
31
- titleActive: {
32
- color: Colors.black_17,
33
- fontSize: 14,
34
- fontWeight: 'bold',
35
- },
36
- containerStyle: {
37
- minHeight: CIRCLE_SIZE + 20 + CIRCLE_SIZE,
38
- },
39
- description: {
40
- fontSize: 12,
41
- color: Colors.black_12,
42
- paddingBottom: 16,
43
- paddingTop: 4,
44
- paddingLeft: 11,
45
- },
46
- date: {
47
- fontSize: 10,
48
- color: Colors.black_12,
49
- },
50
- number: {
51
- fontSize: 12,
52
- color: 'white',
53
- textAlign: 'center',
54
- lineHeight: 13,
55
- },
56
- });
3
+ import HorizontalStep from './Step.horizontal';
4
+ import VerticalStep from './Step.vertical';
57
5
 
58
6
  export default class Step extends Component {
59
7
  constructor(props) {
60
8
  super(props);
61
- this.state = {
62
- width: 0,
63
- height: 0,
64
- };
65
9
  }
66
10
 
67
- onLayout = (e) => {
68
- this.setState({
69
- width: e.nativeEvent.layout.width,
70
- height: e.nativeEvent.layout.height,
71
- });
72
- };
73
-
74
- circleStep = (index) => {
75
- return (
76
- <View style={[styles.circle]}>
77
- <Text style={styles.number}>{index}</Text>
78
- </View>
79
- );
80
- };
81
-
82
- circleColumn = (value, index) => {
83
- const {
84
- currentStep,
85
- titles,
86
- lineStyle,
87
- iconActive,
88
- iconInActive,
89
- lineColorActive,
90
- lineColorInActive,
91
- items,
92
- currentStepColor,
93
- date,
94
- } = this.props;
95
- const { height } = this.state;
96
- let itemHeight = 0;
97
- const icon =
98
- currentStep >= index + 2
99
- ? iconActive || IconSource.ic_check_24
100
- : iconInActive || index + 1;
101
- var circleColor =
102
- currentStep >= index + 1 ? currentStepColor : Colors.black_06;
103
- var circleBorderColor =
104
- currentStep >= index + 1 ? Colors.pink_09 : Colors.black_04;
105
- const textFontStyle =
106
- currentStep === index + 1
107
- ? styles.titleActive
108
- : styles.titleDefault;
109
- const itemWidth = (height - CIRCLE_SIZE) / titles?.length;
110
- const lineActive =
111
- currentStep >= index + 2
112
- ? lineColorActive
113
- ? Colors.pink_09
114
- : '#ffd6e7'
115
- : lineColorInActive || Colors.black_04;
116
- console.log(typeof items[index]);
117
- return (
118
- <View
119
- onLayout={(event) => {
120
- const viewHeight = event.nativeEvent.layout.height;
121
- itemHeight = viewHeight;
122
- console.log({ itemHeight });
123
- }}
124
- key={index}
125
- style={{ flexDirection: 'row' }}>
126
- <View>
127
- {currentStep <= index + 1 ? (
128
- <View
129
- style={[
130
- styles.circle,
131
- {
132
- backgroundColor: circleColor,
133
- borderColor: circleBorderColor,
134
- },
135
- ]}>
136
- <Text style={styles.number}>{icon}</Text>
137
- </View>
138
- ) : (
139
- <View>
140
- <Image
141
- source={icon}
142
- style={[
143
- styles.checkedCircle,
144
- { tintColor: '#ffd6e7' },
145
- ]}
146
- />
147
- </View>
148
- )}
149
- {titles?.length - 1 !== index && (
150
- <View
151
- style={[
152
- styles.line,
153
- {
154
- left: 11,
155
- backgroundColor: lineActive,
156
- width: 2,
157
- minHeight: 10,
158
- marginTop: 4,
159
- marginBottom: 4,
160
- flex: 1,
161
- },
162
- lineStyle,
163
- ]}
164
- />
165
- )}
166
- </View>
167
- <View
168
- style={[{ width: '100%', paddingRight: 48, marginTop: 4 }]}>
169
- <View
170
- style={{
171
- flexDirection: 'row',
172
- justifyContent: 'space-between',
173
- alignItems: 'center',
174
- }}>
175
- <Text.Caption
176
- style={[{ marginLeft: 10 }, textFontStyle]}>
177
- {value}
178
- </Text.Caption>
179
- {currentStep >= index + 1 && (
180
- <Text style={styles.date}>{date}</Text>
181
- )}
182
- </View>
183
- <View>
184
- {typeof items[index] == 'string' ? (
185
- <Text style={[styles.description]}>
186
- {items[index]}
187
- </Text>
188
- ) : (
189
- <View style={[styles.description]}>
190
- {items[index]}
191
- </View>
192
- )}
193
- </View>
194
- </View>
195
- </View>
196
- );
197
- };
198
-
199
- renderCircle = () => {
200
- const { titles = [[]] } = this.props;
201
- return titles.map(this.circleColumn);
202
- };
203
-
204
11
  render() {
205
- const { width, height } = this.state;
206
- const { style, isVertical } = this.props;
207
- return (
208
- <ScrollView>
209
- <View
210
- style={[styles.containerStyle, style]}
211
- onLayout={this.onLayout}>
212
- {isVertical ? (
213
- <View style={[styles.circleColumn, { height }]}>
214
- {this.renderCircle()}
215
- </View>
216
- ) : (
217
- <View style={[styles.circleRow, { width }]}>
218
- {this.renderCircle()}
219
- </View>
220
- )}
221
- </View>
222
- </ScrollView>
223
- );
12
+ const { isVertical } = this.props;
13
+ let DefaultComponent = HorizontalStep;
14
+ if (isVertical) {
15
+ DefaultComponent = VerticalStep;
16
+ }
17
+ return <DefaultComponent {...this.props} />;
224
18
  }
225
19
  }
226
20
 
@@ -0,0 +1,244 @@
1
+ import React, { Component } from 'react';
2
+ import { View, StyleSheet, Dimensions } from 'react-native';
3
+
4
+ import PropTypes, { string } from 'prop-types';
5
+ import { Colors, Text, IconSource, Image, Icon } from '@momo-kits/core';
6
+ import { getUrlByTime } from '../../core/components/image/utils';
7
+ import { ScrollView } from 'react-native-gesture-handler';
8
+ import { transform } from 'lodash';
9
+
10
+ const CIRCLE_SIZE = 24;
11
+
12
+ // this is layout of each item (flexdirection row)
13
+ // this is left container (flex 0.2, )
14
+ // this is value label
15
+ // this is image
16
+ // this is caption label
17
+ // this is desc label
18
+ // this is right container (flex 0.8)
19
+ // this is line (width flex = 1 or width 100 percent)
20
+
21
+ const styles = StyleSheet.create({
22
+ circle: {
23
+ width: CIRCLE_SIZE,
24
+ height: CIRCLE_SIZE,
25
+ borderRadius: CIRCLE_SIZE / 2,
26
+ borderWidth: 2,
27
+ padding: 4,
28
+ },
29
+ checkedCircle: {
30
+ width: CIRCLE_SIZE,
31
+ height: CIRCLE_SIZE,
32
+ borderRadius: CIRCLE_SIZE / 2,
33
+ backgroundColor: '#ffadd2',
34
+ borderWidth: 2,
35
+ borderColor: Colors.pink_09,
36
+ },
37
+ titleDefault: {
38
+ color: Colors.black_12,
39
+ fontSize: 14,
40
+ fontWeight: 'normal',
41
+ },
42
+ titleActive: {
43
+ color: Colors.black_17,
44
+ fontSize: 14,
45
+ fontWeight: 'bold',
46
+ },
47
+ containerStyle: {
48
+ minHeight: CIRCLE_SIZE + 20 + CIRCLE_SIZE,
49
+ },
50
+ description: {
51
+ fontSize: 12,
52
+ color: Colors.black_12,
53
+ marginBottom: 16,
54
+ paddingTop: 4,
55
+ paddingLeft: 11,
56
+ },
57
+ date: {
58
+ fontSize: 10,
59
+ color: Colors.black_12,
60
+ },
61
+ number: {
62
+ fontSize: 12,
63
+ color: 'white',
64
+ textAlign: 'center',
65
+ lineHeight: 13,
66
+ },
67
+ lineVertical: {
68
+ marginLeft: 11,
69
+ width: 2,
70
+ minHeight: 10,
71
+ marginTop: 4,
72
+ marginBottom: 4,
73
+ flex: 1,
74
+ },
75
+ minHeight: {
76
+ minHeight: 12,
77
+ marginBottom: 4,
78
+ },
79
+ });
80
+
81
+ export default class VerticalStep extends Component {
82
+ constructor(props) {
83
+ super(props);
84
+ this.state = {
85
+ width: 0,
86
+ height: 0,
87
+ };
88
+ }
89
+
90
+ onLayout = (e) => {
91
+ this.setState({
92
+ width: e.nativeEvent.layout.width,
93
+ height: e.nativeEvent.layout.height,
94
+ });
95
+ };
96
+
97
+ circleStep = (index) => {
98
+ return (
99
+ <View style={[styles.circle]}>
100
+ <Text style={styles.number}>{index}</Text>
101
+ </View>
102
+ );
103
+ };
104
+
105
+ circleColumn = (value, index) => {
106
+ const {
107
+ currentStep,
108
+ titles,
109
+ lineStyle,
110
+ iconActive,
111
+ iconInActive,
112
+ lineColorActive,
113
+ lineColorInActive,
114
+ items,
115
+ currentStepColor,
116
+ date,
117
+ isVertical,
118
+ } = this.props;
119
+ const icon =
120
+ currentStep >= index + 2
121
+ ? iconActive || IconSource.ic_check_24
122
+ : iconInActive || index + 1;
123
+ var circleColor =
124
+ currentStep >= index + 1 ? currentStepColor : Colors.black_06;
125
+ var circleBorderColor =
126
+ currentStep >= index + 1 ? Colors.pink_09 : Colors.black_04;
127
+ const textFontStyle =
128
+ currentStep === index + 1
129
+ ? styles.titleActive
130
+ : styles.titleDefault;
131
+ const lineActive =
132
+ currentStep >= index + 2
133
+ ? lineColorActive
134
+ ? Colors.pink_09
135
+ : '#ffd6e7'
136
+ : lineColorInActive || Colors.black_04;
137
+ return (
138
+ <View key={index} style={{ flexDirection: 'row' }}>
139
+ <View>
140
+ {currentStep <= index + 1 ? (
141
+ <View>
142
+ {/* image */}
143
+ <View
144
+ style={[
145
+ styles.circle,
146
+ {
147
+ backgroundColor: circleColor,
148
+ borderColor: circleBorderColor,
149
+ },
150
+ ]}>
151
+ <Text style={styles.number}>{icon}</Text>
152
+ </View>
153
+ </View>
154
+ ) : (
155
+ <View>
156
+ <Image
157
+ source={icon}
158
+ style={[
159
+ styles.checkedCircle,
160
+ { tintColor: '#ffd6e7' },
161
+ ]}
162
+ />
163
+ </View>
164
+ )}
165
+ {titles?.length - 1 !== index && (
166
+ <View
167
+ style={[
168
+ styles.lineVertical,
169
+ {
170
+ backgroundColor: lineActive,
171
+ },
172
+ lineStyle,
173
+ ]}
174
+ />
175
+ )}
176
+ </View>
177
+ <View
178
+ style={[{ width: '100%', paddingRight: 48, marginTop: 4 }]}>
179
+ <View
180
+ style={{
181
+ flexDirection: 'row',
182
+ justifyContent: 'space-between',
183
+ alignItems: 'center',
184
+ }}>
185
+ <Text.Caption
186
+ style={[{ marginLeft: 10 }, textFontStyle]}>
187
+ {value}
188
+ </Text.Caption>
189
+ {currentStep >= index + 1 && (
190
+ <Text style={styles.date}>{date}</Text>
191
+ )}
192
+ </View>
193
+ <View>
194
+ {typeof items[index] == 'string' ? (
195
+ <Text style={[styles.description]}>
196
+ {items[index]}
197
+ </Text>
198
+ ) : (
199
+ <View style={[styles.description]}>
200
+ {items[index]}
201
+ </View>
202
+ )}
203
+ </View>
204
+ </View>
205
+ </View>
206
+ );
207
+ };
208
+
209
+ renderCircle = () => {
210
+ const { titles = [[]] } = this.props;
211
+ return titles.map(this.circleColumn);
212
+ };
213
+
214
+ render() {
215
+ return (
216
+ <ScrollView>
217
+ <View style={[styles.containerStyle]} onLayout={this.onLayout}>
218
+ <View style={[styles.circleColumn]}>
219
+ {this.renderCircle()}
220
+ </View>
221
+ </View>
222
+ </ScrollView>
223
+ );
224
+ }
225
+ }
226
+
227
+ VerticalStep.propTypes = {
228
+ titles: PropTypes.array,
229
+ currentStep: PropTypes.number,
230
+ style: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
231
+ items: PropTypes.array,
232
+ isVertical: PropTypes.bool,
233
+ iconActive: PropTypes.any,
234
+ iconInActive: PropTypes.any,
235
+ lineColorActive: PropTypes.string,
236
+ lineColorInActive: PropTypes.string,
237
+ borderColorActive: PropTypes.string,
238
+ borderColorInActive: PropTypes.string,
239
+ };
240
+
241
+ VerticalStep.defaultProps = {
242
+ titles: [],
243
+ currentStep: 0,
244
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/step",
3
- "version": "0.0.43-beta.23",
3
+ "version": "0.0.43-beta.24",
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
- #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"}'
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"}'