"use client"; import { useState } from "react"; interface ColorPaletteProps { colors: string[]; } export function ColorPalette({ colors }: ColorPaletteProps) { const [copiedIdx, setCopiedIdx] = useState(null); if (colors.length === 0) return null; async function copyColor(color: string, idx: number) { try { await navigator.clipboard.writeText(color); setCopiedIdx(idx); setTimeout(() => setCopiedIdx(null), 2000); } catch { // Fallback: ignore } } // Show at most 8 colors const displayed = colors.slice(0, 8); return (
{displayed.map((color, i) => (
))} {colors.length > 8 && ( +{colors.length - 8} )}
); }