1
0
Fork 0
blog/src/components/templates/Post/Actions.tsx

57 lines
1.3 KiB
TypeScript
Raw Normal View History

2020-05-22 14:38:19 +02:00
import React, { ReactElement } from 'react'
2019-12-14 15:46:43 +01:00
import { useSiteMetadata } from '../../../hooks/use-site-metadata'
import * as styles from './Actions.module.css'
2019-12-14 15:46:43 +01:00
import Icon from '../../atoms/Icon'
2019-10-02 13:35:50 +02:00
2019-10-28 23:47:29 +01:00
interface ActionProps {
title: string
text: string
2021-03-14 01:34:04 +01:00
icon: string
2019-10-28 23:47:29 +01:00
url?: string
onClick?(): void
}
2019-10-02 13:35:50 +02:00
2021-03-14 01:34:04 +01:00
const Action = ({ title, text, url, icon, onClick }: ActionProps) => {
2019-10-02 15:32:01 +02:00
return (
<a className={styles.action} href={url} onClick={onClick}>
2021-03-14 01:34:04 +01:00
<Icon name={icon} />
<h1 className={styles.actionTitle}>{title}</h1>
<p className={styles.actionText}>{text}</p>
2019-10-02 15:32:01 +02:00
</a>
)
}
2019-10-02 13:35:50 +02:00
export default function PostActions({
slug,
githubLink
}: {
slug: string
githubLink: string
2020-05-22 14:38:19 +02:00
}): ReactElement {
2019-10-28 23:47:29 +01:00
const { siteUrl } = useSiteMetadata()
const urlTwitter = `https://twitter.com/intent/tweet?text=@kremalicious&url=${siteUrl}${slug}`
2019-10-02 13:35:50 +02:00
return (
<aside className={styles.actions}>
2019-10-28 23:47:29 +01:00
<Action
title="Have a comment?"
text="Hit me up @kremalicious"
url={urlTwitter}
2021-03-14 01:34:04 +01:00
icon="Twitter"
2019-10-28 23:47:29 +01:00
/>
<Action
title="Found something useful?"
2021-03-07 02:48:05 +01:00
text="Say thanks with BTC or ETH"
url="/thanks"
2021-03-14 01:34:04 +01:00
icon="Bitcoin"
2019-10-28 23:47:29 +01:00
/>
<Action
title="Edit on GitHub"
2021-03-07 02:48:05 +01:00
text="Contribute to this post"
2019-10-28 23:47:29 +01:00
url={githubLink}
2021-03-14 01:34:04 +01:00
icon="GitHub"
2019-10-28 23:47:29 +01:00
/>
2019-10-02 13:35:50 +02:00
</aside>
)
}