diff --git a/.changeset/four-humans-applaud.md b/.changeset/four-humans-applaud.md deleted file mode 100644 index 50ab681de9..0000000000 --- a/.changeset/four-humans-applaud.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@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 dc80acecc9..c1e1d42af2 100644 --- a/packages/core-components/src/components/Status/Status.test.tsx +++ b/packages/core-components/src/components/Status/Status.test.tsx @@ -28,52 +28,42 @@ import { describe('', () => { it('renders without exploding', async () => { - const { getByText } = await renderInTestApp(OK); - expect(getByText('OK')).toBeInTheDocument(); + const { getByLabelText } = await renderInTestApp(); + expect(getByLabelText('Status ok')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByText } = await renderInTestApp( - Warning, - ); - expect(getByText('Warning')).toBeInTheDocument(); + const { getByLabelText } = await renderInTestApp(); + expect(getByLabelText('Status warning')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByText } = await renderInTestApp( - Error, - ); - expect(getByText('Error')).toBeInTheDocument(); + const { getByLabelText } = await renderInTestApp(); + expect(getByLabelText('Status error')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByText } = await renderInTestApp( - Pending, - ); - expect(getByText('Pending')).toBeInTheDocument(); + const { getByLabelText } = await renderInTestApp(); + expect(getByLabelText('Status pending')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByText } = await renderInTestApp( - Running, - ); - expect(getByText('Running')).toBeInTheDocument(); + const { getByLabelText } = await renderInTestApp(); + expect(getByLabelText('Status running')).toBeInTheDocument(); }); }); describe('', () => { it('renders without exploding', async () => { - const { getByText } = await renderInTestApp( - Aborted, - ); - expect(getByText('Aborted')).toBeInTheDocument(); + const { getByLabelText } = await renderInTestApp(); + expect(getByLabelText('Status aborted')).toBeInTheDocument(); }); }); diff --git a/packages/core-components/src/components/Status/Status.tsx b/packages/core-components/src/components/Status/Status.tsx index ffe01cdb1b..364193e383 100644 --- a/packages/core-components/src/components/Status/Status.tsx +++ b/packages/core-components/src/components/Status/Status.tsx @@ -19,13 +19,6 @@ 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' @@ -38,43 +31,44 @@ export type StatusClassKey = const useStyles = makeStyles( theme => ({ status: { - alignItems: 'center', - display: 'flex', - flexFlow: 'row wrap', fontWeight: theme.typography.fontWeightMedium, - - '& > svg': { + '&::before': { + width: '0.7em', + height: '0.7em', + display: 'inline-block', marginRight: theme.spacing(1), + borderRadius: '50%', + content: '""', }, }, ok: { - '& > svg': { - fill: theme.palette.status.ok, + '&::before': { + backgroundColor: theme.palette.status.ok, }, }, warning: { - '& > svg': { - fill: theme.palette.status.warning, + '&::before': { + backgroundColor: theme.palette.status.warning, }, }, error: { - '& > svg': { - fill: theme.palette.status.error, + '&::before': { + backgroundColor: theme.palette.status.error, }, }, pending: { - '& > svg': { - fill: theme.palette.status.pending, + '&::before': { + backgroundColor: theme.palette.status.pending, }, }, running: { - '& > svg': { - fill: theme.palette.status.running, + '&::before': { + backgroundColor: theme.palette.status.running, }, }, aborted: { - '& > svg': { - fill: theme.palette.status.aborted, + '&::before': { + backgroundColor: theme.palette.status.aborted, }, }, }), @@ -83,85 +77,78 @@ const useStyles = makeStyles( export function StatusOK(props: PropsWithChildren<{}>) { const classes = useStyles(props); - return ( -
- - -
+ aria-label="Status ok" + aria-hidden="true" + {...props} + /> ); } export function StatusWarning(props: PropsWithChildren<{}>) { const classes = useStyles(props); return ( -
- - -
+ aria-label="Status warning" + aria-hidden="true" + {...props} + /> ); } export function StatusError(props: PropsWithChildren<{}>) { const classes = useStyles(props); return ( -
- - -
+ aria-label="Status error" + aria-hidden="true" + {...props} + /> ); } export function StatusPending(props: PropsWithChildren<{}>) { const classes = useStyles(props); return ( -
- - -
+ aria-label="Status pending" + aria-hidden="true" + {...props} + /> ); } export function StatusRunning(props: PropsWithChildren<{}>) { const classes = useStyles(props); return ( -
- - -
+ aria-label="Status running" + aria-hidden="true" + {...props} + /> ); } export function StatusAborted(props: PropsWithChildren<{}>) { const classes = useStyles(props); return ( -
- - -
+ aria-label="Status aborted" + aria-hidden="true" + {...props} + /> ); } diff --git a/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx index 2a9f8f88e2..0801a34b48 100644 --- a/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx +++ b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx @@ -24,19 +24,19 @@ describe('StatusIcon', () => { let rendered = await renderInTestApp( , ); - expect(rendered.getByLabelText('Ok')).toBeInTheDocument(); + expect(rendered.getByLabelText('Status ok')).toBeInTheDocument(); rendered = await renderInTestApp(); - expect(rendered.getByLabelText('Error')).toBeInTheDocument(); + expect(rendered.getByLabelText('Status error')).toBeInTheDocument(); rendered = await renderInTestApp(); - expect(rendered.getByLabelText('Warning')).toBeInTheDocument(); + expect(rendered.getByLabelText('Status warning')).toBeInTheDocument(); }); it('should render invalid statuses', async () => { const rendered = await renderInTestApp( , ); - expect(rendered.getByLabelText('Aborted')).toBeInTheDocument(); + expect(rendered.getByLabelText('Status aborted')).toBeInTheDocument(); }); });