diff --git a/packages/components/package-lock.json b/packages/components/package-lock.json
index 35ebfb5b5..c669f9afd 100644
--- a/packages/components/package-lock.json
+++ b/packages/components/package-lock.json
@@ -7972,9 +7972,9 @@
"dev": true
},
"axe-core": {
- "version": "4.1.2",
- "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.1.2.tgz",
- "integrity": "sha512-V+Nq70NxKhYt89ArVcaNL9FDryB3vQOd+BFXZIfO3RP6rwtj+2yqqqdHEkacutglPaZLkJeuXKCjCJDMGPtPqg==",
+ "version": "4.3.2",
+ "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.3.2.tgz",
+ "integrity": "sha512-5LMaDRWm8ZFPAEdzTYmgjjEdj1YnQcpfrVajO/sn/LhbpGp0Y0H64c2hLZI1gRMxfA+w1S71Uc/nHaOXgcCvGg==",
"dev": true
},
"babel-jest": {
diff --git a/packages/components/package.json b/packages/components/package.json
index 78ec879aa..1b64e92a9 100644
--- a/packages/components/package.json
+++ b/packages/components/package.json
@@ -75,7 +75,7 @@
"@types/jest": "^26.0.24",
"@types/react": "^17.0.2",
"autoprefixer": "^10.2.4",
- "axe-core": "^4.1.2",
+ "axe-core": "^4.3.2",
"babel-jest": "^26.6.3",
"babel-loader": "^8.2.2",
"core-js": "^3.9.1",
diff --git a/packages/components/src/Button/__snapshots__/button.spec.tsx.snap b/packages/components/src/Button/__snapshots__/button.spec.tsx.snap
index 35830ce77..7ea6d3796 100644
--- a/packages/components/src/Button/__snapshots__/button.spec.tsx.snap
+++ b/packages/components/src/Button/__snapshots__/button.spec.tsx.snap
@@ -60,12 +60,14 @@ exports[` linkWithIcon story renders snapshot 1`] = `
Link with icon
@@ -89,12 +91,14 @@ exports[` outlineWithIcon story renders snapshot 1`] = `
Outline with icon
diff --git a/packages/components/src/Button/button.stories.tsx b/packages/components/src/Button/button.stories.tsx
index 456a9bbb6..bb062e629 100644
--- a/packages/components/src/Button/button.stories.tsx
+++ b/packages/components/src/Button/button.stories.tsx
@@ -1,4 +1,5 @@
import Button from "./button";
+import { CheckCircle } from "../Icons";
import React from "react";
import { Story } from "@storybook/react/types-6-0";
import Text from "../Text";
@@ -19,12 +20,6 @@ type Args = React.ComponentProps;
const Template: Story = (args) => ;
-const heartIcon = (
-
-
-
-);
-
export const flat = Template.bind(null);
flat.args = {
children: "Flat Button",
@@ -79,14 +74,22 @@ withDataTestId.args = {
export const linkWithIcon = Template.bind(null);
linkWithIcon.args = {
- children: <>Link with icon {heartIcon}>,
+ children: (
+ <>
+ Link with icon
+ >
+ ),
color: "success",
variant: "link",
};
export const outlineWithIcon = Template.bind(null);
outlineWithIcon.args = {
- children: <>Outline with icon {heartIcon}>,
+ children: (
+ <>
+ Outline with icon
+ >
+ ),
color: "warning",
variant: "outline",
};
diff --git a/packages/components/src/SvgIcon/SvgIcon.stories.tsx b/packages/components/src/SvgIcon/SvgIcon.stories.tsx
index b70a84026..8565775cb 100644
--- a/packages/components/src/SvgIcon/SvgIcon.stories.tsx
+++ b/packages/components/src/SvgIcon/SvgIcon.stories.tsx
@@ -17,10 +17,10 @@ export default {
options: Object.keys(allIcons),
},
},
- role: {
+ purpose: {
control: {
type: "radio",
- options: ["img", "presentation"],
+ options: ["informative", "decorative"],
},
},
size: {
@@ -49,7 +49,7 @@ const Template: Story = ({ icon, color, ...rest }) => {
const defaultArgs = {
icon: Object.keys(allIcons)[0] as keyof typeof allIcons,
- role: "presentation" as const,
+ role: "decorative" as const,
};
export const Small = Template.bind(null);
@@ -100,11 +100,11 @@ export const InText = ({ icon, ...rest }: Args) => {
return (
The svg icon defaults to the surrounding text size (
- , 1em), but
- often looks better with the line height (
+
+ , 1em), but often looks better with the line height (
@@ -130,7 +130,7 @@ export const AllIcons = () => {
{Object.entries(allIcons).map(([name, Icon]: [string, any]) => (
-
+
{name}
diff --git a/packages/components/src/SvgIcon/SvgIcon.tsx b/packages/components/src/SvgIcon/SvgIcon.tsx
index 48e5e7d9a..3fdd50a38 100644
--- a/packages/components/src/SvgIcon/SvgIcon.tsx
+++ b/packages/components/src/SvgIcon/SvgIcon.tsx
@@ -35,20 +35,33 @@ interface IconPropsBase {
viewBox?: string;
}
-interface FunctionalIconProps extends IconPropsBase {
- role: "img";
+interface InformativeIconProps extends IconPropsBase {
+ /**
+ * The role of the icon.
+ *
+ * Use "informative" when the icon **_does_** provide additional meaning to other text on the
+ * page. You'll be required to pass in a title to label the icon.
+ */
+ purpose: "informative";
title: string;
}
-interface PresentationalIconProps extends IconPropsBase {
- role: "presentation";
+interface DecorativeIconProps extends IconPropsBase {
+ /**
+ * The role of the icon.
+ *
+ * Use "decorative" when the icon **_does not_** provide any additional context or meaning to
+ * associated text. Basically the icon is for show and people don't need it to understand what's
+ * on the page.
+ */
+ purpose: "decorative";
}
-export type SvgIconProps = PresentationalIconProps | FunctionalIconProps;
+export type SvgIconProps = DecorativeIconProps | InformativeIconProps;
export type IconProps =
- | Omit
- | Omit;
+ | Omit
+ | Omit;
interface SvgStyle extends React.CSSProperties {
"--svg-icon-size"?: string;
@@ -65,7 +78,6 @@ function SvgIcon(props: SvgIconProps) {
children,
className,
color = "currentColor",
- role,
size,
viewBox = "0 0 24 24",
} = props;
@@ -78,7 +90,6 @@ function SvgIcon(props: SvgIconProps) {
className: clsx(className, styles.svgIcon, block && styles.displayBlock),
fill: color,
height: size,
- role,
/**
* height/width html properties are overriden by the defaults applied
* to svg css class
@@ -89,15 +100,19 @@ function SvgIcon(props: SvgIconProps) {
xmlns: "http://www.w3.org/2000/svg",
};
- if (props.role === "img") {
+ if (props.purpose === "informative") {
return (
-
+
{props.title}
{children}
);
} else {
- return {children} ;
+ return (
+
+ {children}
+
+ );
}
}
diff --git a/packages/components/src/SvgIcon/__snapshots__/SvgIcon.spec.tsx.snap b/packages/components/src/SvgIcon/__snapshots__/SvgIcon.spec.tsx.snap
index d8ab1a362..aee169e9d 100644
--- a/packages/components/src/SvgIcon/__snapshots__/SvgIcon.spec.tsx.snap
+++ b/packages/components/src/SvgIcon/__snapshots__/SvgIcon.spec.tsx.snap
@@ -2,9 +2,9 @@
exports[` CustomColor story renders snapshot 1`] = `
@@ -16,9 +16,9 @@ exports[` CustomColor story renders snapshot 1`] = `
exports[` CustomViewBox story renders snapshot 1`] = `
@@ -30,10 +30,10 @@ exports[` CustomViewBox story renders snapshot 1`] = `
exports[` FullScreen story renders snapshot 1`] = `
InText story renders snapshot 1`] = `
exports[` Large story renders snapshot 1`] = `
Large story renders snapshot 1`] = `
exports[` Medium story renders snapshot 1`] = `
Medium story renders snapshot 1`] = `
exports[` Small story renders snapshot 1`] = `
,
+ icon: ,
};
export const WithLongTextAndIcon = Template.bind(null);
WithLongTextAndIcon.args = {
...defaultArgs,
children: "This tag has a really long text message",
- icon: ,
+ icon: ,
};
diff --git a/packages/components/src/common/CloseButton/CloseButton.tsx b/packages/components/src/common/CloseButton/CloseButton.tsx
index 6ae9105e1..757ba7fde 100644
--- a/packages/components/src/common/CloseButton/CloseButton.tsx
+++ b/packages/components/src/common/CloseButton/CloseButton.tsx
@@ -36,7 +36,7 @@ const CloseButton = ({ className, color, onClose, size }: CloseButtonProps) => (
onClick={onClose}
variant="link"
>
-
+
);
diff --git a/packages/components/src/common/Notifications/NotificationIcon/NotificationIcon.tsx b/packages/components/src/common/Notifications/NotificationIcon/NotificationIcon.tsx
index 08bcdbed3..4129b20e1 100644
--- a/packages/components/src/common/Notifications/NotificationIcon/NotificationIcon.tsx
+++ b/packages/components/src/common/Notifications/NotificationIcon/NotificationIcon.tsx
@@ -53,7 +53,7 @@ const NotificationIcon = ({ variant }: Props) => {
return (
-
+
);
};