SVG Icon grows to container size
This commit is contained in:
parent
a2145ad979
commit
ec1c8210a1
1 changed files with 8 additions and 1 deletions
|
@ -3,6 +3,7 @@ import InlineSVG from 'react-inlinesvg';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
|
import styled from 'styled-components';
|
||||||
|
|
||||||
const icons = {
|
const icons = {
|
||||||
sortArrowUp: require('../images/sort-arrow-up.svg'),
|
sortArrowUp: require('../images/sort-arrow-up.svg'),
|
||||||
|
@ -24,10 +25,16 @@ const names = lodash.mapValues(icons, (value, key) => key);
|
||||||
|
|
||||||
export const ValidIconNameType = PropTypes.oneOf(Object.keys(names));
|
export const ValidIconNameType = PropTypes.oneOf(Object.keys(names));
|
||||||
|
|
||||||
|
const StyledInlineSVG = styled(InlineSVG)`
|
||||||
|
> svg {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
function Icon({ name, ...props }) {
|
function Icon({ name, ...props }) {
|
||||||
return (
|
return (
|
||||||
<InlineSVG src={icons[name]} {...props} />
|
<StyledInlineSVG src={icons[name]} {...props} />
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue