@momo-kits/step 0.103.1 → 0.103.2-rc.10

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
@@ -1,8 +1,8 @@
1
+ import {Colors, Icon, Text} from '@momo-kits/foundation';
1
2
  import React, {FC} from 'react';
2
3
  import {View} from 'react-native';
3
- import {StepIconProps} from './types';
4
4
  import styles from './styles';
5
- import {Colors, Icon, Text} from '@momo-kits/foundation';
5
+ import {StepIconProps} from './types';
6
6
 
7
7
  const StepIcon: FC<StepIconProps> = ({
8
8
  size = 'large',
@@ -12,34 +12,62 @@ const StepIcon: FC<StepIconProps> = ({
12
12
  style,
13
13
  useNumber,
14
14
  index,
15
+ isActive,
16
+ customIcon,
15
17
  }) => {
16
18
  let iconStyle = styles.stepIcon;
17
19
  let checkIconSize = 16;
18
- let iconSource = error ? 'navigation_close' : 'notifications_check';
20
+ let contentIconSize = 8;
19
21
 
20
22
  if (size === 'small') {
21
23
  iconStyle = styles.stepIconSmall;
22
24
  checkIconSize = 12;
25
+ contentIconSize = 6;
23
26
  }
24
- return (
25
- <View
26
- style={[iconStyle, styles.center, {backgroundColor, borderColor}, style]}>
27
- {useNumber ? (
27
+
28
+ let iconSource = error ? 'navigation_close' : 'notifications_check';
29
+
30
+ const renderIcon = () => {
31
+ // useNumber is true, render number
32
+ if (useNumber) {
33
+ return (
28
34
  <Text
29
- style={{
30
- position: 'absolute',
31
- }}
35
+ style={{position: 'absolute'}}
32
36
  typography={'header_xs_semibold'}
33
37
  color={Colors.black_01}>
34
38
  {index + 1}
35
39
  </Text>
36
- ) : (
37
- <Icon
38
- size={checkIconSize}
39
- color={Colors.black_01}
40
- source={iconSource}
40
+ );
41
+ }
42
+
43
+ if (isActive) {
44
+ // customIcon is true, render customIcon
45
+ if (customIcon) {
46
+ return (
47
+ <Icon
48
+ size={checkIconSize}
49
+ color={Colors.black_01}
50
+ source={customIcon}
51
+ />
52
+ );
53
+ }
54
+ // render default Icon
55
+ return (
56
+ <View
57
+ style={[styles.currIcon, {width: contentIconSize, aspectRatio: 1}]}
41
58
  />
42
- )}
59
+ );
60
+ }
61
+
62
+ return (
63
+ <Icon size={checkIconSize} color={Colors.black_01} source={iconSource} />
64
+ );
65
+ };
66
+
67
+ return (
68
+ <View
69
+ style={[iconStyle, styles.center, {backgroundColor, borderColor}, style]}>
70
+ {renderIcon()}
43
71
  </View>
44
72
  );
45
73
  };
@@ -1,10 +1,10 @@
1
- import React, {FC} from 'react';
2
- import {FlexAlignType, View} from 'react-native';
3
- import {Step, StepsProps} from './types';
1
+ import {ApplicationContext, Colors, Spacing, Text} from '@momo-kits/foundation';
2
+ import React, {FC, useContext} from 'react';
3
+ import {FlexAlignType, TouchableOpacity, View} from 'react-native';
4
4
  import StepIcon from './StepIcon';
5
- import {Spacing, Text} from '@momo-kits/foundation';
6
- import {getStepColor, getStepTypo} from './utils';
7
5
  import styles from './styles';
6
+ import {Step, StepsProps} from './types';
7
+ import {getStepColor, getStepTypo} from './utils';
8
8
 
9
9
  type TextAlign = 'left' | 'right' | 'center';
10
10
 
@@ -14,10 +14,14 @@ const StepsHorizontal: FC<StepsProps> = ({
14
14
  activeIndex,
15
15
  useNumber = false,
16
16
  align = 'center',
17
+ customIcon,
18
+ onPress,
19
+ disabled,
17
20
  }) => {
18
21
  const renderStepItem = (i: Step, ii: number) => {
19
22
  const {title, description, error, time} = steps[ii];
20
23
  let typoStyle = getStepTypo(activeIndex, ii, error, size);
24
+ const {theme} = useContext(ApplicationContext);
21
25
  let alignItems: FlexAlignType = 'center';
22
26
  let textAlign: TextAlign = 'center';
23
27
 
@@ -41,17 +45,19 @@ const StepsHorizontal: FC<StepsProps> = ({
41
45
  ii !== steps.length - 1 && align !== 'center' && align !== 'stretch';
42
46
 
43
47
  return (
44
- <View
48
+ <TouchableOpacity
45
49
  key={`Step ${ii}`}
46
50
  style={{
47
51
  flex: 1,
48
52
  alignItems,
49
53
  marginRight: haveMarginRight ? Spacing.XS : 0,
50
- }}>
54
+ }}
55
+ disabled={disabled || !onPress}
56
+ onPress={onPress}>
51
57
  {!!time && (
52
58
  <Text
53
59
  style={{textAlign}}
54
- color={typoStyle.time.color}
60
+ color={disabled ? theme.colors.text.disable : typoStyle.time.color}
55
61
  typography={typoStyle.time.typography}>
56
62
  {time}
57
63
  </Text>
@@ -60,7 +66,7 @@ const StepsHorizontal: FC<StepsProps> = ({
60
66
  {!!title && (
61
67
  <Text
62
68
  style={[styles.title, {textAlign}]}
63
- color={typoStyle.title.color}
69
+ color={disabled ? theme.colors.text.disable : typoStyle.title.color}
64
70
  typography={typoStyle.title.typography}>
65
71
  {title}
66
72
  </Text>
@@ -68,16 +74,23 @@ const StepsHorizontal: FC<StepsProps> = ({
68
74
  {!!description && (
69
75
  <Text
70
76
  style={{textAlign}}
71
- color={typoStyle.description.color}
77
+ color={
78
+ disabled ? theme.colors.text.disable : typoStyle.description.color
79
+ }
72
80
  typography={typoStyle.description.typography}>
73
81
  {description}
74
82
  </Text>
75
83
  )}
76
- </View>
84
+ </TouchableOpacity>
77
85
  );
78
86
  };
79
87
 
80
- const renderStepIcon = (i: Step, ii: number, align: string = 'center') => {
88
+ const renderStepIcon = (
89
+ i: Step,
90
+ ii: number,
91
+ align: string = 'center',
92
+ disabled: boolean
93
+ ) => {
81
94
  const {error} = steps[ii];
82
95
 
83
96
  const stepStyle = getStepColor(activeIndex, ii, error, steps.length);
@@ -104,8 +117,8 @@ const StepsHorizontal: FC<StepsProps> = ({
104
117
  <StepIcon
105
118
  size={size}
106
119
  error={error}
107
- backgroundColor={backgroundColor}
108
- borderColor={borderColor}
120
+ backgroundColor={disabled ? Colors.pink_08 : backgroundColor}
121
+ borderColor={disabled ? Colors.pink_10 : borderColor}
109
122
  style={{
110
123
  marginRight: !lineRightHide ? Spacing.XS : 0,
111
124
  marginLeft: !lineLeftHide ? Spacing.XS : 0,
@@ -113,6 +126,8 @@ const StepsHorizontal: FC<StepsProps> = ({
113
126
  }}
114
127
  index={ii}
115
128
  useNumber={useNumber}
129
+ isActive={activeIndex === ii}
130
+ customIcon={customIcon}
116
131
  />
117
132
  {!lineRightHide && (
118
133
  <View
package/StepsVertical.tsx CHANGED
@@ -1,10 +1,10 @@
1
+ import {ApplicationContext, Spacing, Text} from '@momo-kits/foundation';
1
2
  import React, {FC, useContext} from 'react';
2
3
  import {View} from 'react-native';
4
+ import StepIcon from './StepIcon';
5
+ import styles from './styles';
3
6
  import {Step, StepsProps} from './types';
4
7
  import {getStepColor, getStepTypo} from './utils';
5
- import {ApplicationContext, Spacing, Text} from '@momo-kits/foundation';
6
- import styles from './styles';
7
- import StepIcon from './StepIcon';
8
8
 
9
9
  const StepsVertical: FC<StepsProps> = ({
10
10
  steps,
@@ -45,6 +45,7 @@ const StepsVertical: FC<StepsProps> = ({
45
45
  borderColor={borderColor}
46
46
  useNumber={useNumber}
47
47
  index={ii}
48
+ isActive={activeIndex === ii}
48
49
  />
49
50
  {ii !== steps.length - 1 && (
50
51
  <View
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/step",
3
- "version": "0.103.1",
3
+ "version": "0.103.2-rc.10",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "dependencies": {},
@@ -14,4 +14,4 @@
14
14
  "@momo-platform/versions": "4.1.11"
15
15
  },
16
16
  "license": "MoMo"
17
- }
17
+ }
package/publish.sh CHANGED
@@ -7,15 +7,15 @@ rsync -r --exclude=/dist ./* dist
7
7
  cd dist
8
8
 
9
9
  if [ "$1" == "stable" ]; then
10
- #npm version $(npm view @momo-kits/step@stable version)
11
- #npm version patch
10
+ npm version $(npm view @momo-kits/foundation@stable version)
11
+ npm version patch
12
12
  npm publish --tag stable --access=public
13
13
  elif [ "$1" == "latest" ]; then
14
- #npm version $(npm view @momo-kits/foundation@latest version)
14
+ npm version $(npm view @momo-kits/foundation@latest version)
15
15
  npm publish --tag latest --access=public
16
16
  else
17
- #npm version $(npm view @momo-kits/step@beta version)
18
- #npm version prerelease --preid=beta
17
+ npm version $(npm view @momo-kits/step@beta version)
18
+ npm version prerelease --preid=beta
19
19
  npm publish --tag beta --access=public
20
20
  fi
21
21
 
package/styles.ts CHANGED
@@ -1,6 +1,5 @@
1
- import {StyleSheet} from 'react-native';
2
1
  import {Radius, scaleSize, Spacing} from '@momo-kits/foundation';
3
-
2
+ import {StyleSheet} from 'react-native';
4
3
  export default StyleSheet.create({
5
4
  stepIcon: {
6
5
  width: 24,
@@ -53,4 +52,9 @@ export default StyleSheet.create({
53
52
  fontSize: scaleSize(8),
54
53
  lineHeight: scaleSize(12),
55
54
  },
55
+ currIcon: {
56
+ backgroundColor: 'white',
57
+ borderRadius: Radius.L,
58
+ aspectRatio: 1,
59
+ },
56
60
  });
package/types.ts CHANGED
@@ -32,6 +32,12 @@ export type StepsProps = {
32
32
  useNumber?: boolean;
33
33
 
34
34
  align?: 'left' | 'right' | 'center' | 'stretch';
35
+
36
+ customIcon?: string;
37
+
38
+ onPress?: () => void;
39
+
40
+ disabled?: boolean;
35
41
  };
36
42
 
37
43
  /**
@@ -101,4 +107,21 @@ export type StepIconProps = {
101
107
  useNumber?: boolean;
102
108
 
103
109
  index: number;
110
+
111
+ isActive?: boolean;
112
+
113
+ /**
114
+ * Optional. Custom active icon
115
+ */
116
+ customIcon?: string;
117
+ };
118
+
119
+ export type ProgressInfoProps = {
120
+ steps: Step[];
121
+ horizontal?: boolean;
122
+ size?: 'small' | 'large';
123
+ useNumber?: boolean;
124
+ align?: 'left' | 'right' | 'center' | 'stretch' | undefined;
125
+ showDescription?: boolean;
126
+ customIcon?: string;
104
127
  };
package/utils.ts CHANGED
@@ -1,7 +1,7 @@
1
- import {useContext} from 'react';
2
1
  import {ApplicationContext, Colors, Typography} from '@momo-kits/foundation';
2
+ import {useContext} from 'react';
3
3
 
4
- type StepStatus = 'inactive' | 'active' | 'completed' | 'error';
4
+ type StepStatus = 'incomplete' | 'current' | 'completed' | 'error';
5
5
  type StepTypo = {
6
6
  typography: Typography;
7
7
  color: string;
@@ -11,7 +11,7 @@ export const getStepTypo = (
11
11
  activeIndex: number,
12
12
  currentIndex: number,
13
13
  error?: boolean,
14
- size?: 'small' | 'large',
14
+ size?: 'small' | 'large'
15
15
  ) => {
16
16
  const {theme} = useContext(ApplicationContext);
17
17
 
@@ -28,27 +28,26 @@ export const getStepTypo = (
28
28
  typography: 'description_xs_regular',
29
29
  };
30
30
 
31
- let status: StepStatus = 'inactive';
31
+ let status: StepStatus = 'incomplete';
32
32
  if (activeIndex > currentIndex) {
33
33
  status = 'completed';
34
34
  }
35
35
  if (activeIndex === currentIndex) {
36
- status = 'active';
36
+ status = 'current';
37
37
  }
38
38
  if (error) {
39
39
  status = 'error';
40
40
  }
41
41
 
42
42
  switch (status) {
43
- case 'active': {
43
+ case 'current': {
44
+ title.color = theme.colors.primary;
44
45
  title.typography = 'header_xs_semibold';
45
46
  break;
46
47
  }
47
48
 
48
49
  case 'completed': {
49
- title.color = theme.colors.text.disable;
50
- description.color = theme.colors.text.disable;
51
- time.color = theme.colors.text.disable;
50
+ title.typography = 'header_xs_semibold';
52
51
  break;
53
52
  }
54
53
 
@@ -70,7 +69,7 @@ export const getStepColor = (
70
69
  activeIndex: number,
71
70
  currentIndex: number,
72
71
  error?: boolean,
73
- length: number = 1,
72
+ length: number = 1
74
73
  ) => {
75
74
  const {theme} = useContext(ApplicationContext);
76
75
  const DEFAULT_LINE_COLOR = theme.colors.background.default;
@@ -80,7 +79,7 @@ export const getStepColor = (
80
79
  let borderColor = theme.colors.border.default;
81
80
  let lineColorLeft = DEFAULT_LINE_COLOR;
82
81
  let lineColorRight = DEFAULT_LINE_COLOR;
83
- let status: StepStatus = 'inactive';
82
+ let status: StepStatus = 'incomplete';
84
83
 
85
84
  if (activeIndex > currentIndex) {
86
85
  status = 'completed';
@@ -88,7 +87,7 @@ export const getStepColor = (
88
87
  lineColorRight = COMPLETED_LINE_COLOR;
89
88
  }
90
89
  if (activeIndex === currentIndex) {
91
- status = 'active';
90
+ status = 'current';
92
91
  lineColorLeft = COMPLETED_LINE_COLOR;
93
92
  }
94
93
  if (error) {
@@ -103,15 +102,15 @@ export const getStepColor = (
103
102
  }
104
103
 
105
104
  switch (status) {
106
- case 'active': {
105
+ case 'current': {
107
106
  backgroundColor = theme.colors.primary;
108
107
  borderColor = theme.colors.background.tonal;
109
108
  break;
110
109
  }
111
110
 
112
111
  case 'completed': {
113
- backgroundColor = theme.colors.primary + '33';
114
- borderColor = theme.colors.background.selected;
112
+ backgroundColor = theme.colors.primary;
113
+ borderColor = theme.colors.background.tonal;
115
114
  break;
116
115
  }
117
116