diff --git a/src/components/tutorial/TutorialWindow.tsx b/src/components/tutorial/TutorialWindow.tsx index e243e83..c595ee4 100644 --- a/src/components/tutorial/TutorialWindow.tsx +++ b/src/components/tutorial/TutorialWindow.tsx @@ -1,6 +1,6 @@ import { Tabs, TabsContent } from "@radix-ui/react-tabs"; import { useNavigate, useRouter, useSearch } from "@tanstack/react-router"; -import { DatabaseZapIcon, XIcon } from "lucide-react"; +import { CheckIcon, DatabaseZapIcon, LinkIcon, XIcon } from "lucide-react"; import { AnimatePresence, motion } from "motion/react"; import { useCallback, @@ -9,7 +9,8 @@ import { useRef, useState, } from "react"; -import { steps } from "@/data/tutorial"; +import { toast } from "sonner"; +import { steps as articles } from "@/data/tutorial"; import { useScrollShadow } from "@/hooks/use-scroll-shadow"; import { cn } from "@/lib/utils"; import { @@ -22,6 +23,65 @@ import { ScrollArea } from "../ui/scroll-area"; import { ScrollShadow } from "../ui/scroll-shadow"; import { TutorialTableOfContents } from "./TutorialTableOfContents"; +function CopyArticleLinkButton({ activeStep }: { activeStep: string | null }) { + const [copied, setCopied] = useState(false); + + const copyLink = useCallback(() => { + if (!activeStep) return; + + const url = new URL(window.location.href); + url.searchParams.set( + "article", + encodeURIComponent(activeStep.toLowerCase()), + ); + + navigator.clipboard + .writeText(url.toString()) + .then(() => { + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }) + .catch((_) => { + toast.error("Couldn't copy the url"); + }); + }, [activeStep]); + + return ( + + ); +} + function FloatingWindowHeader({ toggleWindow }: { toggleWindow: () => void }) { return (