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