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 (
-
+ aria-label={!props.children ? 'Ok' : undefined}
+ role={!props.children ? 'img' : undefined}
+ >
+
+
+
);
}
export function StatusWarning(props: PropsWithChildren<{}>) {
const classes = useStyles(props);
return (
-
+ aria-label={!props.children ? 'Warning' : undefined}
+ role={!props.children ? 'img' : undefined}
+ >
+
+
+
);
}
export function StatusError(props: PropsWithChildren<{}>) {
const classes = useStyles(props);
return (
-
+ aria-label={!props.children ? 'Error' : undefined}
+ role={!props.children ? 'img' : undefined}
+ >
+
+
+
);
}
export function StatusPending(props: PropsWithChildren<{}>) {
const classes = useStyles(props);
return (
-
+ aria-label={!props.children ? 'Pending' : undefined}
+ role={!props.children ? 'img' : undefined}
+ >
+
+
+
);
}
export function StatusRunning(props: PropsWithChildren<{}>) {
const classes = useStyles(props);
return (
-
+ aria-label={!props.children ? 'Running' : undefined}
+ role={!props.children ? 'img' : undefined}
+ >
+
+
+
);
}
export function StatusAborted(props: PropsWithChildren<{}>) {
const classes = useStyles(props);
return (
-
+ aria-label={!props.children ? 'Aborted' : undefined}
+ role={!props.children ? 'img' : undefined}
+ >
+
+
+
);
}
diff --git a/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx b/plugins/xcmetrics/src/components/StatusIcon/StatusIcon.test.tsx
index 0801a34b48..2a9f8f88e2 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('Status ok')).toBeInTheDocument();
+ expect(rendered.getByLabelText('Ok')).toBeInTheDocument();
rendered = await renderInTestApp();
- expect(rendered.getByLabelText('Status error')).toBeInTheDocument();
+ expect(rendered.getByLabelText('Error')).toBeInTheDocument();
rendered = await renderInTestApp();
- expect(rendered.getByLabelText('Status warning')).toBeInTheDocument();
+ expect(rendered.getByLabelText('Warning')).toBeInTheDocument();
});
it('should render invalid statuses', async () => {
const rendered = await renderInTestApp(
,
);
- expect(rendered.getByLabelText('Status aborted')).toBeInTheDocument();
+ expect(rendered.getByLabelText('Aborted')).toBeInTheDocument();
});
});