diff --git a/src/components/copy-button.tsx b/src/components/copy-button.tsx index f4eafa4..1e8922c 100644 --- a/src/components/copy-button.tsx +++ b/src/components/copy-button.tsx @@ -1,21 +1,25 @@ "use client"; -import { Copy } from "lucide-react"; +import { useState } from "react"; +import { Copy, Check } from "lucide-react"; import { Button } from "./ui/button"; -import { toast } from "sonner"; export function CopyButton({ text }: { text: string }) { + const [copied, setCopied] = useState(false); + + const handleCopy = () => { + navigator.clipboard.writeText(text); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }; + return ( -
- -
+ ); } diff --git a/src/components/download-button.tsx b/src/components/download-button.tsx new file mode 100644 index 0000000..d15b0ae --- /dev/null +++ b/src/components/download-button.tsx @@ -0,0 +1,30 @@ +"use client"; + +import { Download } from "lucide-react"; +import { Button } from "./ui/button"; + +export function DownloadButton({ + content, + filename, +}: { + content: string; + filename: string; +}) { + const handleDownload = () => { + const blob = new Blob([content], { type: "application/xml" }); + const url = URL.createObjectURL(blob); + const a = document.createElement("a"); + a.href = url; + a.download = filename; + document.body.appendChild(a); + a.click(); + document.body.removeChild(a); + URL.revokeObjectURL(url); + }; + + return ( + + ); +}