import { useCallback, useState } from "react";
import { Copy, Check } from "lucide-react";
import {
Tabs,
TabsList,
TabsTrigger,
TabsContent,
} from "@/components/ui/tabs";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
interface ThemeExports {
css: string;
tailwind: string;
vscode: string;
json: string;
}
interface ThemeExportTabsProps {
exports: ThemeExports;
className?: string;
}
type TabKey = "css" | "tailwind" | "vscode" | "json";
const TABS: { key: TabKey; label: string }[] = [
{ key: "css", label: "CSS Variables" },
{ key: "tailwind", label: "Tailwind Config" },
{ key: "vscode", label: "VS Code Theme" },
{ key: "json", label: "JSON" },
];
function CopyButton({
text,
tabLabel,
}: {
text: string;
tabLabel: string;
}) {
const [copied, setCopied] = useState(false);
const handleCopy = useCallback(async () => {
try {
await navigator.clipboard.writeText(text);
setCopied(true);
window.setTimeout(() => setCopied(false), 2000);
} catch {
// clipboard write failed silently
}
}, [text]);
return (
);
}
export function ThemeExportTabs({ exports, className }: ThemeExportTabsProps) {
return (
{TABS.map((tab) => (
{tab.label}
))}
{TABS.map((tab) => (
{tab.label}
{exports[tab.key]}
))}
);
}