import { Check, ChevronDown, Copy } from "lucide-react";
import { useState } from "react";
import { toast } from "sonner";
export function Collapsible({
id,
title,
subtitle,
icon,
children,
}: {
id: string;
title: string;
subtitle?: string;
icon?: React.ReactNode;
children: React.ReactNode;
}) {
const [open, setOpen] = useState(false);
const contentId = `collapsible-${id}`;
return (
{open ? (
{children}
) : null}
);
}
export function CodeBlock({ code }: { code: string }) {
return (
);
}
export function CopyButton({
value,
successMessage,
iconOnly = false,
}: {
value: string;
successMessage: string;
iconOnly?: boolean;
}) {
const [copied, setCopied] = useState(false);
const handleCopy = async () => {
if (typeof navigator === "undefined" || !navigator.clipboard?.writeText) {
toast.error("Clipboard not available");
return;
}
try {
await navigator.clipboard.writeText(value);
toast.success(successMessage);
setCopied(true);
setTimeout(() => setCopied(false), 2000);
} catch {
toast.error("Could not copy to clipboard");
}
};
if (iconOnly) {
return (
);
}
return (
);
}