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

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