"use client"; import { useDrag } from "react-dnd"; import { cn } from "@/lib/utils"; import { PopComponentType } from "../types/pop-layout"; import { Square, FileText, MousePointer, BarChart3, LayoutGrid, MousePointerClick, List, Search } from "lucide-react"; import { DND_ITEM_TYPES } from "../constants"; // 컴포넌트 정의 interface PaletteItem { type: PopComponentType; label: string; icon: React.ElementType; description: string; } const PALETTE_ITEMS: PaletteItem[] = [ { type: "pop-sample", label: "샘플 박스", icon: Square, description: "크기 조정 테스트용", }, { type: "pop-text", label: "텍스트", icon: FileText, description: "텍스트, 시간, 이미지 표시", }, { type: "pop-icon", label: "아이콘", icon: MousePointer, description: "네비게이션 아이콘 (화면 이동, URL, 뒤로가기)", }, { type: "pop-dashboard", label: "대시보드", icon: BarChart3, description: "KPI, 차트, 게이지, 통계 집계", }, { type: "pop-card-list", label: "카드 목록", icon: LayoutGrid, description: "테이블 데이터를 카드 형태로 표시", }, { type: "pop-button", label: "버튼", icon: MousePointerClick, description: "액션 버튼 (저장/삭제/API/모달)", }, { type: "pop-string-list", label: "리스트 목록", icon: List, description: "테이블 데이터를 리스트/카드로 표시", }, { type: "pop-search", label: "검색", icon: Search, description: "조건 입력 (텍스트/날짜/선택/모달)", }, ]; // 드래그 가능한 컴포넌트 아이템 function DraggablePaletteItem({ item }: { item: PaletteItem }) { const [{ isDragging }, drag] = useDrag( () => ({ type: DND_ITEM_TYPES.COMPONENT, item: { type: DND_ITEM_TYPES.COMPONENT, componentType: item.type }, collect: (monitor) => ({ isDragging: monitor.isDragging(), }), }), [item.type] ); const Icon = item.icon; return (
{item.label}
{item.description}
); } // 컴포넌트 팔레트 패널 export default function ComponentPalette() { return (
{/* 헤더 */}

컴포넌트

드래그하여 캔버스에 배치

{/* 컴포넌트 목록 */}
{PALETTE_ITEMS.map((item) => ( ))}
{/* 하단 안내 */}

Tip: 캔버스의 그리드 칸에 드롭하세요

); }