2019-11-18 00:58:19 +01:00
|
|
|
import React from 'react'
|
2019-10-02 15:32:01 +02:00
|
|
|
import { useSiteMetadata } from '../../hooks/use-site-metadata'
|
2019-11-15 22:10:53 +01:00
|
|
|
import styles from './PostActions.module.scss'
|
|
|
|
import Icon from '../../components/atoms/Icon'
|
2019-10-02 13:35:50 +02:00
|
|
|
|
2019-10-28 23:47:29 +01:00
|
|
|
interface ActionProps {
|
|
|
|
title: string
|
|
|
|
text: string
|
|
|
|
url?: string
|
|
|
|
onClick?(): void
|
|
|
|
}
|
2019-10-02 13:35:50 +02:00
|
|
|
|
2019-11-15 22:10:53 +01:00
|
|
|
const IconComp = ({ text }: { text: string }) =>
|
2019-10-28 23:47:29 +01:00
|
|
|
text.includes('GitHub') ? (
|
2019-11-15 22:10:53 +01:00
|
|
|
<Icon name="GitHub" />
|
2019-10-28 23:47:29 +01:00
|
|
|
) : text.includes('Bitcoin') ? (
|
2019-11-15 22:10:53 +01:00
|
|
|
<Icon name="Bitcoin" />
|
2019-10-28 23:47:29 +01:00
|
|
|
) : (
|
2019-11-15 22:10:53 +01:00
|
|
|
<Icon name="Twitter" />
|
2019-10-28 23:47:29 +01:00
|
|
|
)
|
2019-10-02 15:32:01 +02:00
|
|
|
|
2019-10-28 23:47:29 +01:00
|
|
|
const Action = ({ title, text, url, onClick }: ActionProps) => {
|
2019-10-02 15:32:01 +02:00
|
|
|
return (
|
2019-10-28 23:47:29 +01:00
|
|
|
<a className={styles.action} href={url} onClick={onClick}>
|
2019-11-15 22:10:53 +01:00
|
|
|
<IconComp text={text} />
|
2019-10-28 23:47:29 +01:00
|
|
|
<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
|
|
|
|
}) {
|
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}
|
|
|
|
/>
|
|
|
|
<Action
|
|
|
|
title="Found something useful?"
|
2019-11-15 22:10:53 +01:00
|
|
|
text="Say thanks with Bitcoin or Ether"
|
2019-11-17 23:56:29 +01:00
|
|
|
url="/thanks"
|
2019-10-28 23:47:29 +01:00
|
|
|
/>
|
|
|
|
<Action
|
|
|
|
title="Edit on GitHub"
|
|
|
|
text="Contribute to this post on GitHub"
|
|
|
|
url={githubLink}
|
|
|
|
/>
|
2019-10-02 13:35:50 +02:00
|
|
|
</aside>
|
|
|
|
)
|
|
|
|
}
|