1
0
mirror of https://github.com/kremalicious/blog.git synced 2024-06-30 13:41:54 +02:00
blog/src/components/atoms/Icon.tsx

69 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-05-23 13:00:15 +02:00
import React, { FunctionComponent, ReactElement } from 'react'
2019-11-15 22:10:53 +01:00
// https://featherstyles.com
// import * as Feather from '@kremalicious/react-feather'
import {
ArrowDownCircle,
Edit,
GitHub,
Twitter,
Rss,
Sun,
Moon,
Compass,
X,
2019-11-17 14:18:49 +01:00
Copy,
Search,
ExternalLink,
Link,
ChevronRight,
2019-11-17 14:18:49 +01:00
ChevronLeft,
Camera,
Aperture,
Maximize,
Crosshair
} from '@kremalicious/react-feather'
2019-11-15 22:10:53 +01:00
// custom icons
import { ReactComponent as Jsonfeed } from '../../images/jsonfeed.svg'
import { ReactComponent as Bitcoin } from '../../images/bitcoin.svg'
2019-11-17 14:18:49 +01:00
import { ReactComponent as Stopwatch } from '../../images/stopwatch.svg'
import * as styles from './Icon.module.css'
2019-11-15 22:10:53 +01:00
2021-05-23 13:00:15 +02:00
const components: {
[key: string]: FunctionComponent<React.SVGProps<SVGSVGElement>>
} = {
Download: ArrowDownCircle,
2019-11-16 16:10:34 +01:00
Jsonfeed,
Bitcoin,
2019-11-17 14:18:49 +01:00
Stopwatch,
ArrowDownCircle,
Edit,
GitHub,
Twitter,
Rss,
Sun,
Moon,
Compass,
X,
2019-11-17 14:18:49 +01:00
Copy,
Search,
ExternalLink,
Link,
ChevronRight,
2019-11-17 14:18:49 +01:00
ChevronLeft,
Camera,
Aperture,
Maximize,
Crosshair
2019-11-16 16:10:34 +01:00
}
2019-11-15 22:10:53 +01:00
2021-03-14 01:34:04 +01:00
const Icon = ({ name, ...props }: { name: string }): ReactElement => {
2019-11-15 22:10:53 +01:00
const IconMapped = components[name]
// const IconFeather = (Feather as any)[name]
if (!IconMapped) return null
2019-11-15 22:10:53 +01:00
return <IconMapped className={styles.icon} {...props} />
2019-11-15 22:10:53 +01:00
}
export default Icon