import { Check, Copy, Facebook, Linkedin, Share2, Twitter } from 'lucide-react'; import { useRef, useState } from 'react'; import { useOutsideClick } from '../hooks/use-outside-click.ts'; import { useCopyText } from '../hooks/use-copy-text.ts'; import { cn } from '../lib/classname.ts'; type ShareRoadmapButtonProps = { description: string; pageUrl: string; }; export function ShareRoadmapButton(props: ShareRoadmapButtonProps) { const { description, pageUrl } = props; const { isCopied, copyText } = useCopyText(); const containerRef = useRef(null); const [isDropdownOpen, setIsDropdownOpen] = useState(false); const twitterUrl = `https://twitter.com/intent/tweet?text=${description}&url=${pageUrl}`; const fbUrl = `https://www.facebook.com/sharer/sharer.php?quote=${description}&u=${pageUrl}`; const hnUrl = `https://news.ycombinator.com/submitlink?t=${description}&u=${pageUrl}`; const redditUrl = `https://www.reddit.com/submit?title=${description}&url=${pageUrl}`; const linkedinUrl = `https://www.linkedin.com/shareArticle?mini=true&url=${pageUrl}&title=${description}`; useOutsideClick(containerRef, () => { setIsDropdownOpen(false); }); return (
{isDropdownOpen && (
Twitter
Facebook
{'hackernews
Hacker News
{'reddit
Reddit
LinkedIn
)}
); }