diff --git a/.changeset/feat-stepper-a11y.md b/.changeset/feat-stepper-a11y.md new file mode 100644 index 000000000..5ac672c63 --- /dev/null +++ b/.changeset/feat-stepper-a11y.md @@ -0,0 +1,5 @@ +--- +'react-magma-dom': minor +--- + +feat(Stepper): Additions to the Stepper component for accessibility compliance. The 'aria-current' attribute now reads 'step' when active, the DOM structure has been changed to a UL LI layout, and when labels are hidden, the screenreader sees the step state for each step label. diff --git a/packages/react-magma-dom/src/components/Stepper/Step.tsx b/packages/react-magma-dom/src/components/Stepper/Step.tsx index 440f7f056..bf6bf1f75 100644 --- a/packages/react-magma-dom/src/components/Stepper/Step.tsx +++ b/packages/react-magma-dom/src/components/Stepper/Step.tsx @@ -8,6 +8,7 @@ import { ThemeInterface } from '../../theme/magma'; import { useIsInverse } from '../../inverse'; import { transparentize } from 'polished'; import { HiddenStyles } from '../../utils/UtilityStyles'; +import { StepperLayout } from './Stepper'; export interface StepProps extends React.HTMLAttributes { /** @@ -18,7 +19,7 @@ export interface StepProps extends React.HTMLAttributes { /** * @internal */ - areLabelsHidden?: boolean; + layout?: StepperLayout; /** * Label beneath each step. */ @@ -31,10 +32,18 @@ export interface StepProps extends React.HTMLAttributes { * @internal */ stepStatus?: StepStatus; + /** + * @internal + */ + index?: number; /** * @internal */ isInverse?: boolean; + /** + * @internal + */ + stepLabel?: string; /** * @internal */ @@ -47,7 +56,7 @@ export interface StepProps extends React.HTMLAttributes { export enum StepStatus { active = 'active', - complete = 'complete', + completed = 'completed', incomplete = 'incomplete', } @@ -74,13 +83,13 @@ function buildStepCircleOutlineColors(props) { function buildStepCircleBackgroundColors(props) { const { isInverse, stepStatus, hasError, theme } = props; if (isInverse) { - if (stepStatus === StepStatus.complete && !hasError) { + if (stepStatus === StepStatus.completed && !hasError) { return theme.colors.tertiary500; } else if (hasError) { return theme.colors.danger500; } } else { - if (stepStatus === StepStatus.complete && !hasError) { + if (stepStatus === StepStatus.completed && !hasError) { return theme.colors.primary500; } else if (hasError) { return theme.colors.danger500; @@ -131,7 +140,6 @@ const StyledStep = typedStyled.div` text-align: center; align-self: self-start; align-items: center; - `; const StyledStepIndicator = typedStyled.span<{ @@ -160,7 +168,7 @@ const StyledStepIndicator = typedStyled.span<{ } `; -const StyledStepTextWrapper = typedStyled.div` +const StyledStepTextWrapper = typedStyled.span` flex: 1; display: flex; align-self: center; @@ -203,9 +211,11 @@ export const Step = React.forwardRef( (props, ref) => { const { hasError, - areLabelsHidden, + index, label, + layout, secondaryLabel, + stepLabel, testId, isInverse: isInverseProp, stepStatus, @@ -222,15 +232,25 @@ export const Step = React.forwardRef( stepStatus={stepStatus} theme={theme} > - {stepStatus === StepStatus.complete && !hasError && ( + {stepStatus === StepStatus.completed && !hasError && (