Switching back to SVG components for icons

No longer need the hack to only use them in components while URLs are
used in styles since I don't need icons in the styles anymore. Embedding
the markup also provides the option to restyle the icons
This commit is contained in:
Jeff Avallone
2018-02-11 06:58:59 -05:00
parent 1de5079aa9
commit 49a236bf89
9 changed files with 98 additions and 35 deletions
+6 -2
View File
@@ -6,7 +6,8 @@ const renderIcon = icon => {
return;
}
return <img src={ icon }/>;
const Icon = icon;
return <Icon/>;
};
const Message = ({ icon, heading, children }) => (
@@ -17,7 +18,10 @@ const Message = ({ icon, heading, children }) => (
);
Message.propTypes = {
icon: PropTypes.string,
icon: PropTypes.oneOfType([
PropTypes.element,
PropTypes.func
]),
heading: PropTypes.string.isRequired,
children: PropTypes.element.isRequired
};
+2 -1
View File
@@ -14,8 +14,9 @@ test('Message rendering', () => {
});
test('Message rendering with icon', () => {
const Icon = () => 'Sample icon SVG';
const component = renderer.create(
<Message heading="Testing" icon="sample-icon-url">
<Message heading="Testing" icon={ Icon }>
<p>Message content</p>
</Message>
);
@@ -18,9 +18,7 @@ exports[`Message rendering with icon 1`] = `
className="message"
>
<h2>
<img
src="sample-icon-url"
/>
Sample icon SVG
Testing
</h2>
<p>