Skip to content

Commit 899db4f

Browse files
committed
fix: remove data attributes
1 parent 2f5d9be commit 899db4f

File tree

3 files changed

+285
-423
lines changed

3 files changed

+285
-423
lines changed

packages/ui/src/components/Stepper/Step.tsx

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ import { Stack } from '../Stack'
88
import { Text } from '../Text'
99
import { useStepper } from './StepperProvider'
1010
import {
11+
animationStepperContainer,
1112
stepBullet,
1213
stepContainer,
13-
stepperContainerDone,
1414
stepperContainerRecipe,
15+
stepperInteractive,
1516
stepText,
1617
} from './styles.css'
1718

@@ -47,34 +48,40 @@ export const Step = ({
4748
className,
4849
'data-testid': dataTestId,
4950
}: StepProps) => {
50-
const currentState = useStepper()
51-
const isActive = index === currentState.step
52-
const isDone = index < currentState.step
51+
const {
52+
separator,
53+
labelPosition,
54+
animated,
55+
size,
56+
interactive,
57+
step,
58+
setStep,
59+
} = useStepper()
60+
const isActive = index === step
61+
const isDone = index < step
62+
const separatorBottom = separator && labelPosition === 'bottom'
63+
const interactiveDone = isDone && interactive
5364

5465
const textVariant = useMemo(() => {
55-
if (currentState.size === 'medium') {
66+
if (size === 'medium') {
5667
return isActive ? 'bodyStrong' : 'body'
5768
}
5869

5970
return isActive ? 'bodySmallStrong' : 'bodySmall'
60-
}, [currentState.size, isActive])
71+
}, [size, isActive])
6172

6273
return (
6374
<Stack
6475
alignItems="center"
65-
className={`${className ? `${className} ` : 'step '}${stepContainer} ${stepperContainerRecipe({ animated: currentState.animated, disabled, size: currentState.size })} ${isDone ? stepperContainerDone : ''}`}
66-
data-hide-separator={!currentState.separator}
67-
data-interactive={currentState.interactive && isDone}
68-
data-label-position={currentState.labelPosition}
69-
data-selected={isActive}
76+
className={`${className ? `${className} ` : 'step '}${stepContainer} ${separatorBottom ? stepperContainerRecipe({ animated, disabled, done: isDone, labelPosition, separator, size }) : ''} ${isActive && separator && animated ? animationStepperContainer[size] : ''} ${interactiveDone && !disabled ? stepperInteractive[isActive ? 'active' : 'inactive'] : ''}`}
7077
data-testid={dataTestId ?? `stepper-step-${index}`}
71-
direction={currentState.labelPosition === 'right' ? 'row' : 'column'}
72-
gap={currentState.labelPosition === 'right' ? 1 : 0}
78+
direction={labelPosition === 'right' ? 'row' : 'column'}
79+
gap={labelPosition === 'right' ? 1 : 0}
7380
justifyContent="flex-start"
7481
onClick={() => {
75-
if (currentState.interactive && !disabled) {
76-
if (index < currentState.step) {
77-
currentState.setStep(index)
82+
if (interactive && !disabled) {
83+
if (index < step) {
84+
setStep(index)
7885
}
7986
onClick?.(index)
8087
}
@@ -85,11 +92,11 @@ export const Step = ({
8592
className={stepBullet({
8693
disabled,
8794
isActive,
88-
size: currentState.size,
95+
size,
8996
})}
9097
prominence="strong"
9198
sentiment="primary"
92-
size={currentState.size}
99+
size={size}
93100
>
94101
<CheckIcon />
95102
</Bullet>
@@ -98,19 +105,22 @@ export const Step = ({
98105
className={stepBullet({
99106
disabled,
100107
isActive,
101-
size: currentState.size,
108+
size,
102109
})}
103110
prominence="strong"
104111
sentiment={isDone || isActive ? 'primary' : 'neutral'}
105-
size={currentState.size}
112+
size={size}
106113
>
107114
{(index + 1).toString()}
108115
</Bullet>
109116
)}
110117
{title ? (
111118
<Text
112119
as="span"
113-
className={stepText({ disabled })}
120+
className={stepText({
121+
addMarginTop: separator && labelPosition !== 'right',
122+
disabled,
123+
})}
114124
prominence={isDone || isActive ? 'default' : 'weak'}
115125
sentiment={isActive ? 'primary' : 'neutral'}
116126
variant={textVariant}

0 commit comments

Comments
 (0)