From c1a6f5e70d5a37a0211313e70f3285be8c29d295 Mon Sep 17 00:00:00 2001 From: Josiah Ivey Date: Thu, 25 Apr 2024 10:09:42 -0700 Subject: [PATCH] make the progress bar accessible as breadcrumbs (#67) * make the progress bar accessible as breadcrumbs * update snapshots --- src/components/ProgressBar.tsx | 29 ++++++---- .../__snapshots__/ProgressBar.spec.tsx.snap | 57 +++++++++++++++++-- 2 files changed, 69 insertions(+), 17 deletions(-) diff --git a/src/components/ProgressBar.tsx b/src/components/ProgressBar.tsx index 816b7fc..b8f37ed 100644 --- a/src/components/ProgressBar.tsx +++ b/src/components/ProgressBar.tsx @@ -5,7 +5,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faCheck } from '@fortawesome/free-solid-svg-icons/faCheck'; import { faXmark } from '@fortawesome/free-solid-svg-icons/faXmark'; -const ProgressBarWrapper = styled.div` +const ProgressBarWrapper = styled.nav` display: flex; justify-content: flex-start; flex-wrap: wrap; @@ -131,18 +131,25 @@ export type ProgressBarItemVariant = 'isCorrect' | 'isIncorrect' | 'isStatus' | export const ProgressBarItem = ({index, isActive, step, goToStep}: ProgressBarItemProps) => - goToStep(index, step)}> + goToStep(index, step)} + aria-current={isActive ? 'location' : 'false'} + aria-label={step.variant === 'isStatus' ? 'Assignment status' : `Step ${index + 1}` } + > {step.variant === 'isStatus' ? : index + 1} ; -export const ProgressBar = ({ steps, activeIndex, goToStep }: ProgressBarProps) => - {steps.map((step, index) => )} -; +export const ProgressBar = ({ steps, activeIndex, goToStep }: ProgressBarProps) => + + {steps.map((step, index) => )} + ; diff --git a/src/components/__snapshots__/ProgressBar.spec.tsx.snap b/src/components/__snapshots__/ProgressBar.spec.tsx.snap index 6e29d9d..df598f3 100644 --- a/src/components/__snapshots__/ProgressBar.spec.tsx.snap +++ b/src/components/__snapshots__/ProgressBar.spec.tsx.snap @@ -1,13 +1,16 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`ProgressBar matches snapshot 1`] = ` -
-
+ `; exports[`ProgressBar matches snapshot when active step is incomplete 1`] = ` -
-
+ `; exports[`ProgressBar matches snapshot when status step is active 1`] = ` -
-
+ `;