@momo-kits/step 0.89.6 → 0.92.1-beta.3

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
1
  import React, {FC, useContext} from 'react';
2
- import {View} from 'react-native';
2
+ import {Text, TextStyle, View} from 'react-native';
3
3
  import {StepIconProps} from './types';
4
4
  import styles from './styles';
5
- import {ApplicationContext, Icon, Colors} from '@momo-kits/foundation';
5
+ import {ApplicationContext, Colors, Icon} from '@momo-kits/foundation';
6
6
 
7
7
  const StepIcon: FC<StepIconProps> = ({
8
8
  size = 'large',
@@ -10,20 +10,43 @@ const StepIcon: FC<StepIconProps> = ({
10
10
  borderColor,
11
11
  error,
12
12
  style,
13
+ useNumber,
14
+ index,
13
15
  }) => {
14
16
  const {theme} = useContext(ApplicationContext);
15
17
  let iconStyle = styles.stepIcon;
16
18
  let checkIconSize = 16;
17
19
  let iconSource = error ? 'navigation_close' : 'notifications_check';
20
+ let typography: TextStyle = {
21
+ ...styles.largeText,
22
+ fontFamily: `${theme.font}-Semibold`,
23
+ };
18
24
 
19
25
  if (size === 'small') {
20
26
  iconStyle = styles.stepIconSmall;
21
27
  checkIconSize = 12;
28
+ typography = {...styles.smallText, fontFamily: `${theme.font}-Medium`};
22
29
  }
23
30
  return (
24
31
  <View
25
32
  style={[iconStyle, styles.center, {backgroundColor, borderColor}, style]}>
26
- <Icon size={checkIconSize} color={Colors.black_01} source={iconSource} />
33
+ {useNumber ? (
34
+ <Text
35
+ style={[
36
+ typography,
37
+ {
38
+ color: Colors.black_01,
39
+ },
40
+ ]}>
41
+ {index + 1}
42
+ </Text>
43
+ ) : (
44
+ <Icon
45
+ size={checkIconSize}
46
+ color={Colors.black_01}
47
+ source={iconSource}
48
+ />
49
+ )}
27
50
  </View>
28
51
  );
29
52
  };
@@ -2,17 +2,27 @@ import React, {FC} from 'react';
2
2
  import {View} from 'react-native';
3
3
  import {Step, StepsProps} from './types';
4
4
  import StepIcon from './StepIcon';
5
- import {Spacing, Text} from '@momo-kits/foundation';
5
+ import {Spacing, Text, getAccessibilityID} from '@momo-kits/foundation';
6
6
  import {getStepColor, getStepTypo} from './utils';
7
7
  import styles from './styles';
8
8
 
9
- const StepsHorizontal: FC<StepsProps> = ({steps, size, activeIndex}) => {
9
+ const StepsHorizontal: FC<StepsProps> = ({
10
+ steps,
11
+ size,
12
+ activeIndex,
13
+ useNumber = false,
14
+ }) => {
10
15
  const renderStepItem = (i: Step, ii: number) => {
11
16
  const {title, description, error, time} = steps[ii];
12
17
  let typoStyle = getStepTypo(activeIndex, ii, error, size);
18
+ const {status} = getStepColor(activeIndex, ii, error, steps.length);
19
+ const accessibilityID = getAccessibilityID?.(`ic_step_${ii}_${status}`);
13
20
 
14
21
  return (
15
- <View key={`Step ${ii}`} style={{flex: 1, alignItems: 'center'}}>
22
+ <View
23
+ {...accessibilityID}
24
+ key={`Step ${ii}`}
25
+ style={{flex: 1, alignItems: 'center'}}>
16
26
  {!!time && (
17
27
  <Text
18
28
  style={styles.textCenter}
@@ -68,6 +78,8 @@ const StepsHorizontal: FC<StepsProps> = ({steps, size, activeIndex}) => {
68
78
  backgroundColor={backgroundColor}
69
79
  borderColor={borderColor}
70
80
  style={{marginHorizontal: Spacing.XS, marginVertical: Spacing.XS}}
81
+ index={ii}
82
+ useNumber={useNumber}
71
83
  />
72
84
  <View
73
85
  style={[
package/StepsVertical.tsx CHANGED
@@ -2,17 +2,30 @@ import React, {FC, useContext} from 'react';
2
2
  import {View} from 'react-native';
3
3
  import {Step, StepsProps} from './types';
4
4
  import {getStepColor, getStepTypo} from './utils';
5
- import {ApplicationContext, Spacing, Text} from '@momo-kits/foundation';
5
+ import {
6
+ ApplicationContext,
7
+ getAccessibilityID,
8
+ Spacing,
9
+ Text,
10
+ } from '@momo-kits/foundation';
6
11
  import styles from './styles';
7
12
  import StepIcon from './StepIcon';
8
13
 
9
- const StepsVertical: FC<StepsProps> = ({steps, activeIndex, size}) => {
14
+ const StepsVertical: FC<StepsProps> = ({
15
+ steps,
16
+ activeIndex,
17
+ size,
18
+ useNumber = false,
19
+ }) => {
10
20
  const {theme} = useContext(ApplicationContext);
21
+
11
22
  const renderStepItem = (i: Step, ii: number) => {
12
23
  const {error, description, title, time} = steps[ii];
13
24
 
14
25
  const stepStyle = getStepColor(activeIndex, ii, error, steps.length);
15
26
  let typoStyle = getStepTypo(activeIndex, ii, error, size);
27
+ const {status} = getStepColor(activeIndex, ii, error, steps.length);
28
+ const accessibilityID = getAccessibilityID?.(`ic_step_${ii}_${status}`);
16
29
 
17
30
  const {backgroundColor, borderColor} = stepStyle;
18
31
  const lineColor =
@@ -21,6 +34,7 @@ const StepsVertical: FC<StepsProps> = ({steps, activeIndex, size}) => {
21
34
  : theme.colors.background.default;
22
35
  return (
23
36
  <View
37
+ {...accessibilityID}
24
38
  key={`Step ${ii}`}
25
39
  style={{
26
40
  flexDirection: 'row',
@@ -37,6 +51,8 @@ const StepsVertical: FC<StepsProps> = ({steps, activeIndex, size}) => {
37
51
  error={error}
38
52
  backgroundColor={backgroundColor}
39
53
  borderColor={borderColor}
54
+ useNumber={useNumber}
55
+ index={ii}
40
56
  />
41
57
  {ii !== steps.length - 1 && (
42
58
  <View
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
- "name": "@momo-kits/step",
3
- "version": "0.89.6",
4
- "private": false,
5
- "main": "index.tsx",
6
- "dependencies": {},
7
- "peerDependencies": {
8
- "@momo-kits/foundation": "latest",
9
- "prop-types": "^15.7.2",
10
- "react": "16.9.0",
11
- "react-native": ">=0.55"
12
- },
13
- "devDependencies": {
14
- "@momo-platform/versions": "4.1.11"
15
- },
16
- "license": "MoMo"
2
+ "name": "@momo-kits/step",
3
+ "version": "0.92.1-beta.3",
4
+ "private": false,
5
+ "main": "index.tsx",
6
+ "dependencies": {},
7
+ "peerDependencies": {
8
+ "@momo-kits/foundation": "latest",
9
+ "prop-types": "^15.7.2",
10
+ "react": "16.9.0",
11
+ "react-native": ">=0.55"
12
+ },
13
+ "devDependencies": {
14
+ "@momo-platform/versions": "4.1.11"
15
+ },
16
+ "license": "MoMo"
17
17
  }
package/styles.ts CHANGED
@@ -1,18 +1,18 @@
1
1
  import {StyleSheet} from 'react-native';
2
- import {Colors, Radius, Spacing} from '@momo-kits/foundation';
2
+ import {Colors, Radius, scaleSize, Spacing} from '@momo-kits/foundation';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  stepIcon: {
6
- width: 24,
7
- height: 24,
6
+ width: scaleSize(24),
7
+ height: scaleSize(24),
8
8
  borderWidth: 2,
9
- borderRadius: Radius.M,
9
+ borderRadius: scaleSize(Radius.L),
10
10
  },
11
11
  stepIconSmall: {
12
- width: 16,
13
- height: 16,
12
+ width: scaleSize(16),
13
+ height: scaleSize(16),
14
14
  borderWidth: 2,
15
- borderRadius: Radius.S,
15
+ borderRadius: scaleSize(Radius.M),
16
16
  },
17
17
  lineHorizontal: {
18
18
  height: 2,
@@ -45,4 +45,12 @@ export default StyleSheet.create({
45
45
  textCenter: {
46
46
  textAlign: 'center',
47
47
  },
48
+ largeText: {
49
+ fontSize: scaleSize(12),
50
+ lineHeight: scaleSize(16),
51
+ },
52
+ smallText: {
53
+ fontSize: scaleSize(8),
54
+ lineHeight: scaleSize(12),
55
+ },
48
56
  });
package/types.ts CHANGED
@@ -28,6 +28,8 @@ export type StepsProps = {
28
28
  * starting from 0 for the first step.
29
29
  */
30
30
  activeIndex: number;
31
+
32
+ useNumber?: boolean;
31
33
  };
32
34
 
33
35
  /**
@@ -93,4 +95,8 @@ export type StepIconProps = {
93
95
  * Can be used to adjust the visual presentation or layout.
94
96
  */
95
97
  style?: ViewStyle;
98
+
99
+ useNumber?: boolean;
100
+
101
+ index: number;
96
102
  };
package/utils.ts CHANGED
@@ -122,5 +122,5 @@ export const getStepColor = (
122
122
  }
123
123
  }
124
124
 
125
- return {backgroundColor, borderColor, lineColorLeft, lineColorRight};
125
+ return {backgroundColor, borderColor, lineColorLeft, lineColorRight, status};
126
126
  };