Skip to content

Commit 89d9474

Browse files
committed
added customizations to all elements
1 parent e0e7711 commit 89d9474

7 files changed

Lines changed: 84 additions & 21 deletions

File tree

.eslintrc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@
2323
"@typescript-eslint/explicit-function-return-type": "error",
2424
"react/prop-types": "warn",
2525
"indent": ["error", 2],
26-
"arrow-body-style": ["error", "as-needed"]
26+
"arrow-body-style": ["error", "as-needed"],
27+
"no-trailing-spaces":"error",
28+
"comma-dangle":"error",
29+
"default-case":"error",
30+
"block-spacing": "error",
31+
"max-len":["warn", 150],
32+
"space-before-blocks":"error"
2733
},
2834
"settings": {
2935
"react": {

src/bubble/bubble.tsx

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,27 @@ import whiteTick from '../assets/white-tick.svg';
44
import { STEP_STATUSES } from './constants';
55
import styles from './styles';
66
const Bubble = (props: IBubbleProps): ReactElement => {
7-
const { step, enableStepClick, renderAdornment, index, currentActiveStepIndexVal, handleStepClick } = props;
7+
const {
8+
step,
9+
enableStepClick,
10+
renderAdornment,
11+
index,
12+
currentActiveStepIndexVal,
13+
handleStepClick,
14+
getBubbleStyles,
15+
getActiveBubbleStyles,
16+
getInActiveBubbleStyles
17+
} = props;
818
return (
919
<div
1020
style={{...styles.eachBubble,
21+
...((getBubbleStyles && getBubbleStyles(step, index)) || {}),
1122
...((enableStepClick && styles.cursorPointer) || {}),
1223
...((index === currentActiveStepIndexVal) && styles.activeStepBubble || {}),
13-
...((step.status === STEP_STATUSES.UNVISITED && currentActiveStepIndexVal !== index) && styles.inactiveStepBubble || {})
24+
...((index === currentActiveStepIndexVal && getActiveBubbleStyles && getActiveBubbleStyles(step, index)) || {}),
25+
...((step.status === STEP_STATUSES.UNVISITED && currentActiveStepIndexVal !== index) && styles.inactiveStepBubble || {}),
26+
...((step.status === STEP_STATUSES.UNVISITED && currentActiveStepIndexVal !== index
27+
&& getInActiveBubbleStyles && getInActiveBubbleStyles(step, index)) || {})
1428
}}
1529
onClick={(): void => handleStepClick(index)}
1630
role="presentation"

src/bubble/constants.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
const VISITED = 'visited';
2-
const UNVISITED = 'unvisited';
3-
const COMPLETED = 'completed';
4-
5-
export const STEP_STATUSES = {
6-
VISITED,
7-
UNVISITED,
8-
COMPLETED
9-
};
1+
export enum STEP_STATUSES {
2+
VISITED = 'visited',
3+
UNVISITED = 'unvisited',
4+
COMPLETED = 'completed'
5+
}

src/bubble/types.d.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,8 @@ export interface IBubbleProps {
77
renderAdornment?(step: IStep, index: number): ReactElement,
88
index: number,
99
currentActiveStepIndexVal: number,
10-
handleStepClick(index: number): void
10+
handleStepClick(index: number): void,
11+
getBubbleStyles?(step: IStep, index: number): object,
12+
getActiveBubbleStyles?(step: IStep, index: number): object,
13+
getInActiveBubbleStyles?(step: IStep, index: number): object,
1114
}

src/stepper-component/stepperComponent.tsx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,26 @@ import { IStep, IStepperProps } from './types';
44
import Bubble from '../bubble';
55

66
const Stepper = (props: IStepperProps): ReactElement => {
7-
const { steps, currentActiveStepIndex, onStepClick, enableStepClick = false, renderAdornment } = props;
7+
const {
8+
steps,
9+
currentActiveStepIndex,
10+
enableStepClick = false,
11+
onStepClick,
12+
renderAdornment,
13+
stylesOverride
14+
} = props;
15+
16+
const {
17+
getLabelDescriptionStyles,
18+
getLabelTitleStyles,
19+
getActiveLabelTitleStyles,
20+
getActiveLabelDescriptionStyles,
21+
getLineSeparatorStyles,
22+
getInactiveLineSeparatorStyles,
23+
getBubbleStyles,
24+
getActiveBubbleStyles,
25+
getInActiveBubbleStyles
26+
} = stylesOverride;
827

928
const [currentActiveStepIndexVal, setCurrentActiveStepIndexVal] = useState<number>();
1029

@@ -31,12 +50,18 @@ const Stepper = (props: IStepperProps): ReactElement => {
3150
currentActiveStepIndexVal= {currentActiveStepIndexVal}
3251
handleStepClick={handleStepClick}
3352
renderAdornment={renderAdornment}
53+
getBubbleStyles={getBubbleStyles}
54+
getActiveBubbleStyles={getActiveBubbleStyles}
55+
getInActiveBubbleStyles={getInActiveBubbleStyles}
3456
/>
3557
<div style={styles.eachLabel}>
3658
{step?.label && (
3759
<span
3860
style={{...styles.labelTitle,
39-
...((index === currentActiveStepIndexVal && styles.activeLabelTitle) || {})}}
61+
...((getLabelTitleStyles && getLabelTitleStyles(step, index)) || {}),
62+
...((index === currentActiveStepIndexVal && styles.activeLabelTitle) || {}),
63+
...((index === currentActiveStepIndexVal && getActiveLabelTitleStyles && getActiveLabelTitleStyles(step, index)) || {})
64+
}}
4065
onClick={(): void => handleStepClick(index)}
4166
role="presentation"
4267
>
@@ -45,14 +70,21 @@ const Stepper = (props: IStepperProps): ReactElement => {
4570
)}
4671
{step?.description && (
4772
<span style={{...styles.labelDescription,
48-
...((index === currentActiveStepIndexVal) && styles.activeLabelDescription|| {})}}>
73+
...((getLabelDescriptionStyles && getLabelDescriptionStyles(step, index)) || {}),
74+
...((index === currentActiveStepIndexVal) && styles.activeLabelDescription|| {}),
75+
...((index === currentActiveStepIndexVal && getActiveLabelDescriptionStyles && getActiveLabelDescriptionStyles(step, index)) || {})
76+
}}>
4977
{step.description}
5078
</span>
5179
)}
5280
</div>
5381
{index < steps?.length - 1 && (
5482
<div style={{...styles.lineSeparator,
55-
...((index > currentActiveStepIndexVal - 1) && styles.activeStepLineSeparator || {})}} />
83+
...((getLineSeparatorStyles && getLineSeparatorStyles(step, index)) || {}),
84+
...((index > currentActiveStepIndexVal - 1) && styles.inactiveStepLineSeparator || {}),
85+
...((index > currentActiveStepIndexVal - 1&& getInactiveLineSeparatorStyles && getInactiveLineSeparatorStyles(step, index)) || {})
86+
87+
}} />
5688
)}
5789
</div>
5890
</div>

src/stepper-component/styles.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
32
const styles = {
43
stepperContainer: {
54
display: 'flex',
@@ -16,7 +15,7 @@ const styles = {
1615
display: 'flex',
1716
flexDirection: 'column',
1817
position: 'relative'
19-
18+
2019
},
2120
bubbleLineWrapper: {
2221
display: 'flex',
@@ -55,7 +54,7 @@ const styles = {
5554
borderRight: '2px solid #dfdff2',
5655
margin: '4px 0'
5756
},
58-
activeStepLineSeparator: {
57+
inactiveStepLineSeparator: {
5958
borderRight: '2px dashed #dfdff2'
6059
}
6160
} as const

src/stepper-component/types.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,18 @@ export interface IStepperProps {
1111
currentActiveStepIndex: number,
1212
onStepClick?(stepIndex: number): void,
1313
enableStepClick?: boolean,
14-
renderAdornment?(step: IStep, index: number): ReactElement
14+
renderAdornment?(step: IStep, index: number): ReactElement,
15+
stylesOverride?: IStylesOverride
16+
}
17+
18+
export interface IStylesOverride {
19+
getLabelDescriptionStyles?(step: IStep, index: number): object,
20+
getLabelTitleStyles?(step: IStep, index: number): object,
21+
getActiveLabelDescriptionStyles?(step: IStep, index: number): object,
22+
getActiveLabelTitleStyles?(step: IStep, index: number): object,
23+
getLineSeparatorStyles?(step: IStep, index: number): object,
24+
getInactiveLineSeparatorStyles?(step: IStep, index: number): object,
25+
getBubbleStyles?(step: IStep, index: number): object,
26+
getActiveBubbleStyles?(step: IStep, index: number): object,
27+
getInActiveBubbleStyles?(step: IStep, index: number): object,
1528
}

0 commit comments

Comments
 (0)