Skip to content

Commit 929090b

Browse files
committed
feat(ui): add badge prop to ConfigureSSO step header
Lets a step render an inline badge next to the title without crowding the right-aligned children slot. The SSO confirmation step now passes its active status badge through this prop instead of layering its own header component inside the body.
1 parent b8310d7 commit 929090b

3 files changed

Lines changed: 39 additions & 61 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/ui': patch
3+
---
4+
5+
Add an optional badge prop to the ConfigureSSO step header and use it for the SSO status badge on the confirmation step.

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type PropsWithChildren } from 'react';
1+
import { type PropsWithChildren, type ReactNode } from 'react';
22

33
import {
44
Badge,
@@ -47,9 +47,10 @@ const Section = ({ fill, sx, ...props }: StepSectionProps): JSX.Element => (
4747
type StepHeaderProps = PropsWithChildren<{
4848
title: LocalizationKey | string;
4949
description?: LocalizationKey | string;
50+
badge?: ReactNode;
5051
}>;
5152

52-
const Header = ({ title, description, children }: StepHeaderProps): JSX.Element => {
53+
const Header = ({ title, description, badge, children }: StepHeaderProps): JSX.Element => {
5354
const { t } = useLocalizations();
5455
const titleText = typeof title === 'string' ? title : t(title);
5556
const descriptionText = description ? (typeof description === 'string' ? description : t(description)) : null;
@@ -69,12 +70,18 @@ const Header = ({ title, description, children }: StepHeaderProps): JSX.Element
6970
sx={theme => ({ gap: theme.space.$4 })}
7071
>
7172
<Col sx={theme => ({ gap: theme.space.$2, minWidth: 0 })}>
72-
<Heading
73-
elementDescriptor={descriptors.configureSSOStepHeaderTitle}
74-
textVariant='h2'
73+
<Flex
74+
align='center'
75+
sx={t => ({ gap: t.space.$2, flexWrap: 'wrap' })}
7576
>
76-
{titleText}
77-
</Heading>
77+
<Heading
78+
elementDescriptor={descriptors.configureSSOStepHeaderTitle}
79+
textVariant='h2'
80+
>
81+
{titleText}
82+
</Heading>
83+
{badge}
84+
</Flex>
7885

7986
{descriptionText && (
8087
<Text

packages/ui/src/components/ConfigureSSO/steps/ConfirmationStep.tsx

Lines changed: 20 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,9 @@
11
import { useOrganization, useReverification } from '@clerk/shared/react';
22
import { useState } from 'react';
33

4-
import {
5-
Badge,
6-
Button,
7-
Col,
8-
descriptors,
9-
Flex,
10-
Flow,
11-
Grid,
12-
Heading,
13-
Link,
14-
localizationKeys,
15-
Text,
16-
} from '@/customizables';
4+
import { Badge, Button, Col, descriptors, Flex, Flow, Grid, Link, localizationKeys, Text } from '@/customizables';
175
import { useCardState } from '@/elements/contexts';
186
import { Switch } from '@/elements/Switch';
19-
import { Alert } from '@/ui/elements/Alert';
207
import { handleError } from '@/utils/errorHandler';
218

229
import { useConfigureSSO } from '../ConfigureSSOContext';
@@ -34,59 +21,38 @@ export const ConfirmationStep = (): JSX.Element => {
3421
elementDescriptor={descriptors.configureSSOStep}
3522
elementId={descriptors.configureSSOStep.setId('confirmation')}
3623
>
24+
<Step.Header
25+
title={localizationKeys('configureSSO.confirmation.statusSection.title')}
26+
badge={
27+
<Badge
28+
elementDescriptor={descriptors.configureSSOConfirmationStatusBadge}
29+
elementId={descriptors.configureSSOConfirmationStatusBadge.setId(isActive ? 'active' : 'inactive')}
30+
colorScheme={isActive ? 'success' : 'danger'}
31+
localizationKey={
32+
isActive
33+
? localizationKeys('configureSSO.confirmation.statusSection.activeBadge')
34+
: localizationKeys('configureSSO.confirmation.statusSection.inactiveBadge')
35+
}
36+
/>
37+
}
38+
/>
39+
3740
<Step.Body sx={t => ({ paddingInline: t.space.$6, paddingBlock: t.space.$5, gap: t.space.$5 })}>
38-
<StatusHeader isActive={isActive} />
3941
<DetailsGrid />
4042
</Step.Body>
4143

4244
<Step.Footer>
4345
{!isActive && (
44-
<Alert
45-
variant='info'
46-
title={localizationKeys('configureSSO.confirmation.inactiveBanner.title')}
47-
sx={{ flex: 1 }}
48-
/>
46+
<Flex>
47+
<Text title={localizationKeys('configureSSO.confirmation.inactiveBanner.title')} />
48+
</Flex>
4949
)}
5050
</Step.Footer>
5151
</Step>
5252
</Flow.Part>
5353
);
5454
};
5555

56-
type StatusHeaderProps = {
57-
isActive: boolean;
58-
};
59-
60-
const StatusHeader = ({ isActive }: StatusHeaderProps): JSX.Element => {
61-
return (
62-
<Flex
63-
align='center'
64-
sx={t => ({
65-
gap: t.space.$3,
66-
paddingBlockEnd: t.space.$4,
67-
borderBottomWidth: t.borderWidths.$normal,
68-
borderBottomStyle: t.borderStyles.$solid,
69-
borderBottomColor: t.colors.$borderAlpha100,
70-
})}
71-
>
72-
<Heading
73-
textVariant='h2'
74-
localizationKey={localizationKeys('configureSSO.confirmation.statusSection.title')}
75-
/>
76-
<Badge
77-
elementDescriptor={descriptors.configureSSOConfirmationStatusBadge}
78-
elementId={descriptors.configureSSOConfirmationStatusBadge.setId(isActive ? 'active' : 'inactive')}
79-
colorScheme={isActive ? 'success' : 'danger'}
80-
localizationKey={
81-
isActive
82-
? localizationKeys('configureSSO.confirmation.statusSection.activeBadge')
83-
: localizationKeys('configureSSO.confirmation.statusSection.inactiveBadge')
84-
}
85-
/>
86-
</Flex>
87-
);
88-
};
89-
9056
const DetailsGrid = (): JSX.Element => {
9157
return (
9258
<Grid

0 commit comments

Comments
 (0)