Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make the progress bar accessible as breadcrumbs #67

Merged
merged 2 commits into from
Apr 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/components/ProgressBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -131,18 +131,25 @@ export type ProgressBarItemVariant = 'isCorrect' | 'isIncorrect' | 'isStatus' |

export const ProgressBarItem = <S extends {variant: ProgressBarItemVariant}>({index, isActive, step, goToStep}: ProgressBarItemProps<S>) =>
<StyledItemWrapper>
<StyledItem variant={step.variant} isActive={isActive} onClick={() => goToStep(index, step)}>
<StyledItem
variant={step.variant}
isActive={isActive}
onClick={() => goToStep(index, step)}
aria-current={isActive ? 'location' : 'false'}
aria-label={step.variant === 'isStatus' ? 'Assignment status' : `Step ${index + 1}` }
>
{step.variant === 'isStatus' ? <FlagIcon /> : index + 1}
</StyledItem>
<ItemIcon variant={step.variant} />
</StyledItemWrapper>;

export const ProgressBar = <S extends {variant: ProgressBarItemVariant}>({ steps, activeIndex, goToStep }: ProgressBarProps<S>) => <ProgressBarWrapper>
{steps.map((step, index) => <ProgressBarItem
key={index}
index={index}
isActive={index === activeIndex}
step={step}
goToStep={goToStep}
/>)}
</ProgressBarWrapper>;
export const ProgressBar = <S extends {variant: ProgressBarItemVariant}>({ steps, activeIndex, goToStep }: ProgressBarProps<S>) =>
<ProgressBarWrapper aria-label="Breadcrumbs">
{steps.map((step, index) => <ProgressBarItem
key={index}
index={index}
isActive={index === activeIndex}
step={step}
goToStep={goToStep}
/>)}
</ProgressBarWrapper>;
Loading