diff --git a/.changeset/four-humans-applaud.md b/.changeset/four-humans-applaud.md new file mode 100644 index 0000000000..50ab681de9 --- /dev/null +++ b/.changeset/four-humans-applaud.md @@ -0,0 +1,5 @@ +--- +'@backstage/core-components': patch +--- + +Updates the Status component to fix use of color and voice over accessibility issues. 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..ffe01cdb1b 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 CheckIcon from '@material-ui/icons/Check'; +import WarningIcon from '@material-ui/icons/Warning'; +import ErrorIcon from '@material-ui/icons/Error'; +import HighlightOffIcon from '@material-ui/icons/HighlightOff'; +import ScheduleIcon from '@material-ui/icons/Schedule'; +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 ( -