Removing SVG components
Sticking with importing data URIs for now
This commit is contained in:
@@ -1,19 +1,12 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
//import style from './style.css';
|
||||
|
||||
const renderIcon = icon => {
|
||||
if (!icon) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (typeof icon === 'string') {
|
||||
return <img src={ icon }/>;
|
||||
} else {
|
||||
const Icon = icon;
|
||||
return <Icon/>;
|
||||
}
|
||||
return <img src={ icon }/>;
|
||||
};
|
||||
|
||||
const Message = ({ icon, heading, children }) => (
|
||||
@@ -24,11 +17,7 @@ const Message = ({ icon, heading, children }) => (
|
||||
);
|
||||
|
||||
Message.propTypes = {
|
||||
icon: PropTypes.oneOfType([
|
||||
PropTypes.element,
|
||||
PropTypes.func,
|
||||
PropTypes.string
|
||||
]),
|
||||
icon: PropTypes.string,
|
||||
heading: PropTypes.string.isRequired,
|
||||
children: PropTypes.element.isRequired
|
||||
};
|
||||
|
||||
@@ -14,9 +14,8 @@ test('Message rendering', () => {
|
||||
});
|
||||
|
||||
test('Message rendering with icon', () => {
|
||||
const Icon = () => 'Sample icon SVG';
|
||||
const component = renderer.create(
|
||||
<Message heading="Testing" icon={ Icon }>
|
||||
<Message heading="Testing" icon="sample-icon-url">
|
||||
<p>Message content</p>
|
||||
</Message>
|
||||
);
|
||||
|
||||
@@ -18,7 +18,9 @@ exports[`Message rendering with icon 1`] = `
|
||||
className="message"
|
||||
>
|
||||
<h2>
|
||||
Sample icon SVG
|
||||
<img
|
||||
src="sample-icon-url"
|
||||
/>
|
||||
Testing
|
||||
</h2>
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user