@momo-kits/step 0.73.3-beta.5 → 0.74.2-react-native.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/StepIcon.tsx +31 -0
- package/StepsHorizontal.tsx +94 -0
- package/StepsVertical.tsx +89 -0
- package/index.tsx +20 -0
- package/package.json +11 -9
- package/publish.sh +1 -1
- package/styles.ts +48 -0
- package/types.ts +96 -0
- package/utils.ts +126 -0
- package/Step.horizontal.js +0 -279
- package/Step.horizontal.web.js +0 -299
- package/Step.js +0 -52
- package/Step.vertical.js +0 -313
- package/Step.vertical.web.js +0 -325
- package/Step.web.js +0 -51
- package/index.js +0 -3
package/StepIcon.tsx
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {StepIconProps} from './types';
|
|
4
|
+
import styles from './styles';
|
|
5
|
+
import {ApplicationContext, Icon, Colors} from '@momo-kits/foundation';
|
|
6
|
+
|
|
7
|
+
const StepIcon: FC<StepIconProps> = ({
|
|
8
|
+
size = 'large',
|
|
9
|
+
backgroundColor,
|
|
10
|
+
borderColor,
|
|
11
|
+
error,
|
|
12
|
+
style,
|
|
13
|
+
}) => {
|
|
14
|
+
const {theme} = useContext(ApplicationContext);
|
|
15
|
+
let iconStyle = styles.stepIcon;
|
|
16
|
+
let checkIconSize = 16;
|
|
17
|
+
let iconSource = error ? 'navigation_close' : 'notifications_check';
|
|
18
|
+
|
|
19
|
+
if (size === 'small') {
|
|
20
|
+
iconStyle = styles.stepIconSmall;
|
|
21
|
+
checkIconSize = 12;
|
|
22
|
+
}
|
|
23
|
+
return (
|
|
24
|
+
<View
|
|
25
|
+
style={[iconStyle, styles.center, {backgroundColor, borderColor}, style]}>
|
|
26
|
+
<Icon size={checkIconSize} color={Colors.black_01} source={iconSource} />
|
|
27
|
+
</View>
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export default StepIcon;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {Step, StepsProps} from './types';
|
|
4
|
+
import StepIcon from './StepIcon';
|
|
5
|
+
import {Spacing, Text} from '@momo-kits/foundation';
|
|
6
|
+
import {getStepColor, getStepTypo} from './utils';
|
|
7
|
+
import styles from './styles';
|
|
8
|
+
|
|
9
|
+
const StepsHorizontal: FC<StepsProps> = ({steps, size, activeIndex}) => {
|
|
10
|
+
const renderStepItem = (i: Step, ii: number) => {
|
|
11
|
+
const {title, description, error, time} = steps[ii];
|
|
12
|
+
let typoStyle = getStepTypo(activeIndex, ii, error, size);
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<View key={`Step ${ii}`} style={{flex: 1, alignItems: 'center'}}>
|
|
16
|
+
{!!time && (
|
|
17
|
+
<Text
|
|
18
|
+
style={styles.textCenter}
|
|
19
|
+
color={typoStyle.time.color}
|
|
20
|
+
typography={typoStyle.time.typography}>
|
|
21
|
+
{time}
|
|
22
|
+
</Text>
|
|
23
|
+
)}
|
|
24
|
+
{renderStepIcon(i, ii)}
|
|
25
|
+
{!!title && (
|
|
26
|
+
<Text
|
|
27
|
+
style={[styles.title, styles.textCenter]}
|
|
28
|
+
color={typoStyle.title.color}
|
|
29
|
+
typography={typoStyle.title.typography}>
|
|
30
|
+
{title}
|
|
31
|
+
</Text>
|
|
32
|
+
)}
|
|
33
|
+
{!!description && (
|
|
34
|
+
<Text
|
|
35
|
+
style={styles.textCenter}
|
|
36
|
+
color={typoStyle.description.color}
|
|
37
|
+
typography={typoStyle.description.typography}>
|
|
38
|
+
{description}
|
|
39
|
+
</Text>
|
|
40
|
+
)}
|
|
41
|
+
</View>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const renderStepIcon = (i: Step, ii: number) => {
|
|
46
|
+
const {error} = steps[ii];
|
|
47
|
+
|
|
48
|
+
const stepStyle = getStepColor(activeIndex, ii, error, steps.length);
|
|
49
|
+
const {backgroundColor, borderColor, lineColorRight, lineColorLeft} =
|
|
50
|
+
stepStyle;
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<View style={styles.rowStep}>
|
|
54
|
+
{
|
|
55
|
+
<View
|
|
56
|
+
style={[
|
|
57
|
+
styles.lineHorizontal,
|
|
58
|
+
styles.radiusRight,
|
|
59
|
+
{
|
|
60
|
+
backgroundColor: lineColorLeft,
|
|
61
|
+
},
|
|
62
|
+
]}
|
|
63
|
+
/>
|
|
64
|
+
}
|
|
65
|
+
<StepIcon
|
|
66
|
+
size={size}
|
|
67
|
+
error={error}
|
|
68
|
+
backgroundColor={backgroundColor}
|
|
69
|
+
borderColor={borderColor}
|
|
70
|
+
style={{marginHorizontal: Spacing.XS, marginVertical: Spacing.XS}}
|
|
71
|
+
/>
|
|
72
|
+
<View
|
|
73
|
+
style={[
|
|
74
|
+
styles.lineHorizontal,
|
|
75
|
+
styles.radiusLeft,
|
|
76
|
+
{
|
|
77
|
+
backgroundColor: lineColorRight,
|
|
78
|
+
},
|
|
79
|
+
]}
|
|
80
|
+
/>
|
|
81
|
+
</View>
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<View style={{flexDirection: 'row'}}>
|
|
87
|
+
{steps.map((i, ii) => {
|
|
88
|
+
return renderStepItem(i, ii);
|
|
89
|
+
})}
|
|
90
|
+
</View>
|
|
91
|
+
);
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
export default StepsHorizontal;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React, {FC, useContext} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {Step, StepsProps} from './types';
|
|
4
|
+
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
|
+
|
|
9
|
+
const StepsVertical: FC<StepsProps> = ({steps, activeIndex, size}) => {
|
|
10
|
+
const {theme} = useContext(ApplicationContext);
|
|
11
|
+
const renderStepItem = (i: Step, ii: number) => {
|
|
12
|
+
const {error, description, title, time} = steps[ii];
|
|
13
|
+
|
|
14
|
+
const stepStyle = getStepColor(activeIndex, ii, error, steps.length);
|
|
15
|
+
let typoStyle = getStepTypo(activeIndex, ii, error, size);
|
|
16
|
+
|
|
17
|
+
const {backgroundColor, borderColor} = stepStyle;
|
|
18
|
+
const lineColor =
|
|
19
|
+
activeIndex > ii
|
|
20
|
+
? theme.colors.primary + '33'
|
|
21
|
+
: theme.colors.background.default;
|
|
22
|
+
return (
|
|
23
|
+
<View
|
|
24
|
+
key={`Step ${ii}`}
|
|
25
|
+
style={{
|
|
26
|
+
flexDirection: 'row',
|
|
27
|
+
marginBottom: Spacing.XS,
|
|
28
|
+
}}>
|
|
29
|
+
<View
|
|
30
|
+
style={{
|
|
31
|
+
alignItems: 'center',
|
|
32
|
+
marginRight: Spacing.M,
|
|
33
|
+
minHeight: 48,
|
|
34
|
+
}}>
|
|
35
|
+
<StepIcon
|
|
36
|
+
size={size}
|
|
37
|
+
error={error}
|
|
38
|
+
backgroundColor={backgroundColor}
|
|
39
|
+
borderColor={borderColor}
|
|
40
|
+
/>
|
|
41
|
+
{ii !== steps.length - 1 && (
|
|
42
|
+
<View
|
|
43
|
+
style={[
|
|
44
|
+
styles.lineVertical,
|
|
45
|
+
{backgroundColor: lineColor, marginVertical: Spacing.XS},
|
|
46
|
+
]}
|
|
47
|
+
/>
|
|
48
|
+
)}
|
|
49
|
+
</View>
|
|
50
|
+
<View style={{flex: 1}}>
|
|
51
|
+
<View
|
|
52
|
+
style={[
|
|
53
|
+
{
|
|
54
|
+
flexDirection: 'row',
|
|
55
|
+
justifyContent: 'space-between',
|
|
56
|
+
},
|
|
57
|
+
]}>
|
|
58
|
+
<Text
|
|
59
|
+
numberOfLines={2}
|
|
60
|
+
style={{marginRight: Spacing.S, flex: 1}}
|
|
61
|
+
color={typoStyle.title.color}
|
|
62
|
+
typography={typoStyle.title.typography}>
|
|
63
|
+
{title}
|
|
64
|
+
</Text>
|
|
65
|
+
<Text
|
|
66
|
+
color={typoStyle.time.color}
|
|
67
|
+
typography={typoStyle.time.typography}>
|
|
68
|
+
{time}
|
|
69
|
+
</Text>
|
|
70
|
+
</View>
|
|
71
|
+
<Text
|
|
72
|
+
color={typoStyle.description.color}
|
|
73
|
+
typography={typoStyle.description.typography}>
|
|
74
|
+
{description}
|
|
75
|
+
</Text>
|
|
76
|
+
</View>
|
|
77
|
+
</View>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
return (
|
|
81
|
+
<View style={{width: '100%'}}>
|
|
82
|
+
{steps.map((i, ii) => {
|
|
83
|
+
return renderStepItem(i, ii);
|
|
84
|
+
})}
|
|
85
|
+
</View>
|
|
86
|
+
);
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default StepsVertical;
|
package/index.tsx
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, {FC} from 'react';
|
|
2
|
+
import {View} from 'react-native';
|
|
3
|
+
import {StepsProps, Step} from './types';
|
|
4
|
+
import StepsHorizontal from './StepsHorizontal';
|
|
5
|
+
import StepsVertical from './StepsVertical';
|
|
6
|
+
|
|
7
|
+
const Steps: FC<StepsProps> = ({horizontal = false, ...props}) => {
|
|
8
|
+
return (
|
|
9
|
+
<View>
|
|
10
|
+
{horizontal ? (
|
|
11
|
+
<StepsHorizontal {...props} />
|
|
12
|
+
) : (
|
|
13
|
+
<StepsVertical {...props} />
|
|
14
|
+
)}
|
|
15
|
+
</View>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export {Steps};
|
|
20
|
+
export type {StepsProps, Step};
|
package/package.json
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@momo-kits/step",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.2-react-native.1",
|
|
4
4
|
"private": false,
|
|
5
|
-
"main": "index.
|
|
6
|
-
"dependencies": {},
|
|
5
|
+
"main": "index.tsx",
|
|
7
6
|
"peerDependencies": {
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"react": "
|
|
11
|
-
"
|
|
7
|
+
"@momo-kits/foundation": "latest",
|
|
8
|
+
"react": "*",
|
|
9
|
+
"react-native": "*",
|
|
10
|
+
"prop-types": "15.7.2"
|
|
12
11
|
},
|
|
13
|
-
"devDependencies": {
|
|
14
|
-
|
|
12
|
+
"devDependencies": {
|
|
13
|
+
"@momo-platform/versions": "4.1.11"
|
|
14
|
+
},
|
|
15
|
+
"license": "MoMo",
|
|
16
|
+
"dependencies": {}
|
|
15
17
|
}
|
package/publish.sh
CHANGED
|
@@ -26,4 +26,4 @@ cd ..
|
|
|
26
26
|
rm -rf dist
|
|
27
27
|
|
|
28
28
|
|
|
29
|
-
|
|
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/stepper new version release: '*"$VERSION"*' https://www.npmjs.com/package/@momo-kits/stepper"}'
|
package/styles.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {StyleSheet} from 'react-native';
|
|
2
|
+
import {Colors, Radius, Spacing} from '@momo-kits/foundation';
|
|
3
|
+
|
|
4
|
+
export default StyleSheet.create({
|
|
5
|
+
stepIcon: {
|
|
6
|
+
width: 24,
|
|
7
|
+
height: 24,
|
|
8
|
+
borderWidth: 2,
|
|
9
|
+
borderRadius: Radius.M,
|
|
10
|
+
},
|
|
11
|
+
stepIconSmall: {
|
|
12
|
+
width: 16,
|
|
13
|
+
height: 16,
|
|
14
|
+
borderWidth: 2,
|
|
15
|
+
borderRadius: Radius.S,
|
|
16
|
+
},
|
|
17
|
+
lineHorizontal: {
|
|
18
|
+
height: 2,
|
|
19
|
+
flex: 1,
|
|
20
|
+
},
|
|
21
|
+
lineVertical: {
|
|
22
|
+
width: 2,
|
|
23
|
+
minHeight: 20,
|
|
24
|
+
flex: 1,
|
|
25
|
+
},
|
|
26
|
+
radiusLeft: {
|
|
27
|
+
borderTopLeftRadius: Radius.S,
|
|
28
|
+
borderBottomLeftRadius: Radius.S,
|
|
29
|
+
},
|
|
30
|
+
radiusRight: {
|
|
31
|
+
borderTopRightRadius: Radius.S,
|
|
32
|
+
borderBottomRightRadius: Radius.S,
|
|
33
|
+
},
|
|
34
|
+
center: {
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
justifyContent: 'center',
|
|
37
|
+
},
|
|
38
|
+
rowStep: {
|
|
39
|
+
flexDirection: 'row',
|
|
40
|
+
alignItems: 'center',
|
|
41
|
+
},
|
|
42
|
+
title: {
|
|
43
|
+
marginBottom: Spacing.XS,
|
|
44
|
+
},
|
|
45
|
+
textCenter: {
|
|
46
|
+
textAlign: 'center',
|
|
47
|
+
},
|
|
48
|
+
});
|
package/types.ts
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import {ViewStyle} from 'react-native';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Properties for the Steps component, a guided progress through a sequence of procedural steps.
|
|
5
|
+
*/
|
|
6
|
+
export type StepsProps = {
|
|
7
|
+
/**
|
|
8
|
+
* Optional. If `true`, the steps are laid out in a horizontal manner.
|
|
9
|
+
* If `false`, the steps are laid out vertically.
|
|
10
|
+
* Defaults to `false` (vertical) if not provided.
|
|
11
|
+
*/
|
|
12
|
+
horizontal?: boolean;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* An array of `Step` items representing each individual step in the sequence.
|
|
16
|
+
* Each `Step` has its own set of properties such as title, description, etc.
|
|
17
|
+
*/
|
|
18
|
+
steps: Step[];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Optional. Specifies the size of the steps. Affects all step items within the component.
|
|
22
|
+
* If not provided, a default size is used.
|
|
23
|
+
*/
|
|
24
|
+
size?: 'small' | 'large';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The index of the currently active step within the steps sequence,
|
|
28
|
+
* starting from 0 for the first step.
|
|
29
|
+
*/
|
|
30
|
+
activeIndex: number;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents a single step within the Steps component. Each step has a
|
|
35
|
+
* title and can have optional properties such as a description or error state.
|
|
36
|
+
*/
|
|
37
|
+
export type Step = {
|
|
38
|
+
/**
|
|
39
|
+
* The title of the step, briefly describing the purpose or task of this stage.
|
|
40
|
+
*/
|
|
41
|
+
title: string;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Optional. More detailed text about this particular step.
|
|
45
|
+
* It can provide users with guidance on what to expect or what's required.
|
|
46
|
+
*/
|
|
47
|
+
description?: string;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Optional. If `true`, the step is marked as having an error, typically displayed
|
|
51
|
+
* with an error icon and error styles. Defaults to `false` if not provided.
|
|
52
|
+
*/
|
|
53
|
+
error?: boolean;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Optional. A string representing the time associated with this step.
|
|
57
|
+
* It could be the duration, a specific time, or date, depending on the context.
|
|
58
|
+
*/
|
|
59
|
+
time?: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Properties for the StepIcon component, which displays an icon
|
|
64
|
+
* representing a step within the Steps component.
|
|
65
|
+
*/
|
|
66
|
+
export type StepIconProps = {
|
|
67
|
+
/**
|
|
68
|
+
* Optional. Specifies the size of the step icon. If not provided, a default size is used.
|
|
69
|
+
*/
|
|
70
|
+
size?: 'small' | 'large';
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Optional. The background color of the step icon.
|
|
74
|
+
* If not provided, a default background color is used.
|
|
75
|
+
*/
|
|
76
|
+
backgroundColor?: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Optional. The border color of the step icon.
|
|
80
|
+
* If not provided, a default border color is used.
|
|
81
|
+
*/
|
|
82
|
+
borderColor?: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Optional. If `true`, the step icon is marked as being in an error state,
|
|
86
|
+
* typically displayed with an error icon and error styles.
|
|
87
|
+
* Defaults to `false` if not provided.
|
|
88
|
+
*/
|
|
89
|
+
error?: boolean;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Optional. Custom styles to apply to the StepIcon component.
|
|
93
|
+
* Can be used to adjust the visual presentation or layout.
|
|
94
|
+
*/
|
|
95
|
+
style?: ViewStyle;
|
|
96
|
+
};
|
package/utils.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import {useContext} from 'react';
|
|
2
|
+
import {ApplicationContext, Colors, Typography} from '@momo-kits/foundation';
|
|
3
|
+
|
|
4
|
+
type StepStatus = 'inactive' | 'active' | 'completed' | 'error';
|
|
5
|
+
type StepTypo = {
|
|
6
|
+
typography: Typography;
|
|
7
|
+
color: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const getStepTypo = (
|
|
11
|
+
activeIndex: number,
|
|
12
|
+
currentIndex: number,
|
|
13
|
+
error?: boolean,
|
|
14
|
+
size?: 'small' | 'large',
|
|
15
|
+
) => {
|
|
16
|
+
const {theme} = useContext(ApplicationContext);
|
|
17
|
+
|
|
18
|
+
let title: StepTypo = {
|
|
19
|
+
color: theme.colors.text.default,
|
|
20
|
+
typography: 'description_default_regular',
|
|
21
|
+
};
|
|
22
|
+
let description: StepTypo = {
|
|
23
|
+
color: theme.colors.text.hint,
|
|
24
|
+
typography: 'description_default_regular',
|
|
25
|
+
};
|
|
26
|
+
let time: StepTypo = {
|
|
27
|
+
color: theme.colors.text.hint,
|
|
28
|
+
typography: 'description_xs_regular',
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let status: StepStatus = 'inactive';
|
|
32
|
+
if (activeIndex > currentIndex) {
|
|
33
|
+
status = 'completed';
|
|
34
|
+
}
|
|
35
|
+
if (activeIndex === currentIndex) {
|
|
36
|
+
status = 'active';
|
|
37
|
+
}
|
|
38
|
+
if (error) {
|
|
39
|
+
status = 'error';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
switch (status) {
|
|
43
|
+
case 'active': {
|
|
44
|
+
title.typography = 'header_xs_semibold';
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case 'completed': {
|
|
49
|
+
title.color = theme.colors.text.disable;
|
|
50
|
+
description.color = theme.colors.text.disable;
|
|
51
|
+
time.color = theme.colors.text.disable;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
case 'error': {
|
|
56
|
+
title.typography = 'header_xs_semibold';
|
|
57
|
+
title.color = theme.colors.error.primary;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (size === 'small') {
|
|
63
|
+
description.typography = 'description_xs_regular';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return {title, description, time};
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export const getStepColor = (
|
|
70
|
+
activeIndex: number,
|
|
71
|
+
currentIndex: number,
|
|
72
|
+
error?: boolean,
|
|
73
|
+
length: number = 1,
|
|
74
|
+
) => {
|
|
75
|
+
const {theme} = useContext(ApplicationContext);
|
|
76
|
+
const DEFAULT_LINE_COLOR = theme.colors.background.default;
|
|
77
|
+
const COMPLETED_LINE_COLOR = theme.colors.primary + '33';
|
|
78
|
+
|
|
79
|
+
let backgroundColor = Colors.black_06;
|
|
80
|
+
let borderColor = theme.colors.border.default;
|
|
81
|
+
let lineColorLeft = DEFAULT_LINE_COLOR;
|
|
82
|
+
let lineColorRight = DEFAULT_LINE_COLOR;
|
|
83
|
+
let status: StepStatus = 'inactive';
|
|
84
|
+
|
|
85
|
+
if (activeIndex > currentIndex) {
|
|
86
|
+
status = 'completed';
|
|
87
|
+
lineColorLeft = COMPLETED_LINE_COLOR;
|
|
88
|
+
lineColorRight = COMPLETED_LINE_COLOR;
|
|
89
|
+
}
|
|
90
|
+
if (activeIndex === currentIndex) {
|
|
91
|
+
status = 'active';
|
|
92
|
+
lineColorLeft = COMPLETED_LINE_COLOR;
|
|
93
|
+
}
|
|
94
|
+
if (error) {
|
|
95
|
+
status = 'error';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
if (currentIndex === 0) {
|
|
99
|
+
lineColorLeft = 'transparent';
|
|
100
|
+
}
|
|
101
|
+
if (currentIndex === length - 1) {
|
|
102
|
+
lineColorRight = 'transparent';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
switch (status) {
|
|
106
|
+
case 'active': {
|
|
107
|
+
backgroundColor = theme.colors.primary;
|
|
108
|
+
borderColor = theme.colors.background.tonal;
|
|
109
|
+
break;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
case 'completed': {
|
|
113
|
+
backgroundColor = theme.colors.primary + '33';
|
|
114
|
+
borderColor = theme.colors.background.selected;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
case 'error': {
|
|
119
|
+
backgroundColor = theme.colors.error.primary;
|
|
120
|
+
borderColor = theme.colors.error.container;
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return {backgroundColor, borderColor, lineColorLeft, lineColorRight};
|
|
126
|
+
};
|