import { memo, useState, useCallback } from "react"; import type { BlockParam } from "@hyperframes/core/registry"; interface BlockParamsPanelProps { blockName: string; blockTitle: string; params: BlockParam[]; compositionPath: string; onClose: () => void; } export const BlockParamsPanel = memo(function BlockParamsPanel({ blockTitle, params, compositionPath: _compositionPath, onClose, }: BlockParamsPanelProps) { const [values, setValues] = useState>(() => { const initial: Record = {}; for (const p of params) { initial[p.key] = p.default; } return initial; }); const handleChange = useCallback((key: string, value: string) => { setValues((prev) => ({ ...prev, [key]: value })); }, []); return (
{blockTitle}
Parameters
{params.map((param) => ( handleChange(param.key, v)} /> ))}
); }); function ParamControl({ param, value, onChange, }: { param: BlockParam; value: string; onChange: (value: string) => void; }) { return (
{param.type === "color" && (
onChange(e.target.value)} className="w-7 h-7 rounded border border-neutral-700 bg-transparent cursor-pointer" /> onChange(e.target.value)} className="flex-1 bg-neutral-900 border border-neutral-800 rounded px-2 py-1 text-[10px] text-neutral-200 font-mono focus:outline-none focus:border-neutral-700" />
)} {param.type === "number" && (
onChange(e.target.value)} className="flex-1" /> {value}
)} {param.type === "text" && ( onChange(e.target.value)} className="w-full bg-neutral-900 border border-neutral-800 rounded px-2 py-1 text-[10px] text-neutral-200 focus:outline-none focus:border-neutral-700" /> )} {param.type === "select" && param.options && ( )}
); }