manifold/web/components/tweet-button.tsx

31 lines
817 B
TypeScript
Raw Permalink Normal View History

2022-01-04 22:47:56 +00:00
import clsx from 'clsx'
import TwitterLogo from 'web/lib/icons/twitter-logo'
import { trackCallback } from 'web/lib/service/analytics'
import { buttonClass } from './button'
2022-01-04 22:47:56 +00:00
export function TweetButton(props: { tweetText: string }) {
const { tweetText } = props
2022-01-04 20:57:48 +00:00
return (
<a
// #1da1f2 is twitter blue
className={clsx(
buttonClass('2xs', 'override'),
'gap-1 border-2 border-[#1da1f2] text-[#1da1f2] hover:bg-[#1da1f2] hover:text-white'
)}
href={getTweetHref(tweetText)}
onClick={trackCallback('share tweet')}
target="_blank"
2022-01-04 20:57:48 +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>
)
}
function getTweetHref(tweetText: string) {
return `https://twitter.com/intent/tweet?text=${encodeURIComponent(
tweetText ?? ''
)}`
}