@harmonics/lattice-ui 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  `@harmonics/lattice-ui` follows semantic versioning; while it is `0.x`, a minor version may change
4
4
  an element's inputs, events or tokens, and says so here.
5
5
 
6
+ ## 0.6.0
7
+
8
+ - `<lattice-board>`, in `@harmonics/lattice-ui/board`: a surface of lattice pieces a person drags,
9
+ steps, turns, glues, breaks apart, pulls parts off and throws away, with an optional tray of new
10
+ cells and triangles. The tree's Build mode, as an element: the same pull into a slot, click,
11
+ refusal and glue glow. A cancelable `change` after each thing done; `catch` when a slot catches.
12
+ Its own entry: pages that do not use it load none of it. Additive: nothing in 0.5.1 changes.
13
+
14
+ ## 0.5.1
15
+
16
+ - What 0.5.0 says, built. 0.5.0 shipped this README and CHANGELOG over a `dist` built before
17
+ them: its scripts have `orient` and nothing else of 0.5.0, and its `react.d.ts` imports a
18
+ `StrokeEndDetail` its types do not have. `npm publish` now builds and checks the package first.
19
+
6
20
  ## 0.5.0
7
21
 
8
22
  - `<shears-pad>` always ends a stroke. `strokeend` carries `cancelled`: true when the stroke was cut
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @harmonics/lattice-ui
2
2
 
3
3
  The Harmonics tree's look as Custom Elements: a face drawn in the lattice's own triangles, the
4
- hexagon sky, raised shapes of cells and triangles, a shears cut gesture, and two marks. They work
4
+ hexagon sky, raised shapes of cells and triangles, a shears cut gesture, two marks, and a board of pieces to build on. They work
5
5
  on any page and in any framework (React, Vue, Svelte, Solid, plain HTML) with no build step. Each
6
6
  draws in its own shadow root and carries the tree's colours with it, so it needs nothing else from
7
7
  the page. You bring the state; the elements draw it.
@@ -122,6 +122,52 @@ see [Cutting](#cutting).
122
122
  `name="shears"` or `name="done"`, in the text's colour, a step square
123
123
  (`--lattice-icon-size` to change it). Hidden from screen readers unless it has a `label`.
124
124
 
125
+ ## Board
126
+
127
+ `<lattice-board>` is a surface of the lattice's pieces a person builds with, the way the Harmonics
128
+ tree's Build mode does. It is an entry of its own, so a page without one loads none of it.
129
+
130
+ ```js
131
+ import { defineLatticeBoard } from "@harmonics/lattice-ui/board";
132
+ defineLatticeBoard();
133
+
134
+ const board = document.querySelector("lattice-board");
135
+ board.pieces = [
136
+ { id: "a", parts: [{ kind: "cell", at: { q: 1, r: 1 }, tone: 0 }, { kind: "cell", at: { q: 2, r: 1 }, tone: 0 }] },
137
+ { id: "b", parts: [{ kind: "tri", at: { i: -6, j: 16, k: 0 }, tone: 5 }] }, // a triangle of cell (7, 1)
138
+ ];
139
+ board.addEventListener("change", (e) => save(e.detail.pieces));
140
+ ```
141
+
142
+ ```html
143
+ <lattice-board tray style="height: 400px"></lattice-board>
144
+ ```
145
+
146
+ Drag a piece and the lattice pulls it in: near a slot it leans in and the slot lights, nearer it is
147
+ caught and held, and let go it clicks into the slot, or goes to the nearest place it fits. A piece
148
+ with the focus (Tab) steps with the arrows; R and Shift+R (or a double-click) turn it a sixth;
149
+ G glues it to every piece it shares a side with (the sides glow first); Shift+G breaks it into its
150
+ units; Alt-drag pulls one part off; Delete throws it away. Under reduced motion a carried piece
151
+ follows the pointer exactly and nothing animates.
152
+
153
+ | Input | Type | Default | |
154
+ |---|---|---|---|
155
+ | `pieces` | `{ id?, parts }[]`, or the same as JSON | | What the board starts from; read back, its own pieces now (each `{ id, parts, pivot }`). Set it again to replace them |
156
+ | `fixed` | `{ id?, parts }[]` (property) | | Drawn flat and in the way, never handled, glued to or handed back |
157
+ | `tray` | boolean | `false` | Two cells at the bottom left: drag out a new cell or triangle (or Enter on one), drop a piece there to throw it away |
158
+ | `scale` | number | `1` | 1 is the tree's own size: a cell 76 pixels across |
159
+ | `label` | string | "A board of lattice pieces" | What a screen reader calls it |
160
+
161
+ | Event | `detail` | |
162
+ |---|---|---|
163
+ | `change` | `{ pieces, action, id }` | After each thing done: `action` is `move`, `turn`, `glue`, `break`, `pull`, `add` or `remove`; `id` the piece acted on (`""` when a resize moved pieces back onto the board). Cancelable: `preventDefault()` undoes it |
164
+ | `catch` | `{ id }` | A slot caught the carried piece: a page's own sound goes here |
165
+
166
+ The board fills the element; size it as any block. Its lattice starts at its top-left, so a
167
+ `<hex-sky>` of the same size and `scale` under it shows the slots. `LatticeBoardEventMap` types the
168
+ events on the board's own `addEventListener`. Pieces are the `Piece`s of
169
+ [Geometry](#geometry): a page can lay them out with those functions before handing them over.
170
+
125
171
  ## Styling
126
172
 
127
173
  Every element carries the tree's colour tokens, light and dark (it follows
@@ -157,7 +203,8 @@ them: `lattice-icon::part(done-cell)`, `::part(done-check)`, `::part(shears-blad
157
203
 
158
204
  ## Frameworks
159
205
 
160
- - **React 19**: use the tags directly; add `import type {} from "@harmonics/lattice-ui/react"`
206
+ - **React 19**: use the tags directly (define the board before it renders, as the others);
207
+ add `import type {} from "@harmonics/lattice-ui/react"`
161
208
  for their props. React 19 sets inputs as properties, so `parts={[…]}` works, and listens with
162
209
  `onstroke` / `onstrokeend`. Define the elements before React first renders them: until then
163
210
  React cannot see the property and sets `parts` as the attribute `"[object Object]"`, which draws