1- import React , { useState , useEffect , ReactElement , FC } from 'react' ;
1+ import React , { ReactElement , FC } from 'react' ;
22import classes from './styles.module.scss' ;
3- import type { IStep , IStepperProps } from './types' ;
3+ import { IStep , IStepperProps } from './types' ;
44import Bubble from '../bubble' ;
5- import { LABEL_POSITION } from '../constants' ;
5+ import { LABEL_POSITION , Elements } from '../constants' ;
66
77const Stepper : FC < IStepperProps > = ( props ) => {
88 const {
@@ -14,17 +14,13 @@ const Stepper: FC<IStepperProps> = (props) => {
1414 labelPosition = LABEL_POSITION . RIGHT
1515 } = props ;
1616
17- const {
18- getLabelDescriptionStyles,
19- getLabelTitleStyles,
20- getActiveLabelTitleStyles,
21- getActiveLabelDescriptionStyles,
22- getLineSeparatorStyles,
23- getInactiveLineSeparatorStyles,
24- getBubbleStyles,
25- getActiveBubbleStyles,
26- getInActiveBubbleStyles
27- } = styles ;
17+ const getStyles = ( element : Elements , step : IStep , index : number ) : object => {
18+ const getElementStyle = styles [ element ] ;
19+ if ( getElementStyle ) {
20+ return getElementStyle ( step , index ) ;
21+ }
22+ return { } ;
23+ } ;
2824
2925 return (
3026 < div className = { classes . stepperContainer } >
@@ -37,9 +33,7 @@ const Stepper: FC<IStepperProps> = (props) => {
3733 currentStepIndex = { currentStepIndex }
3834 handleStepClick = { ( ) : void => onStepClick && onStepClick ( step , stepIndex ) }
3935 renderAdornment = { renderBubble }
40- getBubbleStyles = { getBubbleStyles }
41- getActiveBubbleStyles = { getActiveBubbleStyles }
42- getInActiveBubbleStyles = { getInActiveBubbleStyles }
36+ getStyles = { ( element : Elements ) : object => getStyles ( element , step , stepIndex ) }
4337 />
4438 < div className = { `${ classes . labelContainer } ${ classes [ `labelContainer__${ labelPosition || LABEL_POSITION . RIGHT } ` ] } ` } >
4539 { step ?. label && (
@@ -48,8 +42,8 @@ const Stepper: FC<IStepperProps> = (props) => {
4842 ${ onStepClick && classes . cursorPointer }
4943 ${ stepIndex === currentStepIndex && classes . activeLabelTitle } ` }
5044 style = { {
51- ...( ( getLabelTitleStyles && getLabelTitleStyles ( step , stepIndex ) ) || { } ) ,
52- ...( ( stepIndex === currentStepIndex && getActiveLabelTitleStyles && getActiveLabelTitleStyles ( step , stepIndex ) ) || { } )
45+ ...( ( getStyles ( Elements . LabelTitle , step , stepIndex ) ) || { } ) ,
46+ ...( ( stepIndex === currentStepIndex && getStyles ( Elements . ActiveLabelTitle , step , stepIndex ) ) || { } )
5347 } }
5448 onClick = { ( ) : void => onStepClick && onStepClick ( step , stepIndex ) }
5549 role = "presentation"
@@ -64,9 +58,9 @@ const Stepper: FC<IStepperProps> = (props) => {
6458 ${ onStepClick && classes . cursorPointer }
6559 ${ stepIndex === currentStepIndex && classes . activeLabelDescription } ` }
6660 style = { {
67- ...( ( getLabelDescriptionStyles && getLabelDescriptionStyles ( step , stepIndex ) ) || { } ) ,
61+ ...( ( getStyles ( Elements . LabelDescription , step , stepIndex ) ) || { } ) ,
6862 ...( ( stepIndex === currentStepIndex &&
69- getActiveLabelDescriptionStyles && getActiveLabelDescriptionStyles ( step , stepIndex ) ) || { } )
63+ getStyles ( Elements . ActiveLabelDescription , step , stepIndex ) ) || { } )
7064 } }
7165 onClick = { ( ) : void => onStepClick && onStepClick ( step , stepIndex ) }
7266 role = "presentation"
@@ -81,9 +75,9 @@ const Stepper: FC<IStepperProps> = (props) => {
8175 className = { `${ classes . lineSeparator }
8276 ${ stepIndex > currentStepIndex - 1 && classes . inactiveStepLineSeparator } ` }
8377 style = { {
84- ...( ( getLineSeparatorStyles && getLineSeparatorStyles ( step , stepIndex ) ) || { } ) ,
78+ ...( ( getStyles ( Elements . LineSeparator , step , stepIndex ) ) || { } ) ,
8579 ...( ( stepIndex > currentStepIndex - 1
86- && getInactiveLineSeparatorStyles && getInactiveLineSeparatorStyles ( step , stepIndex ) ) || { } )
80+ && getStyles ( Elements . InactiveLineSeparator , step , stepIndex ) ) || { } )
8781 } }
8882 />
8983 ) }
0 commit comments