From 909153e817515a146d8444a6c91d3e7352d15a1f Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Sun, 17 Nov 2019 02:28:31 +0100 Subject: [PATCH] selectively import icons --- README.md | 4 +++ src/components/atoms/Icon.jsx | 49 ++++++++++++++++++++++++----------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index b215a71..8b90770 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,10 @@ You can simply use [Docker](https://www.docker.com) & [Docker Compose](https://d git clone git@github.com:kremalicious/portfolio.git cd portfolio/ +# GATSBY_GITHUB_TOKEN is required for some parts +cp .env.sample .env +vi .env + # use Docker docker-compose up diff --git a/src/components/atoms/Icon.jsx b/src/components/atoms/Icon.jsx index 2ab0022..582674c 100644 --- a/src/components/atoms/Icon.jsx +++ b/src/components/atoms/Icon.jsx @@ -2,31 +2,50 @@ import React from 'react' import PropTypes from 'prop-types' // https://featherstyles.com -import * as Feather from 'react-feather' +// import * as Feather from 'react-feather' +import { + ArrowDownCircle, + Edit, + GitHub, + Twitter, + Rss, + Sun, + Moon, + Compass, + FileText, + Key, + Image +} from 'react-feather' import { ReactComponent as Dribbble } from '../../images/dribbble.svg' import styles from './Icon.module.scss' const Icon = ({ name, ...props }) => { const components = { Dribbble, - Link: Feather.Compass, - Download: Feather.ArrowDownCircle, - 'Info & Download': Feather.ArrowDownCircle, - Styleguide: Feather.FileText, - Blog: Feather.Edit, - Keybase: Feather.Key + Link: Compass, + Download: ArrowDownCircle, + 'Info & Download': ArrowDownCircle, + Styleguide: FileText, + Blog: Edit, + Keybase: Key, + ArrowDownCircle, + Edit, + GitHub, + Twitter, + Rss, + Sun, + Moon, + Compass, + FileText, + Key, + Image } const IconMapped = components[name] - const Icon = Feather[name] + // const IconComp = Feather[name] + if (!IconMapped) return null - if (!IconMapped && !Icon) return null - - return IconMapped ? ( - - ) : ( - - ) + return } Icon.propTypes = {