Fix P1 accessibility issues in Button and Card

Button:
- Add aria-busy={loading} for assistive technology
- Add visually-hidden "Loading" text for screen readers
- Mark CircularProgress as aria-hidden (decorative)

Card:
- Add tabIndex={0} and role="button" when interactive
- Fix Record<string, any> → Theme type for type safety

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-25 16:56:33 +11:00
parent 2f9b719f01
commit b2349d6c78
2 changed files with 33 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ import React from 'react';
import MuiCard from '@mui/material/Card';
import type { CardProps as MuiCardProps } from '@mui/material/Card';
import CardContent from '@mui/material/CardContent';
import type { Theme } from '@mui/material/styles';
// ─── Types ───────────────────────────────────────────────────────────────────
@@ -56,11 +57,17 @@ export const Card = React.forwardRef<HTMLDivElement, CardProps>(
// Map FA variant names to MUI Card variant
const muiVariant = variant === 'outlined' ? 'outlined' : undefined;
// Interactive cards need keyboard operability
const interactiveProps = interactive
? { tabIndex: 0 as const, role: 'button' as const }
: {};
return (
<MuiCard
ref={ref}
variant={muiVariant}
elevation={0}
{...interactiveProps}
sx={[
// Selected state: brand border + warm background
// Border width is always 2px (set in theme) — only colour changes here
@@ -81,7 +88,7 @@ export const Card = React.forwardRef<HTMLDivElement, CardProps>(
// Focus-visible for keyboard accessibility on interactive cards
interactive && {
'&:focus-visible': {
outline: (theme: Record<string, any>) =>
outline: (theme: Theme) =>
`2px solid ${theme.palette.primary.main}`,
outlineOffset: '2px',
},