"use client" import { useState } from "react" import { useComposer } from "@/contexts/composer-context" import { ScrollArea } from "@/components/ui/scroll-area" import { Button } from "@/components/ui/button" import { Card, CardContent } from "@/components/ui/card" import { ChevronLeft } from "lucide-react" import { cn } from "@/lib/utils" import { componentIds, getComponent } from "./component-variants-registry" // Fixed border radius for UI components const UI_BORDER_RADIUS = "6px" // Foundation items const foundationItems = [ { name: "Color", id: "color" }, { name: "Iconography", id: "iconography" }, { name: "Typography", id: "typography" }, { name: "Spacing", id: "spacing" }, { name: "Elevation", id: "elevation" }, ] // Component items - filter to only include components that exist in the registry const componentItems = [ { name: "Accordion", id: "accordion" }, { name: "Alert", id: "alerts" }, { name: "Avatar", id: "avatars" }, { name: "Badge", id: "badges" }, { name: "Button", id: "buttons" }, { name: "Card", id: "cards" }, { name: "Checkbox", id: "checkbox" }, { name: "Dropdown", id: "dropdowns" }, { name: "Input", id: "input" }, { name: "Progress", id: "progress" }, { name: "Separator", id: "separator" }, { name: "Slider", id: "slider" }, { name: "Switch", id: "switch" }, { name: "Tabs", id: "tabs" }, { name: "Textarea", id: "textarea" }, ].filter((item) => componentIds.includes(item.id)) // Block items const blockItems = [{ name: "Contact Form", id: "contact-form" }].filter((item) => componentIds.includes(item.id)) export function ComponentPalette() { const { addComponent } = useComposer() const [selectedComponent, setSelectedComponent] = useState(null) // Function to handle adding a component variant const handleAddVariant = (componentId: string, variantId: string) => { addComponent({ type: "component-variant", componentId, variantId, }) // Optionally, go back to the component list setSelectedComponent(null) } // If a component is selected, show its variants if (selectedComponent) { const component = getComponent(selectedComponent) if (!component) { return
Component not found
} return (

{component.name} Variants

{component.variants.map((variant) => (
{variant.component}
{variant.name}
))}
) } // Otherwise, show the component list return (

Component Palette

{/* Components section */}

COMPONENTS

{/* Blocks section */}

BLOCKS

) }