2022-01-04 22:47:56 +00:00
|
|
|
import clsx from 'clsx'
|
|
|
|
|
2022-04-07 20:52:54 +00:00
|
|
|
export function TweetButton(props: { className?: string; tweetText: string }) {
|
2022-01-04 22:47:56 +00:00
|
|
|
const { tweetText, className } = props
|
2022-01-04 20:57:48 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<a
|
2022-03-21 21:54:09 +00:00
|
|
|
className={clsx('btn btn-xs flex-nowrap normal-case', className)}
|
2022-03-19 00:05:06 +00:00
|
|
|
style={{
|
|
|
|
backgroundColor: 'white',
|
|
|
|
border: '2px solid #1da1f2',
|
|
|
|
color: '#1da1f2',
|
|
|
|
}}
|
2022-04-07 20:52:54 +00:00
|
|
|
href={getTweetHref(tweetText)}
|
2022-01-04 22:34:07 +00:00
|
|
|
target="_blank"
|
2022-01-04 20:57:48 +00:00
|
|
|
>
|
2022-03-19 00:05:06 +00:00
|
|
|
<img className="mr-2" src={'/twitter-logo.svg'} 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 ?? ''
|
|
|
|
)}`
|
|
|
|
}
|