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

70 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 {
2023-01-29 22:58:19 +01:00
Aperture,
ArrowDownCircle,
2023-01-29 22:58:19 +01:00
Camera,
ChevronLeft,
ChevronRight,
Compass,
2019-11-17 14:18:49 +01:00
Copy,
2023-01-29 22:58:19 +01:00
Crosshair,
Edit,
ExternalLink,
2023-01-29 22:58:19 +01:00
GitHub,
Link,
2019-11-17 14:18:49 +01:00
Maximize,
2023-01-29 22:58:19 +01:00
Moon,
Rss,
Search,
Sun,
Twitter,
X
2022-12-25 16:16:25 +01:00
} from 'react-feather'
2023-01-29 22:58:19 +01:00
import { ReactComponent as Bitcoin } from '../../images/bitcoin.svg'
2019-11-15 22:10:53 +01:00
// custom icons
import { ReactComponent as Jsonfeed } from '../../images/jsonfeed.svg'
2023-01-26 19:36:45 +01:00
import { ReactComponent as Mastodon } from '../../images/mastodon.svg'
2023-01-29 22:58:19 +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,
2023-01-26 19:36:45 +01:00
Crosshair,
Mastodon
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