Removing SVG components

Sticking with importing data URIs for now
This commit is contained in:
Jeff Avallone
2018-02-11 06:45:39 -05:00
parent c368e9031f
commit 810b37aa47
7 changed files with 19 additions and 99 deletions
+2 -13
View File
@@ -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
};
+1 -2
View File
@@ -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>
+2 -2
View File
@@ -4,10 +4,10 @@ import ReactDOM from 'react-dom';
import '../style.css';
import Message from '../components/Message';
import ErrorIcon from '!svg-react-loader!feather-icons/dist/icons/alert-octagon.svg';
import errorIcon from 'feather-icons/dist/icons/alert-octagon.svg';
ReactDOM.render(
<Message icon={ ErrorIcon } heading="404 Page Not Found">
<Message icon={ errorIcon } heading="404 Page Not Found">
<p>The page you have requested could not be found</p>
</Message>,
document.getElementById('root'));
-1
View File
@@ -120,7 +120,6 @@ li {
margin: var(--spacing-margin) 0;
}
.message h2 svg,
.message h2 img {
margin-right: 0.5rem;
height: 3rem;