Add title to <Icon /> for accessibility

This commit is contained in:
Victor Zhou
2019-07-24 23:24:07 -04:00
parent d1aa92184e
commit 96b487cd9a
13 changed files with 170 additions and 2 deletions

View File

@@ -3,14 +3,16 @@ import React from 'react';
import styles from './Icon.module.scss';
type Props = {
name: string,
icon: {
viewBox?: string,
path?: string
}
};
const Icon = ({ icon }: Props) => (
const Icon = ({ name, icon }: Props) => (
<svg className={styles['icon']} viewBox={icon.viewBox}>
<title>{name}</title>
<path d={icon.path} />
</svg>
);

View File

@@ -5,6 +5,7 @@ import Icon from './Icon';
describe('Icon', () => {
const props = {
name: 'test',
icon: {
viewBox: '0 0 0 0',
path: '',

View File

@@ -5,6 +5,9 @@ exports[`Icon renders correctly 1`] = `
className="icon"
viewBox="0 0 0 0"
>
<title>
test
</title>
<path
d=""
/>