2020-04-19 18:30:32 +00:00
|
|
|
/* eslint-disable global-require */
|
|
|
|
import InlineSVG from 'react-inlinesvg';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import React from 'react';
|
|
|
|
import lodash from 'lodash';
|
2020-04-27 08:20:07 +00:00
|
|
|
import styled from 'styled-components';
|
2020-04-19 18:30:32 +00:00
|
|
|
|
|
|
|
const icons = {
|
2020-04-26 10:43:58 +00:00
|
|
|
sortArrowUp: require('../images/sort-arrow-up.svg'),
|
|
|
|
sortArrowDown: require('../images/sort-arrow-down.svg'),
|
2020-04-19 18:30:32 +00:00
|
|
|
github: require('../images/github.svg'),
|
|
|
|
google: require('../images/google.svg'),
|
2020-04-26 10:43:58 +00:00
|
|
|
plus: require('../images/plus-icon.svg'),
|
|
|
|
close: require('../images/close.svg'),
|
2020-04-19 18:30:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
names will be an mirror-object of icon names:
|
|
|
|
{
|
|
|
|
github: 'github',
|
|
|
|
...
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
const names = lodash.mapValues(icons, (value, key) => key);
|
|
|
|
|
2020-04-26 13:32:50 +00:00
|
|
|
export const ValidIconNameType = PropTypes.oneOf(Object.keys(names));
|
|
|
|
|
2020-04-27 08:20:07 +00:00
|
|
|
const StyledInlineSVG = styled(InlineSVG)`
|
|
|
|
> svg {
|
|
|
|
width: 100%;
|
|
|
|
height: 100%;
|
|
|
|
}
|
|
|
|
`;
|
2020-04-19 18:30:32 +00:00
|
|
|
|
|
|
|
function Icon({ name, ...props }) {
|
|
|
|
return (
|
2020-04-27 08:20:07 +00:00
|
|
|
<StyledInlineSVG src={icons[name]} {...props} />
|
2020-04-19 18:30:32 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-26 13:32:50 +00:00
|
|
|
|
2020-04-19 18:30:32 +00:00
|
|
|
Icon.names = names;
|
|
|
|
|
|
|
|
Icon.propTypes = {
|
2020-04-26 13:32:50 +00:00
|
|
|
name: ValidIconNameType.isRequired
|
2020-04-19 18:30:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export default Icon;
|