API Reference Hakushi v#0.4.0

Copy Markdown View Source

Modules

Hakushi (白紙, "a blank sheet of paper") is a canvas for Phoenix: an endless sheet that people pan and zoom, with nodes of your own HEEx on it, joined by edges.

The LiveComponent behind Hakushi.Components.canvas/1.

A change to a canvas: what a person did, or what the app does.

Function components for the canvas.

An edge of a canvas: a line from a handle of one node to a handle of another.

The nodes and edges of a canvas.

An Ecto type for a whole canvas in one column: a :map (jsonb on PostgreSQL, JSON text on SQLite and MySQL).

The icons of the kits and of the embed frame: Lucide icons (https://lucide.dev, ISC licence), drawn with strokes of currentColor, as Kotoba's toolbar draws its own.

The images of a canvas (Hakushi.Kits.Images), checked on the server before they become nodes, and kept in the app's store with Storehouse.

The geometry of a stroke of ink (Hakushi.Kits.Ink): its outline, as the d of an SVG path, whose width follows the pen's pressure.

A shared canvas on Issho: the canvas's graph is a document of an Issho room, the canvas's LiveView is one of the room's sessions, and Issho is the room's people and their cursors.

A place on a Hakushi canvas, in the canvas's own terms (never screen pixels, as each person has their own pan and zoom): where a person's pointer is, where an agent goes (Issho.Motion), what an app keeps of them. Its format is part of Hakushi's public API, and only grows.

A kit: the things of one kind of canvas, which the canvas draws, makes and edits by itself. A canvas with kits needs no :node slots and no new_node for them

The kit of a flow: a trigger that starts it, steps, and conditions with two ways out, joined by edges in the order they run.

The kit of images on the paper: for a moodboard, a screenshot to mark up, references beside a plan.

The kit of ink: drawing on the paper with a pen, over anything on the canvas (annotate, sketch, circle a node, write by hand), with a highlighter, an eraser of whole strokes, and a lasso that selects strokes and nodes alike.

The kit of sticky notes: notes of a few colours, which people write in place, resize by their corners and join with arrows.

The kit of a database schema: tables, with columns that have a name, a type and a key (primary or foreign), and foreign keys drawn from a column to a column of the same type.

The kit of plain shapes: rectangles, ellipses, diamonds, triangles, text and lines, for diagrams, wireframes and whiteboards with no :node slot of the app's.

The on_mount hook of a LiveView with a shared canvas (issho), and the app's own changes to a canvas.

Helpers for kits that write their canvas as a Mermaid diagram in Markdown, and read it back (Hakushi.Kit.to_markdown/1, Hakushi.Kit.from_markdown/1).

The words of the canvas: the labels of its controls, the reasons it gives when it refuses a change, and the announcements for screen readers.

A node of a canvas: a box at a place, drawn by the :node slot of its type.

The paper of a canvas: its pattern (background) and the size of its squares (grid), which nodes snap to.

The rules of the edges of a canvas, the same in the browser and on the server.

Helpers for Phoenix.LiveViewTest, to read and change the canvases of a LiveView with no browser.

Mix Tasks

Builds the Hakushi canvas into priv/static.

Sets up Hakushi in a Phoenix application.

Checks the built files before a release of Hakushi.