2022-01-04 22:47:56 +00:00
|
|
|
import clsx from 'clsx'
|
2022-10-05 22:51:10 +00:00
|
|
|
import TwitterLogo from 'web/lib/icons/twitter-logo'
|
2022-06-15 21:34:34 +00:00
|
|
|
import { trackCallback } from 'web/lib/service/analytics'
|
2022-10-05 22:51:10 +00:00
|
|
|
import { buttonClass } from './button'
|
2022-01-04 22:47:56 +00:00
|
|
|
|
2022-10-05 22:51:10 +00:00
|
|
|
export function TweetButton(props: { tweetText: string }) {
|
|
|
|
const { tweetText } = props
|
2022-01-04 20:57:48 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<a
|
2022-10-05 22:51:10 +00:00
|
|
|
// #1da1f2 is twitter blue
|
|
|
|
className={clsx(
|
|
|
|
buttonClass('2xs', 'override'),
|
|
|
|
'gap-1 border-2 border-[#1da1f2] text-[#1da1f2] hover:bg-[#1da1f2] hover:text-white'
|
|
|
|
)}
|
2022-04-07 20:52:54 +00:00
|
|
|
href={getTweetHref(tweetText)}
|
2022-06-15 21:34:34 +00:00
|
|
|
onClick={trackCallback('share tweet')}
|
2022-01-04 22:34:07 +00:00
|
|
|
target="_blank"
|
2022-01-04 20:57:48 +00:00
|
|
|
>
|
2022-10-05 22:51:10 +00:00
|
|
|
<TwitterLogo width={15} height={15} />
|
2022-01-11 16:29:54 +00:00
|
|
|
<div>Tweet</div>
|
2022-01-04 20:57:48 +00:00
|
|
|
</a>
|
|
|
|
)
|
|
|
|
}
|
2022-04-07 20:52:54 +00:00
|
|
|
|
|
|
|
function getTweetHref(tweetText: string) {
|
|
|
|
return `https://twitter.com/intent/tweet?text=${encodeURIComponent(
|
|
|
|
tweetText ?? ''
|
|
|
|
)}`
|
|
|
|
}
|