From 1a1e475696b98444166e6fd9f3960b5b07883be3 Mon Sep 17 00:00:00 2001 From: Nicholas Pappas Date: Fri, 30 Jun 2023 20:25:33 -0700 Subject: [PATCH 1/3] Fix Status a11y concerns Signed-off-by: Nicholas Pappas --- .../src/components/Status/Status.test.tsx | 34 +++-- .../src/components/Status/Status.tsx | 121 ++++++++++-------- 2 files changed, 89 insertions(+), 66 deletions(-) diff --git a/packages/core-components/src/components/Status/Status.test.tsx b/packages/core-components/src/components/Status/Status.test.tsx index c1e1d42af2..dc80acecc9 100644 --- a/packages/core-components/src/components/Status/Status.test.tsx +++ b/packages/core-components/src/components/Status/Status.test.tsx @@ -28,42 +28,52 @@ import { describe('', () => { it('renders without exploding', async () => { - const { getByLabelText } = await renderInTestApp(); - expect(getByLabelText('Status ok')).toBeInTheDocument(); + const { getByText } = await renderInTestApp(OK); + expect(getByText('OK')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByLabelText } = await renderInTestApp(); - expect(getByLabelText('Status warning')).toBeInTheDocument(); + const { getByText } = await renderInTestApp( + Warning, + ); + expect(getByText('Warning')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByLabelText } = await renderInTestApp(); - expect(getByLabelText('Status error')).toBeInTheDocument(); + const { getByText } = await renderInTestApp( + Error, + ); + expect(getByText('Error')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByLabelText } = await renderInTestApp(); - expect(getByLabelText('Status pending')).toBeInTheDocument(); + const { getByText } = await renderInTestApp( + Pending, + ); + expect(getByText('Pending')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByLabelText } = await renderInTestApp(); - expect(getByLabelText('Status running')).toBeInTheDocument(); + const { getByText } = await renderInTestApp( + Running, + ); + expect(getByText('Running')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByLabelText } = await renderInTestApp(); - expect(getByLabelText('Status aborted')).toBeInTheDocument(); + const { getByText } = await renderInTestApp( + Aborted, + ); + expect(getByText('Aborted')).toBeInTheDocument(); }); }); diff --git a/packages/core-components/src/components/Status/Status.tsx b/packages/core-components/src/components/Status/Status.tsx index 364193e383..f3bdf4e0f2 100644 --- a/packages/core-components/src/components/Status/Status.tsx +++ b/packages/core-components/src/components/Status/Status.tsx @@ -19,6 +19,13 @@ import Typography from '@material-ui/core/Typography'; import classNames from 'classnames'; import React, { PropsWithChildren } from 'react'; +import CheckCircleIcon from '@material-ui/icons/CheckCircle'; +import WarningIcon from '@material-ui/icons/Warning'; +import ErrorIcon from '@material-ui/icons/Error'; +import HighlightOffIcon from '@material-ui/icons/HighlightOff'; +import WatchLaterIcon from '@material-ui/icons/WatchLater'; +import DirectionsRunIcon from '@material-ui/icons/DirectionsRun'; + export type StatusClassKey = | 'status' | 'ok' @@ -31,44 +38,43 @@ export type StatusClassKey = const useStyles = makeStyles( theme => ({ status: { + alignItems: 'center', + display: 'flex', + flexFlow: 'row wrap', fontWeight: theme.typography.fontWeightMedium, - '&::before': { - width: '0.7em', - height: '0.7em', - display: 'inline-block', + + '& > svg': { marginRight: theme.spacing(1), - borderRadius: '50%', - content: '""', }, }, ok: { - '&::before': { - backgroundColor: theme.palette.status.ok, + '& > svg': { + fill: theme.palette.status.ok, }, }, warning: { - '&::before': { - backgroundColor: theme.palette.status.warning, + '& > svg': { + fill: theme.palette.status.warning, }, }, error: { - '&::before': { - backgroundColor: theme.palette.status.error, + '& > svg': { + fill: theme.palette.status.error, }, }, pending: { - '&::before': { - backgroundColor: theme.palette.status.pending, + '& > svg': { + fill: theme.palette.status.pending, }, }, running: { - '&::before': { - backgroundColor: theme.palette.status.running, + '& > svg': { + fill: theme.palette.status.running, }, }, aborted: { - '&::before': { - backgroundColor: theme.palette.status.aborted, + '& > svg': { + fill: theme.palette.status.aborted, }, }, }), @@ -77,78 +83,85 @@ const useStyles = makeStyles( export function StatusOK(props: PropsWithChildren<{}>) { const classes = useStyles(props); + return ( -