import { Component } from '@angular/core'; import { NgFor } from '@angular/common'; import { CdkDrag, CdkDropList } from '@angular/cdk/drag-drop'; import { MatIconModule } from '@angular/material/icon'; import { MatListModule } from '@angular/material/list'; import { ComponentType, getComponentLabel, getComponentIcon } from '../../core/models/component'; import { BuilderStateService } from '../services/builder-state.service'; const CATEGORIES: { label: string; types: ComponentType[] }[] = [ { label: 'Content', types: ['HEADING', 'TEXT', 'DIVIDER'], }, { label: 'Media', types: ['IMAGE', 'GALLERY', 'VIDEO'], }, { label: 'Interactive', types: ['BUTTON', 'CONTACT_FORM', 'MAP'], }, { label: 'Advanced', types: ['CUSTOM_HTML'], }, ]; @Component({ selector: 'app-component-palette', standalone: true, imports: [NgFor, CdkDropList, CdkDrag, MatIconModule, MatListModule], template: `

Components

{{ cat.label }}

{{ getIcon(type) }} {{ getLabel(type) }}
`, styles: [` :host { display: block; } .cdk-drag-preview { @apply bg-white shadow-lg rounded-md border border-blue-200 px-3 py-2 text-sm; } .cdk-drag-placeholder { opacity: 0; } `], }) export class ComponentPalette { categories = CATEGORIES; allTypes: ComponentType[] = CATEGORIES.flatMap(c => c.types); constructor(private state: BuilderStateService) {} getLabel(type: ComponentType): string { return getComponentLabel(type); } getIcon(type: ComponentType): string { return getComponentIcon(type); } addComponent(type: ComponentType): void { this.state.addComponent(type); } noop(): void {} }