"use client"
import type { ReactNode } from "react"
import {
ArrowClockwise,
ArrowDown,
ArrowLeft,
ArrowRight,
ArrowUp,
MagnifyingGlassMinus,
MagnifyingGlassPlus,
Trash,
type Icon,
} from "@phosphor-icons/react"
import { Button } from "@/components/ui/button"
import { useBoothStore, type StickerInstance, type StripText } from "@/stores/booth"
import { STICKERS } from "./presets"
/* DESIGN-SYSTEM §11: kanvas tidak terbaca pembaca layar, jadi tiap stiker dan
teks punya barisnya sendiri dengan tombol pindah, ukuran, putar, dan hapus.
Seluruh penyuntingan bisa selesai tanpa penunjuk; Transformer hanya jalur
tambahan. */
const STEP = 8
const WIDTH_STEP = 12
const FONT_STEP = 4
const ROTATE_STEP = 15
function IconAction({
label,
icon: ActionIcon,
onClick,
}: {
label: string
icon: Icon
onClick: () => void
}) {
return (
)
}
function RowShell({
children,
readout,
}: {
children: ReactNode
readout: string
}) {
return (
{children}
{readout}
)
}
function StickerRow({
sticker,
label,
}: {
sticker: StickerInstance
label: string
}) {
const updateSticker = useBoothStore((state) => state.updateSticker)
const removeSticker = useBoothStore((state) => state.removeSticker)
return (
Stiker {label}
updateSticker(sticker.id, { x: sticker.x - STEP })}
/>
updateSticker(sticker.id, { x: sticker.x + STEP })}
/>
updateSticker(sticker.id, { y: sticker.y - STEP })}
/>
updateSticker(sticker.id, { y: sticker.y + STEP })}
/>
updateSticker(sticker.id, { width: sticker.width + WIDTH_STEP })
}
/>
updateSticker(sticker.id, { width: sticker.width - WIDTH_STEP })
}
/>
updateSticker(sticker.id, { rotation: sticker.rotation + ROTATE_STEP })
}
/>
removeSticker(sticker.id)}
/>
)
}
function TextRow({ text }: { text: StripText }) {
const updateText = useBoothStore((state) => state.updateText)
const removeText = useBoothStore((state) => state.removeText)
const label = `Teks ${text.value}`
return (
{label}
updateText(text.id, { fontSize: text.fontSize + FONT_STEP })
}
/>
updateText(text.id, { fontSize: text.fontSize - FONT_STEP })
}
/>
removeText(text.id)}
/>
)
}
export function DecorList() {
const stickers = useBoothStore((state) => state.stickers)
const texts = useBoothStore((state) => state.texts)
if (stickers.length === 0 && texts.length === 0) {
return null
}
return (
Isi strip
{stickers.map((sticker) => (
asset.id === sticker.assetId)?.label ??
sticker.assetId
}
/>
))}
{texts.map((text) => (
))}
)
}