1
0
Fork 0
blog/src/components/atoms/Icon.tsx

32 lines
732 B
TypeScript
Raw Normal View History

2019-11-15 22:10:53 +01:00
import React from 'react'
// https://featherstyles.com
import * as Feather from 'react-feather'
// custom icons
import { ReactComponent as Jsonfeed } from '../../images/jsonfeed.svg'
import { ReactComponent as Bitcoin } from '../../images/bitcoin.svg'
import styles from './Icon.module.scss'
2019-11-16 16:10:34 +01:00
const components: any = {
Download: Feather.ArrowDownCircle,
Blog: Feather.Edit,
Keybase: Feather.Key,
Jsonfeed,
Bitcoin
}
2019-11-15 22:10:53 +01:00
2019-11-16 16:10:34 +01:00
const Icon = ({ name }: { name: string }) => {
2019-11-15 22:10:53 +01:00
const IconMapped = components[name]
const Icon = (Feather as any)[name]
if (!IconMapped && !Icon) return null
return IconMapped ? (
<IconMapped className={styles.icon} />
) : (
<Icon className={styles.icon} />
)
}
export default Icon