33import React from 'react' ;
44import clsx from 'clsx' ;
55
6+ import { BoxProps } from '../box/interfaces' ;
7+ import InternalBox from '../box/internal' ;
68import { InternalBaseComponentProps } from '../internal/hooks/use-base-component' ;
79import { SomeRequired } from '../internal/types' ;
810import StatusIndicator from '../status-indicator/internal' ;
@@ -12,6 +14,17 @@ import styles from './styles.css.js';
1214
1315type InternalStepsProps = SomeRequired < StepsProps , 'steps' > & InternalBaseComponentProps ;
1416
17+ const statusToColor : Record < StepsProps . Status , BoxProps . Color > = {
18+ error : 'text-status-error' ,
19+ warning : 'text-status-warning' ,
20+ success : 'text-status-success' ,
21+ info : 'text-status-info' ,
22+ stopped : 'text-status-inactive' ,
23+ pending : 'text-status-inactive' ,
24+ 'in-progress' : 'text-status-inactive' ,
25+ loading : 'text-status-inactive' ,
26+ } ;
27+
1528const CustomStep = ( {
1629 step,
1730 orientation,
@@ -21,14 +34,19 @@ const CustomStep = ({
2134 orientation : StepsProps . Orientation ;
2235 renderStep : Required < StepsProps > [ 'renderStep' ] ;
2336} ) => {
24- const { header, details } = renderStep ( step ) ;
37+ const { status, statusIconAriaLabel } = step ;
38+ const { header, details, icon } = renderStep ( step ) ;
2539 return (
26- < li className = { clsx ( styles . container , styles . custom ) } >
40+ < li className = { styles . container } >
2741 < div className = { styles . header } >
28- < span > { header } </ span >
29- { orientation === 'horizontal' && < hr className = { styles . connector } role = "none" /> }
42+ { icon ? icon : < StatusIndicator type = { status } iconAriaLabel = { statusIconAriaLabel } /> }
43+ { orientation === 'vertical' ? header : < hr className = { styles . connector } role = "none" /> }
3044 </ div >
31- { orientation === 'vertical' && < hr className = { styles . connector } role = "none" /> }
45+ { orientation === 'vertical' ? (
46+ < hr className = { styles . connector } role = "none" />
47+ ) : (
48+ < div className = { styles [ 'horizontal-header' ] } > { header } </ div >
49+ ) }
3250 { details && < div className = { styles . details } > { details } </ div > }
3351 </ li >
3452 ) ;
@@ -45,11 +63,17 @@ const InternalStep = ({
4563 < li className = { styles . container } >
4664 < div className = { styles . header } >
4765 < StatusIndicator type = { status } iconAriaLabel = { statusIconAriaLabel } >
48- { header }
66+ { orientation === 'vertical' && header }
4967 </ StatusIndicator >
5068 { orientation === 'horizontal' && < hr className = { styles . connector } role = "none" /> }
5169 </ div >
52- { orientation === 'vertical' && < hr className = { styles . connector } role = "none" /> }
70+ { orientation === 'vertical' ? (
71+ < hr className = { styles . connector } role = "none" />
72+ ) : (
73+ < div className = { styles [ 'horizontal-header' ] } >
74+ < InternalBox color = { statusToColor [ status ] } > { header } </ InternalBox >
75+ </ div >
76+ ) }
5377 { details && < div className = { styles . details } > { details } </ div > }
5478 </ li >
5579 ) ;
0 commit comments