2020-05-27 00:20:54 +02:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2020-06-18 21:34:28 +02:00
|
|
|
import styled from 'styled-components';
|
2020-06-19 03:52:25 +02:00
|
|
|
import { prop } from '../theme';
|
2020-05-27 00:20:54 +02:00
|
|
|
import SortArrowUp from '../images/sort-arrow-up.svg';
|
|
|
|
import SortArrowDown from '../images/sort-arrow-down.svg';
|
|
|
|
import Github from '../images/github.svg';
|
|
|
|
import Google from '../images/google.svg';
|
|
|
|
import Plus from '../images/plus-icon.svg';
|
|
|
|
import Close from '../images/close.svg';
|
2020-06-18 21:34:28 +02:00
|
|
|
import Exit from '../images/exit.svg';
|
2020-05-27 00:20:54 +02:00
|
|
|
import DropdownArrow from '../images/down-filled-triangle.svg';
|
2020-06-29 19:40:54 +02:00
|
|
|
import Preferences from '../images/preferences.svg';
|
|
|
|
import Play from '../images/triangle-arrow-right.svg';
|
2020-07-21 23:33:10 +02:00
|
|
|
import More from '../images/more.svg';
|
2020-07-21 17:21:46 +02:00
|
|
|
import Code from '../images/code.svg';
|
2020-08-17 20:21:37 +02:00
|
|
|
import Save from '../images/save.svg';
|
2020-07-21 23:01:00 +02:00
|
|
|
import Terminal from '../images/terminal.svg';
|
2020-07-21 17:21:46 +02:00
|
|
|
|
2020-08-11 23:03:09 +02:00
|
|
|
import Folder from '../images/folder-padded.svg';
|
|
|
|
|
2020-08-07 20:03:18 +02:00
|
|
|
import CircleTerminal from '../images/circle-terminal.svg';
|
|
|
|
import CircleFolder from '../images/circle-folder.svg';
|
|
|
|
import CircleInfo from '../images/circle-info.svg';
|
|
|
|
|
2020-05-27 00:20:54 +02:00
|
|
|
|
|
|
|
// HOC that adds the right web accessibility props
|
|
|
|
// https://www.scottohara.me/blog/2019/05/22/contextual-images-svgs-and-a11y.html
|
|
|
|
|
|
|
|
// could also give these a default size, color, etc. based on the theme
|
|
|
|
// Need to add size to these - like small icon, medium icon, large icon. etc.
|
|
|
|
function withLabel(SvgComponent) {
|
|
|
|
const Icon = (props) => {
|
2020-06-18 21:34:28 +02:00
|
|
|
const StyledIcon = styled(SvgComponent)`
|
|
|
|
&&& {
|
|
|
|
color: ${prop('Icon.default')};
|
|
|
|
& g, & path, & polygon {
|
|
|
|
opacity: 1;
|
|
|
|
fill: ${prop('Icon.default')};
|
|
|
|
}
|
|
|
|
&:hover {
|
|
|
|
color: ${prop('Icon.hover')};
|
|
|
|
& g, & path, & polygon {
|
|
|
|
opacity: 1;
|
|
|
|
fill: ${prop('Icon.hover')};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-05-27 00:20:54 +02:00
|
|
|
const { 'aria-label': ariaLabel } = props;
|
|
|
|
if (ariaLabel) {
|
2020-06-18 21:34:28 +02:00
|
|
|
return (<StyledIcon
|
2020-05-27 00:20:54 +02:00
|
|
|
{...props}
|
|
|
|
aria-label={ariaLabel}
|
|
|
|
role="img"
|
|
|
|
focusable="false"
|
|
|
|
/>);
|
|
|
|
}
|
2020-06-18 21:34:28 +02:00
|
|
|
return (<StyledIcon
|
2020-05-27 00:20:54 +02:00
|
|
|
{...props}
|
|
|
|
aria-hidden
|
|
|
|
focusable="false"
|
|
|
|
/>);
|
|
|
|
};
|
|
|
|
|
|
|
|
Icon.propTypes = {
|
|
|
|
'aria-label': PropTypes.string
|
|
|
|
};
|
|
|
|
|
|
|
|
Icon.defaultProps = {
|
|
|
|
'aria-label': null
|
|
|
|
};
|
|
|
|
|
|
|
|
return Icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const SortArrowUpIcon = withLabel(SortArrowUp);
|
|
|
|
export const SortArrowDownIcon = withLabel(SortArrowDown);
|
|
|
|
export const GithubIcon = withLabel(Github);
|
|
|
|
export const GoogleIcon = withLabel(Google);
|
|
|
|
export const PlusIcon = withLabel(Plus);
|
|
|
|
export const CloseIcon = withLabel(Close);
|
2020-06-18 21:34:28 +02:00
|
|
|
export const ExitIcon = withLabel(Exit);
|
2020-05-27 00:20:54 +02:00
|
|
|
export const DropdownArrowIcon = withLabel(DropdownArrow);
|
2020-06-29 19:40:54 +02:00
|
|
|
export const PreferencesIcon = withLabel(Preferences);
|
|
|
|
export const PlayIcon = withLabel(Play);
|
2020-07-21 23:33:10 +02:00
|
|
|
export const MoreIcon = withLabel(More);
|
2020-07-21 23:01:00 +02:00
|
|
|
export const TerminalIcon = withLabel(Terminal);
|
2020-07-28 15:46:53 +02:00
|
|
|
export const CodeIcon = withLabel(Code);
|
2020-08-17 20:21:37 +02:00
|
|
|
export const SaveIcon = withLabel(Save);
|
2020-08-07 20:03:18 +02:00
|
|
|
|
2020-08-11 23:03:09 +02:00
|
|
|
export const FolderIcon = withLabel(Folder);
|
|
|
|
|
2020-08-07 20:03:18 +02:00
|
|
|
export const CircleTerminalIcon = withLabel(CircleTerminal);
|
|
|
|
export const CircleFolderIcon = withLabel(CircleFolder);
|
|
|
|
export const CircleInfoIcon = withLabel(CircleInfo);
|