Skip to content

Commit 8d10866

Browse files
committed
changed to styles in ts from css
1 parent 11b99c0 commit 8d10866

3 files changed

Lines changed: 112 additions & 104 deletions

File tree

src/stepper-component/stepperComponent.tsx

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useEffect, ReactElement } from 'react';
2-
import './styles.css';
2+
import styles from './styles';
33
import { Istep, IstepperProps } from './types';
44
import whiteTick from '../assets/white-tick.svg';
55
import { STEP_STATUSES } from './constants';
@@ -21,44 +21,49 @@ const Stepper = (props: IstepperProps): ReactElement => {
2121
}
2222

2323
return (
24-
<div className="stepperContainer">
24+
<div style={styles.stepperContainer}>
2525
{steps?.map((step: Istep, index: number): ReactElement => (
26-
<div key={index} className="eachStep">
27-
<div className='bubbleLineWrapper'>
26+
<div key={index} style={styles.eachStep}>
27+
<div style={styles.bubbleLineWrapper}>
2828
<div
29-
className={`eachBubble
30-
${enableStepClick && 'cursorPointer'}
31-
${index === currentActiveStepIndexVal && 'activeStepBubble'}
32-
${(step.status === STEP_STATUSES.UNVISITED && currentActiveStepIndexVal !== index) && 'inactiveStepBubble'}`}
29+
style={{...styles.eachBubble,
30+
...((enableStepClick && styles.cursorPointer) || {}),
31+
...((index === currentActiveStepIndexVal) && styles.activeStepBubble || {}),
32+
...((step.status === STEP_STATUSES.UNVISITED && currentActiveStepIndexVal !== index) && styles.inactiveStepBubble || {})
33+
}}
3334
onClick={(): void => handleStepClick(index)}
35+
role="presentation"
3436
>
3537
{step?.status === STEP_STATUSES.COMPLETED && (
3638
<img
3739
src={whiteTick}
38-
className="whiteTickImg"
40+
style={styles.whiteTickImg}
3941
alt=""
4042
/>
4143
)
4244
|| index + 1}
4345
</div>
44-
<div className='eachLabel'>
45-
{step.label && (
46+
<div style={styles.eachLabel}>
47+
{step?.label && (
4648
<span
47-
className={`labelTitle ${index === currentActiveStepIndexVal && 'activeLabelTitle'}`}
49+
style={{...styles.labelTitle,
50+
...((index === currentActiveStepIndexVal && styles.activeLabelTitle) || {})}}
4851
onClick={(): void => handleStepClick(index)}
4952
role="presentation"
5053
>
51-
{step?.label}
54+
{step.label}
5255
</span>
5356
)}
5457
{step?.description && (
55-
<span className={`labelDescription ${index === currentActiveStepIndexVal && 'activeLabelDescription'}`}>
56-
{step?.description}
58+
<span style={{...styles.labelDescription,
59+
...((index === currentActiveStepIndexVal) && styles.activeLabelDescription|| {})}}>
60+
{step.description}
5761
</span>
5862
)}
5963
</div>
6064
{index < steps?.length - 1 && (
61-
<div className={`lineSeparator ${(index > currentActiveStepIndexVal - 1) && 'activeStepLineSeparator'}`} />
65+
<div style={{...styles.lineSeparator,
66+
...((index > currentActiveStepIndexVal - 1) && styles.activeStepLineSeparator || {})}} />
6267
)}
6368
</div>
6469
</div>

src/stepper-component/styles.css

Lines changed: 0 additions & 88 deletions
This file was deleted.

src/stepper-component/styles.ts

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
2+
3+
const styles = {
4+
stepperContainer: {
5+
display: 'flex',
6+
width: '100%',
7+
height: '100%',
8+
flexDirection: 'column',
9+
marginLeft: '10px',
10+
alignItems: 'center'
11+
},
12+
stepSection: {
13+
display: 'flex'
14+
},
15+
eachBubble: {
16+
borderRadius: '50%',
17+
height: '24px',
18+
width: '24px',
19+
background: '#312ec0',
20+
color: 'white',
21+
display: 'flex',
22+
alignItems: 'center',
23+
justifyContent: 'center',
24+
overflow: 'visible',
25+
fontWeight: '400',
26+
fontSize: '12px',
27+
lineHeight: '16px',
28+
border: '7px solid'
29+
},
30+
activeStepBubble: {
31+
border: '7px solid #CBCBEF'
32+
},
33+
inactiveStepBubble: {
34+
opacity: 0.4
35+
},
36+
cursorPointer: {
37+
cursor: 'pointer'
38+
},
39+
whiteTickImg: {
40+
objectFit: 'cover',
41+
width: '10px',
42+
height: '8px'
43+
},
44+
eachStep: {
45+
display: 'flex',
46+
flexDirection: 'column',
47+
position: 'relative'
48+
49+
},
50+
bubbleLineWrapper: {
51+
display: 'flex',
52+
flexDirection: 'column',
53+
alignItems: 'center',
54+
width: 'fit-content'
55+
},
56+
eachLabel: {
57+
position: 'absolute',
58+
top: '4px',
59+
left: '44px',
60+
width: 'max-content',
61+
height: 'fit-content',
62+
display: 'flex',
63+
flexDirection: 'column'
64+
},
65+
labelTitle: {
66+
color: '#4F4F4F'
67+
},
68+
activeLabelTitle: {
69+
fontWeight: 700
70+
},
71+
labelDescription: {
72+
fontWeight: 400,
73+
fontSize: '12px',
74+
lineHeight: '21px',
75+
letterSpacing: '0.02em',
76+
color: '#929292'
77+
},
78+
activeLabelDescription: {
79+
color: '#676767'
80+
},
81+
lineSeparator: {
82+
height: '22px',
83+
width: '1px',
84+
borderRight: '2px solid #dfdff2',
85+
margin: '4px 0'
86+
},
87+
activeStepLineSeparator: {
88+
borderRight: '2px dashed #dfdff2'
89+
}
90+
} as const
91+
export default styles;

0 commit comments

Comments
 (0)