"use client"; import type { ImageBlockProps } from "@/features/editor/state/editorStore"; import { NumericPropertyControl } from "@/features/editor/components/NumericPropertyControl"; import { ColorPickerField, TEXT_COLOR_PALETTE } from "@/features/editor/components/ColorPickerField"; import { useAppLocale } from "@/features/i18n/LocaleProvider"; import { getEditorImagePanelMessages } from "@/features/i18n/messages/editorImagePanel"; export type ImagePropertiesPanelProps = { imageProps: ImageBlockProps; selectedBlockId: string; updateBlock: (id: string, partial: Partial) => void; }; export function ImagePropertiesPanel({ imageProps, selectedBlockId, updateBlock }: ImagePropertiesPanelProps) { const locale = useAppLocale(); const m = getEditorImagePanelMessages(locale); const source: "url" | "upload" = imageProps.sourceType === "asset" || (imageProps.src && imageProps.src.startsWith("/api/image/")) ? "upload" : "url"; return ( <>
{source === "url" && (
)} {source === "upload" && (
)}

{m.styleSectionTitle}

{/* 카드 배경색 */}
{ const next = hex && hex.trim().length > 0 ? hex : undefined; updateBlock(selectedBlockId, { backgroundColorCustom: next } as any); }} palette={TEXT_COLOR_PALETTE} />
{/* 정렬 */} {/* 너비 모드 */} {(imageProps.widthMode ?? "auto") === "fixed" && ( { updateBlock(selectedBlockId, { widthPx: v, } as any); }} /> )} {/* 모서리 둥글기 */} { if (typeof imageProps.borderRadiusPx === "number") { return imageProps.borderRadiusPx; } const r = imageProps.borderRadius ?? "md"; // 토큰만 있는 기존 데이터의 경우, 토큰별 대표값으로 초기화한다. return r === "none" ? 0 : r === "sm" ? 20 : r === "lg" ? 120 : r === "full" ? 180 : 60; })()} min={0} max={200} step={1} presets={[ { id: "none", label: m.borderRadiusPresetNone, value: 0 }, { id: "sm", label: m.borderRadiusPresetSmall, value: 20 }, { id: "md", label: m.borderRadiusPresetMedium, value: 60 }, { id: "lg", label: m.borderRadiusPresetLarge, value: 120 }, { id: "full", label: m.borderRadiusPresetFull, value: 180 }, ]} onChangeValue={(v) => { // 0~50 범위를 토큰으로 매핑한다. const nextToken = v <= 0 ? "none" : v <= 30 ? "sm" : v <= 90 ? "md" : v <= 150 ? "lg" : "full"; updateBlock(selectedBlockId, { borderRadius: nextToken, borderRadiusPx: v, } as any); }} />
); }