Skip to content

Commit 78d6cc4

Browse files
committed
Add element descriptors
1 parent 551b23a commit 78d6cc4

4 files changed

Lines changed: 54 additions & 18 deletions

File tree

packages/ui/src/components/ConfigureSSO/wizard/ConfigureSSOWizard.tsx

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

3-
import { Badge, Box, Button, descriptors, Flex, Icon, Spinner, Text, useLocalizations } from '@/customizables';
3+
import { Badge, Box, Button, Col, descriptors, Flex, Icon, Spinner, Text, useLocalizations } from '@/customizables';
44
import { CaretLeft, CaretRight } from '@/icons';
55
import { Route, Switch, useRouter } from '@/router';
66

@@ -241,14 +241,26 @@ const Body = ({ activeSteps }: { activeSteps: ConfigureSSOWizardActiveStep[] }):
241241
key={step.id}
242242
path={step.path}
243243
>
244-
{step.children}
244+
<StepBody step={step} />
245245
</Route>
246246
))}
247-
<Route key={firstStep.id}>{firstStep.children}</Route>
247+
<Route key={firstStep.id}>
248+
<StepBody step={firstStep} />
249+
</Route>
248250
</Switch>
249251
);
250252
};
251253

254+
const StepBody = ({ step }: { step: ConfigureSSOWizardActiveStep }): JSX.Element => (
255+
<Col
256+
elementDescriptor={descriptors.configureSSOWizardBody}
257+
elementId={descriptors.configureSSOWizardBody.setId(step.id)}
258+
sx={{ flex: 1, minHeight: 0 }}
259+
>
260+
{step.children}
261+
</Col>
262+
);
263+
252264
/**
253265
* Numbered breadcrumb of the outermost wizard's active steps.
254266
* Completed and current steps are clickable for backwards navigation,
@@ -260,6 +272,7 @@ const Header = (): JSX.Element => {
260272

261273
return (
262274
<Flex
275+
elementDescriptor={descriptors.configureSSOWizardHeader}
263276
align='center'
264277
sx={theme => ({
265278
gap: theme.space.$2,
@@ -282,6 +295,9 @@ const Header = (): JSX.Element => {
282295
<SkeletonBreadcrumbStep />
283296
) : (
284297
<Button
298+
elementDescriptor={descriptors.configureSSOWizardHeaderItem}
299+
elementId={descriptors.configureSSOWizardHeaderItem.setId(step.id)}
300+
isActive={isCurrent}
285301
variant='unstyled'
286302
isDisabled={!isReachable}
287303
onClick={() => {
@@ -296,6 +312,9 @@ const Header = (): JSX.Element => {
296312
})}
297313
>
298314
<Flex
315+
elementDescriptor={descriptors.configureSSOWizardHeaderItemBullet}
316+
elementId={descriptors.configureSSOWizardHeaderItemBullet.setId(step.id)}
317+
isActive={isCurrent}
299318
align='center'
300319
justify='center'
301320
sx={theme => ({
@@ -315,6 +334,8 @@ const Header = (): JSX.Element => {
315334
{index + 1}
316335
</Flex>
317336
<Text
337+
elementDescriptor={descriptors.configureSSOWizardHeaderItemLabel}
338+
elementId={descriptors.configureSSOWizardHeaderItemLabel.setId(step.id)}
318339
as='span'
319340
variant='body'
320341
sx={{ fontWeight: 'inherit', color: 'inherit' }}
@@ -325,6 +346,7 @@ const Header = (): JSX.Element => {
325346
)}
326347
{index < activeSteps.length - 1 && (
327348
<Icon
349+
elementDescriptor={descriptors.configureSSOWizardHeaderSeparator}
328350
icon={CaretRight}
329351
size='sm'
330352
sx={theme => ({ color: theme.colors.$colorMutedForeground })}
@@ -374,7 +396,10 @@ const StepIndicator = (): JSX.Element | null => {
374396
}
375397

376398
return (
377-
<Flex sx={{ marginBottom: 'auto' }}>
399+
<Flex
400+
elementDescriptor={descriptors.configureSSOWizardStepIndicator}
401+
sx={{ marginBottom: 'auto' }}
402+
>
378403
<Badge
379404
colorScheme='primary'
380405
sx={{
@@ -468,6 +493,7 @@ const Footer = (props: FooterProps): JSX.Element => {
468493
>
469494
{!hidePrevious && (
470495
<Button
496+
elementDescriptor={descriptors.configureSSOWizardFooterPreviousButton}
471497
variant='outline'
472498
size='sm'
473499
isDisabled={isForceDisabled || isFirstStep}
@@ -482,6 +508,7 @@ const Footer = (props: FooterProps): JSX.Element => {
482508
</Button>
483509
)}
484510
<Button
511+
elementDescriptor={descriptors.configureSSOWizardFooterContinueButton}
485512
variant='solid'
486513
size='sm'
487514
isDisabled={isForceDisabled || continueAction?.isDisabled || isLastStep}

packages/ui/src/components/ConfigureSSO/wizard/ConfigureSSOWizardContext.tsx

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,9 @@ import React from 'react';
22

33
import type { ConfigureSSOWizardContextValue, ContinueAction } from './types';
44

5-
/**
6-
* Per-wizard context. Each `<ConfigureSSOWizard>` renders one of
7-
* these, so `useConfigureSSOWizard()` returns the *nearest* wizard.
8-
* Inner wizards reach their parent via `React.useContext` *before*
9-
* overriding the provider with their own value
10-
*/
115
export const ConfigureSSOWizardContext = React.createContext<ConfigureSSOWizardContextValue | null>(null);
126
ConfigureSSOWizardContext.displayName = 'ConfigureSSOWizardContext';
137

14-
/**
15-
* Returns the nearest `<ConfigureSSOWizard>`'s API. Inner steps
16-
* registered inside a nested wizard see the inner wizard's `goNext`,
17-
* which itself cascades to the parent wizard on overflow
18-
*/
198
export function useConfigureSSOWizard(): ConfigureSSOWizardContextValue {
209
const ctx = React.useContext(ConfigureSSOWizardContext);
2110

@@ -41,9 +30,9 @@ interface WizardChromeRegistry {
4130
continueAction: ContinueAction | undefined;
4231
setContinueAction: (action: ContinueAction | undefined) => void;
4332
/**
44-
* Marks a wizard as mounted; called by every `<ConfigureSSOWizard>`
45-
* on mount and unmount. Footer-level controls always dispatch to
46-
* the deepest wizard in this stack
33+
* Marks a wizard as mounted, called by every `<ConfigureSSOWizard>`
34+
* on mount and unmount
35+
* Footer-level controls always dispatch to the deepest wizard in this stack
4736
*/
4837
pushWizard: (ref: WizardValueRef) => void;
4938
popWizard: (ref: WizardValueRef) => void;

packages/ui/src/customizables/elementDescriptors.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,16 @@ export const APPEARANCE_KEYS = containsAllElementsConfigKeys([
536536
'enterpriseConnectionButton',
537537
'enterpriseConnectionButtonText',
538538

539+
'configureSSOWizardHeader',
540+
'configureSSOWizardHeaderItem',
541+
'configureSSOWizardHeaderItemBullet',
542+
'configureSSOWizardHeaderItemLabel',
543+
'configureSSOWizardHeaderSeparator',
544+
'configureSSOWizardBody',
545+
'configureSSOWizardStepIndicator',
546+
'configureSSOWizardFooterPreviousButton',
547+
'configureSSOWizardFooterContinueButton',
548+
539549
'web3SolanaWalletButtonsRoot',
540550
'web3SolanaWalletButtons',
541551
'web3SolanaWalletButtonsIconButton',

packages/ui/src/internal/appearance.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,16 @@ export type ElementsConfig = {
672672
enterpriseConnectionButton: WithOptions;
673673
enterpriseConnectionButtonText: WithOptions;
674674

675+
configureSSOWizardHeader: WithOptions;
676+
configureSSOWizardHeaderItem: WithOptions<string, ActiveState>;
677+
configureSSOWizardHeaderItemBullet: WithOptions<string, ActiveState>;
678+
configureSSOWizardHeaderItemLabel: WithOptions<string>;
679+
configureSSOWizardHeaderSeparator: WithOptions;
680+
configureSSOWizardBody: WithOptions<string>;
681+
configureSSOWizardStepIndicator: WithOptions;
682+
configureSSOWizardFooterPreviousButton: WithOptions;
683+
configureSSOWizardFooterContinueButton: WithOptions;
684+
675685
web3SolanaWalletButtonsRoot: WithOptions;
676686
web3SolanaWalletButtons: WithOptions;
677687
web3SolanaWalletButtonsIconButton: WithOptions<string, LoadingState>;

0 commit comments

Comments
 (0)