'use client'
import * as React from 'react'
import { BlockType } from './types'
import { Button } from '../ui/button'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '../ui/dropdown-menu'
import {
Plus,
Type,
BarChart3,
Minus,
MousePointerClick,
ImageIcon,
ArrowUpDown,
Share2,
Building2,
FileText,
} from 'lucide-react'
interface BlockOption {
type: BlockType
label: string
icon: React.ReactNode
description: string
category: 'content' | 'layout' | 'preset'
}
const BLOCK_OPTIONS: BlockOption[] = [
// Content blocks
{ type: 'text', label: 'Text', icon: , description: 'Rich text content', category: 'content' },
{ type: 'image', label: 'Image', icon: , description: 'Image with caption', category: 'content' },
{ type: 'cta', label: 'Button', icon: , description: 'Call to action button', category: 'content' },
{ type: 'metrics', label: 'Metrics', icon: , description: 'KPI grid', category: 'content' },
// Layout blocks
{ type: 'divider', label: 'Divider', icon: , description: 'Visual separator', category: 'layout' },
{ type: 'spacer', label: 'Spacer', icon: , description: 'Vertical spacing', category: 'layout' },
// Preset blocks
{ type: 'header', label: 'Header', icon: , description: 'Logo + company name', category: 'preset' },
{ type: 'footer', label: 'Footer', icon: , description: 'Unsubscribe + address', category: 'preset' },
{ type: 'social', label: 'Social Links', icon: , description: 'Social media icons', category: 'preset' },
]
interface AddBlockMenuProps {
onAdd: (type: BlockType) => void
variant?: 'default' | 'small' | 'inline'
}
export function AddBlockMenu({ onAdd, variant = 'default' }: AddBlockMenuProps) {
const contentBlocks = BLOCK_OPTIONS.filter((b) => b.category === 'content')
const layoutBlocks = BLOCK_OPTIONS.filter((b) => b.category === 'layout')
const presetBlocks = BLOCK_OPTIONS.filter((b) => b.category === 'preset')
return (
{variant === 'small' ? (
) : variant === 'inline' ? (
) : (
)}
Content
{contentBlocks.map((option) => (
onAdd(option.type)}
className="flex items-center gap-3"
>
{option.icon}
{option.label}
{option.description}
))}
Layout
{layoutBlocks.map((option) => (
onAdd(option.type)}
className="flex items-center gap-3"
>
{option.icon}
{option.label}
{option.description}
))}
Presets
{presetBlocks.map((option) => (
onAdd(option.type)}
className="flex items-center gap-3"
>
{option.icon}
{option.label}
{option.description}
))}
)
}