"use client"; import { useReplicache } from "src/replicache"; import { useCanvasPaintOrder } from "src/hooks/queries/useCanvasStacking"; import { TooltipButton } from "./Buttons"; import { BringForwardTiny } from "./Icons/BringForwardTiny"; import { SendBackwardTiny } from "./Icons/SendBackwardTiny"; import { SendToFrontTiny } from "./Icons/SendToFrontTiny"; import { SendToBackTiny } from "./Icons/SendToBackTiny"; // Stacking controls for one canvas block, rendered inside a block's options // bar in place of the document up/down buttons. export function CanvasLayerControls(props: { parent: string; entityID: string; }) { let { rep } = useReplicache(); let order = useCanvasPaintOrder(props.parent); let index = order.indexOf(props.entityID); let atFront = index === order.length - 1; let atBack = index === 0; let controls = [ { action: "backward", label: "Send Backward", icon: , disabled: atBack, }, { action: "forward", label: "Bring Forward", icon: , disabled: atFront, }, { action: "back", label: "Send to Back", icon: , disabled: atBack, }, { action: "front", label: "Bring to Front", icon: , disabled: atFront, }, ] as const; return (
e.stopPropagation()}> {controls.map((c) => ( rep?.mutate.moveCanvasBlockLayer({ parent: props.parent, entityID: props.entityID, action: c.action, }) } > {c.icon} ))}
); }