Skip to content

Commit 7dc3f44

Browse files
committed
refactor(ui): simplify Stepper.Item API
Stepper.Item now takes the label as children and a bullet number as a primitive prop (rather than a ReactNode the caller had to pre-build). The check-icon-vs-number switch moves inside Item, driven by the isCompleted prop — callers no longer pick which symbol to render in the bullet slot. ConfigureSSOHeader simplifies accordingly: it computes the bullet number from the index, resolves the step label via useLocalizations, and passes the rest as plain props. No more inline ternary picking between an Icon and a Text node for the bullet.
1 parent 7bd72fe commit 7dc3f44

3 files changed

Lines changed: 34 additions & 40 deletions

File tree

packages/ui/src/components/ConfigureSSO/ConfigureSSOHeader.tsx

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Icon, Text } from '@/customizables';
2-
import { Check } from '@/icons';
1+
import { useLocalizations } from '@/customizables';
32

43
import { ProfileCardHeader } from './elements/ProfileCard';
54
import { Stepper } from './elements/Stepper';
65
import { useWizard } from './elements/Wizard';
76

87
export const ConfigureSSOHeader = (): JSX.Element => {
98
const { activeSteps, currentStep, goToStep } = useWizard();
9+
const { t } = useLocalizations();
1010
// Select Provider isn't part of the visual breadcrumb per the design —
1111
// filter it out here. The wizard still tracks it as the first step
1212
// for navigation (goNext from it advances to verify-domain, Previous
@@ -21,31 +21,12 @@ export const ConfigureSSOHeader = (): JSX.Element => {
2121
const isCurrent = index === currentIndex;
2222
const isCompleted = step.isCompleted ?? index < currentIndex;
2323
const isReachable = isCompleted || index <= currentIndex;
24-
const showCheck = isCompleted && !isCurrent;
24+
const labelText = step.label ? (typeof step.label === 'string' ? step.label : t(step.label)) : '';
2525

2626
return (
2727
<Stepper.Item
2828
key={step.id}
29-
label={step.label}
30-
bullet={
31-
showCheck ? (
32-
<Icon
33-
icon={Check}
34-
sx={theme => ({ width: theme.sizes.$2, height: theme.sizes.$2, color: theme.colors.$white })}
35-
/>
36-
) : (
37-
<Text
38-
as='span'
39-
sx={theme => ({
40-
fontSize: theme.fontSizes.$xs,
41-
fontWeight: theme.fontWeights.$semibold,
42-
color: theme.colors.$colorBackground,
43-
})}
44-
>
45-
{index + 1}
46-
</Text>
47-
)
48-
}
29+
bullet={index + 1}
4930
isCurrent={isCurrent}
5031
isCompleted={isCompleted}
5132
isReachable={isReachable}
@@ -54,7 +35,9 @@ export const ConfigureSSOHeader = (): JSX.Element => {
5435
void goToStep(step.id);
5536
}
5637
}}
57-
/>
38+
>
39+
{labelText}
40+
</Stepper.Item>
5841
);
5942
})}
6043
</Stepper>

packages/ui/src/components/ConfigureSSO/elements/Stepper/Stepper.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22

3-
import { Box, Button, descriptors, Flex, Icon, Text, useLocalizations } from '@/customizables';
4-
import { CaretRight } from '@/icons';
3+
import { Box, Button, descriptors, Flex, Icon, Text } from '@/customizables';
4+
import { CaretRight, Check } from '@/icons';
55

66
import type { StepperItemProps, StepperProps } from './types';
77

@@ -36,16 +36,13 @@ const Root = ({ children }: StepperProps): JSX.Element => {
3636
};
3737

3838
const Item = ({
39-
label,
4039
bullet,
4140
isCurrent,
4241
isCompleted,
4342
isReachable = true,
4443
onClick,
44+
children,
4545
}: StepperItemProps): JSX.Element => {
46-
const { t } = useLocalizations();
47-
const labelText = label ? (typeof label === 'string' ? label : t(label)) : '';
48-
4946
return (
5047
<Button
5148
elementDescriptor={descriptors.configureSSOStepperItem}
@@ -75,15 +72,31 @@ const Item = ({
7572
: theme.colors.$neutralAlpha400,
7673
})}
7774
>
78-
{bullet}
75+
{isCompleted && !isCurrent ? (
76+
<Icon
77+
icon={Check}
78+
sx={theme => ({ width: theme.sizes.$2, height: theme.sizes.$2, color: theme.colors.$white })}
79+
/>
80+
) : (
81+
<Text
82+
as='span'
83+
sx={theme => ({
84+
fontSize: theme.fontSizes.$xs,
85+
fontWeight: theme.fontWeights.$semibold,
86+
color: theme.colors.$colorBackground,
87+
})}
88+
>
89+
{bullet}
90+
</Text>
91+
)}
7992
</Flex>
8093
<Text
8194
elementDescriptor={descriptors.configureSSOStepperItemLabel}
8295
as='span'
8396
variant='body'
8497
sx={{ fontWeight: 'inherit', color: 'inherit' }}
8598
>
86-
{labelText}
99+
{children}
87100
</Text>
88101
</Button>
89102
);

packages/ui/src/components/ConfigureSSO/elements/Stepper/types.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import type React from 'react';
22

3-
import type { LocalizationKey } from '@/customizables';
4-
53
export interface StepperItemProps {
6-
/** Display label. Resolved by the caller before passing in. */
7-
label?: LocalizationKey | string;
8-
/** Content to render inside the bullet circle (typically a number or a check icon). Caller decides what to show. */
9-
bullet?: React.ReactNode;
4+
/** The number shown in the bullet — typically the 1-indexed position. Replaced by a check icon when `isCompleted && !isCurrent`. */
5+
bullet: number;
106
/** Whether this is the active item. Bullet renders in foreground color. */
117
isCurrent?: boolean;
12-
/** Whether this item is past/done. Bullet renders in success color, label in foreground color. */
8+
/** Whether this item is past/done. Bullet renders the check icon in success color, label in foreground color. */
139
isCompleted?: boolean;
1410
/** Whether the user can click this item to jump to it. When false, the button is `isDisabled`. Defaults to true. */
1511
isReachable?: boolean;
16-
/** Click handler. Called regardless of `isReachable` — caller can no-op when not reachable, but the button itself just dispatches. */
12+
/** Click handler. */
1713
onClick?: () => void;
14+
/** Label content rendered next to the bullet. Caller is responsible for any localization. */
15+
children: React.ReactNode;
1816
}
1917

2018
export interface StepperProps {

0 commit comments

Comments
 (0)