Skip to content

Commit 5d63c1e

Browse files
committed
moved constants file to a global constants file
1 parent ad27483 commit 5d63c1e

6 files changed

Lines changed: 19 additions & 11 deletions

File tree

src/bubble/bubble.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { FC } from "react";
22
import { IBubbleProps } from "./types";
33
import whiteTick from '../assets/white-tick.svg';
4-
import { STEP_STATUSES } from './constants';
4+
import { STEP_STATUSES } from '../constants';
55
import styles from './styles';
66
const Bubble: FC<IBubbleProps> = (props) => {
77
const {

src/stepper-component/stepperComponent.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +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';
5+
import { LABEL_POSITION } from '../constants';
66

77
const Stepper: FC<IStepperProps> = (props) => {
88
const {
@@ -27,10 +27,10 @@ const Stepper: FC<IStepperProps> = (props) => {
2727
getInActiveBubbleStyles
2828
} = stylesOverride;
2929

30-
const [currentActiveStepIndexVal, setCurrentActiveStepIndexVal] = useState<number>();
30+
const [currentActiveStepIndexVal, setCurrentActiveStepIndexVal] = useState<number>(0);
3131

3232
useEffect(() => {
33-
setCurrentActiveStepIndexVal(currentActiveStepIndex ?? 0);
33+
setCurrentActiveStepIndexVal((currentActiveStepIndex ?? 0) as number);
3434
}, [currentActiveStepIndex]);
3535

3636
const handleStepClick = (stepIndex: number): void => {
@@ -65,6 +65,7 @@ const Stepper: FC<IStepperProps> = (props) => {
6565
{step?.label && (
6666
<span
6767
style={{...styles.labelTitle,
68+
...((enableStepClick && styles.cursorPointer) || {}),
6869
...((getLabelTitleStyles && getLabelTitleStyles(step, index)) || {}),
6970
...((index === currentActiveStepIndexVal && styles.activeLabelTitle) || {}),
7071
...((index === currentActiveStepIndexVal && getActiveLabelTitleStyles && getActiveLabelTitleStyles(step, index)) || {})
@@ -77,19 +78,23 @@ const Stepper: FC<IStepperProps> = (props) => {
7778
)}
7879
{step?.description && (
7980
<span style={{...styles.labelDescription,
81+
...((enableStepClick && styles.cursorPointer) || {}),
8082
...((getLabelDescriptionStyles && getLabelDescriptionStyles(step, index)) || {}),
8183
...((index === currentActiveStepIndexVal) && styles.activeLabelDescription|| {}),
8284
...((index === currentActiveStepIndexVal && getActiveLabelDescriptionStyles && getActiveLabelDescriptionStyles(step, index)) || {})
83-
}}>
85+
}}
86+
onClick={(): void => handleStepClick(index)}
87+
role="presentation"
88+
>
8489
{step.description}
8590
</span>
8691
)}
8792
</div>
8893
{index < steps?.length - 1 && (
8994
<div style={{...styles.lineSeparator,
9095
...((getLineSeparatorStyles && getLineSeparatorStyles(step, index)) || {}),
91-
...((currentActiveStepIndexVal && index > currentActiveStepIndexVal - 1) && styles.inactiveStepLineSeparator || {}),
92-
...((currentActiveStepIndexVal && index > currentActiveStepIndexVal - 1
96+
...((index > currentActiveStepIndexVal - 1) && styles.inactiveStepLineSeparator || {}),
97+
...((index > currentActiveStepIndexVal - 1
9398
&& getInactiveLineSeparatorStyles && getInactiveLineSeparatorStyles(step, index)) || {})
9499
}} />
95100
)}

src/stepper-component/styles.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ const styles = {
5555
activeLabelDescription: {
5656
color: '#676767'
5757
},
58+
cursorPointer: {
59+
cursor: 'pointer'
60+
},
5861
lineSeparator: {
5962
height: '22px',
6063
width: '1px',

src/stepper-component/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ReactElement } from "react"
2-
import { LABEL_POSITION } from "../bubble/constants"
2+
import { LABEL_POSITION } from "../constants"
33
export interface IStep {
44
label: string,
55
description?: string,

src/stories/StepperComponent.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export default {
1414

1515
const Template: ComponentStory<typeof Stepper> = (args) => <Stepper {...args} />;
1616

17-
export const LoggedIn = Template.bind({});
18-
LoggedIn.args = {
17+
export const VerticalStepper = Template.bind({});
18+
VerticalStepper.args = {
1919
steps: [{
2020
label: 'Step 1',
2121
description: 'The quick brown fox jumps over the lazy dog'
@@ -36,5 +36,5 @@ LoggedIn.args = {
3636
enableStepClick: true,
3737
// onStepClick: (stepIndex: number) => console.log("🚀 ~ file: StepperComponent.stories.tsx:37 ~ stepIndex", stepIndex)
3838
// renderAdornment: (step, index) => {},
39-
labelPosition: 'left'
39+
// labelPosition: 'left'
4040
};

0 commit comments

Comments
 (0)