Skip to content

Instantly share code, notes, and snippets.

@alex35mil
Last active April 6, 2017 05:01
Show Gist options
  • Save alex35mil/c39422958470d9f0e88793a23eddd9c2 to your computer and use it in GitHub Desktop.
Save alex35mil/c39422958470d9f0e88793a23eddd9c2 to your computer and use it in GitHub Desktop.
import createIcon from '.utils/createIcon';
import colors from './styles/colors';
const MyIcon = ({ color }) => (
<path fill={colors[color]} ... />
);
export default createIcon({
width: 16,
height: 16,
Icon: MyIcon,
});
import SvgIconTemplate from 'libs/templates/SvgIconTemplate';
export default ({ width, height, Icon }) => {
const WrappedIcon = ({
color,
title = Icon.name,
viewBoxWidth = width,
viewBoxHeight = height,
...otherProps
}) => (
<SvgIconTemplate {...{ title, viewBoxWidth, viewBoxHeight, ...otherProps }}>
<Icon {...{ color }} />
</SvgIconTemplate>
);
WrappedIcon.aspectRatio = width / height;
return WrappedIcon;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment