Tool Palette

The floating toolbar of a canvas, with tool flyouts and a design, prototype and inspect switch.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/tool-palette

Usage

import { boardTools, ToolPalette } from "./ui/uicontext/components/canvas/ToolPalette.ts"import { CanvasTool } from "./ui/uicontext/components/canvas/Viewport.ts"
const Message = UiSchema.TaggedEnum({ PickedTool: { tool: CanvasTool } })export const Tools = (h: Html.H<typeof Message.Type>, tool: CanvasTool) =>	ToolPalette(h, { tool, groups: boardTools, onPick: (picked) => Message.PickedTool({ tool: picked }) })

API reference

Options

ToolPalette options
NameTypeDescription
toolrequired"select" | "hand" | "frame" | "rect" | "ellipse" | "line" | "arrow" | "text" | "sticky" | "pen" | "highlighter" | "eraser" | "comment" | "laser"—
groupsrequiredPaletteGroup[]—
onPickrequired(tool: CanvasTool) => Message—
shownReadonly<Record<string, CanvasTool>>The tool each group shows, by group id: the caller remembers the last one used
mode{ readonly value: CanvasMode readonly options: CanvasMode[] readonly onPick: (mode: CanvasMode) => Message }—
endView.ChildrenControls after the tools: undo and redo, a zoom
styleStyle—

Source