From d328727ceb1ffcb4f21cd68c205a9f937018a842 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Tue, 13 Feb 2018 21:28:31 -0500 Subject: [PATCH] Adding support for default icons based on Message type --- src/components/Message/index.js | 12 ++++++++++-- src/components/RavenError/__snapshots__/test.js.snap | 1 - src/components/RavenError/index.js | 3 +-- src/pages/404/Component.js | 3 +-- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/Message/index.js b/src/components/Message/index.js index 585cd99..f2921c5 100644 --- a/src/components/Message/index.js +++ b/src/components/Message/index.js @@ -3,7 +3,15 @@ import PropTypes from 'prop-types'; import style from './style.css'; -const renderIcon = icon => { +import AlertIcon from 'feather-icons/dist/icons/alert-octagon.svg'; + +const iconTypes = { + error: AlertIcon +}; + +const renderIcon = (type, icon) => { + icon = icon || iconTypes[type]; + if (!icon) { return; } @@ -15,7 +23,7 @@ const renderIcon = icon => { const Message = ({ type, icon, heading, children }) => (
-

{ renderIcon(icon) }{ heading }

+

{ renderIcon(type, icon) }{ heading }

{ children } diff --git a/src/components/RavenError/__snapshots__/test.js.snap b/src/components/RavenError/__snapshots__/test.js.snap index 6cae96e..6c3acbf 100644 --- a/src/components/RavenError/__snapshots__/test.js.snap +++ b/src/components/RavenError/__snapshots__/test.js.snap @@ -3,7 +3,6 @@ exports[`RavenError rendering 1`] = `

diff --git a/src/components/RavenError/index.js b/src/components/RavenError/index.js index a12e0f6..79032e9 100644 --- a/src/components/RavenError/index.js +++ b/src/components/RavenError/index.js @@ -4,7 +4,6 @@ import { translate, Trans } from 'react-i18next'; import { Raven } from 'sentry'; import Message from 'components/Message'; -import AlertIcon from 'feather-icons/dist/icons/alert-octagon.svg'; class RavenError extends React.Component { componentDidMount() { @@ -23,7 +22,7 @@ class RavenError extends React.Component { render() { const { t } = this.props; - return + return

This error has been logged. You may also fill out a report.

diff --git a/src/pages/404/Component.js b/src/pages/404/Component.js index d68afc7..23592b3 100644 --- a/src/pages/404/Component.js +++ b/src/pages/404/Component.js @@ -3,14 +3,13 @@ import PropTypes from 'prop-types'; import { translate, Trans } from 'react-i18next'; import Message from 'components/Message'; -import AlertIcon from 'feather-icons/dist/icons/alert-octagon.svg'; import Header from 'components/Header'; import Footer from 'components/Footer'; const Component = ({ t }) => (
- +

The page you have requested could not be found