Skip to content

Commit ad27483

Browse files
committed
added left and right alignment options for label
1 parent a38db32 commit ad27483

5 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/bubble/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,9 @@ export enum STEP_STATUSES {
22
VISITED = 'visited',
33
UNVISITED = 'unvisited',
44
COMPLETED = 'completed'
5+
}
6+
7+
export enum LABEL_POSITION {
8+
LEFT = 'left',
9+
RIGHT = 'right'
510
}

src/stepper-component/stepperComponent.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState, useEffect, ReactElement, FC } from 'react';
22
import styles from './styles';
33
import { IStep, IStepperProps } from './types';
44
import Bubble from '../bubble';
5+
import { LABEL_POSITION } from '../bubble/constants';
56

67
const Stepper: FC<IStepperProps> = (props) => {
78
const {
@@ -10,7 +11,8 @@ const Stepper: FC<IStepperProps> = (props) => {
1011
enableStepClick = false,
1112
onStepClick,
1213
renderAdornment,
13-
stylesOverride = {}
14+
stylesOverride = {},
15+
labelPosition = LABEL_POSITION.RIGHT
1416
} = props;
1517

1618
const {
@@ -54,7 +56,12 @@ const Stepper: FC<IStepperProps> = (props) => {
5456
getActiveBubbleStyles={getActiveBubbleStyles}
5557
getInActiveBubbleStyles={getInActiveBubbleStyles}
5658
/>
57-
<div style={styles.eachLabel}>
59+
<div
60+
style={{
61+
...styles.labelContainer,
62+
...styles[`labelContainer__${labelPosition}`] ?? {}
63+
}}
64+
>
5865
{step?.label && (
5966
<span
6067
style={{...styles.labelTitle,

src/stepper-component/styles.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,22 @@ const styles = {
2323
alignItems: 'center',
2424
width: 'fit-content'
2525
},
26-
eachLabel: {
26+
labelContainer: {
2727
position: 'absolute',
28-
top: '4px',
29-
left: '44px',
3028
width: 'max-content',
3129
height: 'fit-content',
3230
display: 'flex',
3331
flexDirection: 'column'
3432
},
33+
labelContainer__right: {
34+
top: '4px',
35+
left: '44px'
36+
},
37+
labelContainer__left: {
38+
top: '4px',
39+
right: '44px',
40+
alignItems: 'end'
41+
},
3542
labelTitle: {
3643
color: '#4F4F4F'
3744
},

src/stepper-component/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactElement } from "react"
2-
2+
import { LABEL_POSITION } from "../bubble/constants"
33
export interface IStep {
44
label: string,
55
description?: string,
@@ -12,7 +12,8 @@ export interface IStepperProps {
1212
onStepClick?(stepIndex: number): void,
1313
enableStepClick?: boolean,
1414
renderAdornment?(step: IStep, index: number): ReactElement,
15-
stylesOverride?: IStylesOverride
15+
stylesOverride?: IStylesOverride,
16+
labelPosition?: LABEL_POSITION.LEFT | LABEL_POSITION.RIGHT
1617
}
1718

1819
export interface IStylesOverride {

src/stories/StepperComponent.stories.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,6 @@ LoggedIn.args = {
3535
currentActiveStepIndex: 2,
3636
enableStepClick: true,
3737
// onStepClick: (stepIndex: number) => console.log("🚀 ~ file: StepperComponent.stories.tsx:37 ~ stepIndex", stepIndex)
38-
// renderAdornment: (step, index) => {}
38+
// renderAdornment: (step, index) => {},
39+
labelPosition: 'left'
3940
};

0 commit comments

Comments
 (0)