mirror of
https://github.com/mastermindzh/rickvanlieshout.com
synced 2025-07-27 12:42:28 +02:00
Add title to <Icon /> for accessibility
This commit is contained in:
@@ -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>
|
||||
);
|
||||
|
@@ -5,6 +5,7 @@ import Icon from './Icon';
|
||||
|
||||
describe('Icon', () => {
|
||||
const props = {
|
||||
name: 'test',
|
||||
icon: {
|
||||
viewBox: '0 0 0 0',
|
||||
path: '',
|
||||
|
@@ -5,6 +5,9 @@ exports[`Icon renders correctly 1`] = `
|
||||
className="icon"
|
||||
viewBox="0 0 0 0"
|
||||
>
|
||||
<title>
|
||||
test
|
||||
</title>
|
||||
<path
|
||||
d=""
|
||||
/>
|
||||
|
Reference in New Issue
Block a user