Skip to content

Commit d58b4df

Browse files
committed
Merge branch 'develop' into slug-api-endpoint
2 parents 47e798a + cd6d95a commit d58b4df

File tree

4 files changed

+76
-7
lines changed

4 files changed

+76
-7
lines changed

Diff for: client/common/icons.jsx

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import React from 'react';
2+
import PropTypes from 'prop-types';
3+
import SortArrowUp from '../images/sort-arrow-up.svg';
4+
import SortArrowDown from '../images/sort-arrow-down.svg';
5+
import Github from '../images/github.svg';
6+
import Google from '../images/google.svg';
7+
import Plus from '../images/plus-icon.svg';
8+
import Close from '../images/close.svg';
9+
import DropdownArrow from '../images/down-filled-triangle.svg';
10+
11+
// HOC that adds the right web accessibility props
12+
// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
13+
14+
// could also give these a default size, color, etc. based on the theme
15+
// Need to add size to these - like small icon, medium icon, large icon. etc.
16+
function withLabel(SvgComponent) {
17+
const Icon = (props) => {
18+
const { 'aria-label': ariaLabel } = props;
19+
if (ariaLabel) {
20+
return (<SvgComponent
21+
{...props}
22+
aria-label={ariaLabel}
23+
role="img"
24+
focusable="false"
25+
/>);
26+
}
27+
return (<SvgComponent
28+
{...props}
29+
aria-hidden
30+
focusable="false"
31+
/>);
32+
};
33+
34+
Icon.propTypes = {
35+
'aria-label': PropTypes.string
36+
};
37+
38+
Icon.defaultProps = {
39+
'aria-label': null
40+
};
41+
42+
return Icon;
43+
}
44+
45+
export const SortArrowUpIcon = withLabel(SortArrowUp);
46+
export const SortArrowDownIcon = withLabel(SortArrowDown);
47+
export const GithubIcon = withLabel(Github);
48+
export const GoogleIcon = withLabel(Google);
49+
export const PlusIcon = withLabel(Plus);
50+
export const CloseIcon = withLabel(Close);
51+
export const DropdownArrowIcon = withLabel(DropdownArrow);

Diff for: client/common/icons.stories.jsx

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react';
2+
import { select } from '@storybook/addon-knobs';
3+
4+
import * as icons from './icons';
5+
6+
export default {
7+
title: 'Common/Icons',
8+
component: icons
9+
};
10+
11+
export const AllIcons = () => {
12+
const names = Object.keys(icons);
13+
14+
const SelectedIcon = icons[select('name', names, names[0])];
15+
return (
16+
<SelectedIcon />
17+
);
18+
};

Diff for: package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"enzyme-adapter-react-16": "^1.15.2",
9090
"eslint": "^4.19.1",
9191
"eslint-config-airbnb": "^16.1.0",
92-
"eslint-plugin-import": "^2.20.1",
92+
"eslint-plugin-import": "^2.20.2",
9393
"eslint-plugin-jsx-a11y": "^6.2.3",
9494
"eslint-plugin-react": "^7.18.3",
9595
"file-loader": "^2.0.0",

0 commit comments

Comments
 (0)