@harmonics/lattice-ui 0.5.1 → 0.7.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 +18 -0
- package/README.md +88 -8
- package/dist/board.js +685 -0
- package/dist/define.js +1 -1
- package/dist/elements-DdyLdkzr.js +1346 -0
- package/dist/{hexes-B4uCADpF.js → hexes-DwdbCYSF.js} +197 -160
- package/dist/hexes.js +1 -1
- package/dist/index.js +3 -1
- package/dist/types/boardTypes.d.ts +2 -0
- package/dist/types/elements/board-entry.d.ts +9 -0
- package/dist/types/elements/board.d.ts +59 -0
- package/dist/types/elements/icon.d.ts +1 -1
- package/dist/types/elements/index.d.ts +1 -1
- package/dist/types/elements/shape.d.ts +35 -3
- package/dist/types/elements/solid.d.ts +17 -1
- package/dist/woods-C8W11GkD.js +708 -0
- package/package.json +6 -2
- package/react.d.ts +19 -0
- package/dist/elements-Ka2LbDpP.js +0 -1832
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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.7.0
|
|
7
|
+
|
|
8
|
+
- `<lattice-shape pressable>`: a button shaped like itself, in the tab order, named by its
|
|
9
|
+
`label`; a click on its faces, Enter or Space fires `press`. `pressed` makes it a toggle the page
|
|
10
|
+
sets; `disabled` stops it. It lifts under the pointer and sinks while pressed, and its focus ring
|
|
11
|
+
runs round its outline. Without `pressable`, a shape is what it was.
|
|
12
|
+
- `<lattice-icon>` draws five more marks: `note`, and the board's actions `turn`, `glue`, `apart`
|
|
13
|
+
and `bin`. Each path is a part, named in the README.
|
|
14
|
+
- Additive: nothing in 0.6.0 changes.
|
|
15
|
+
|
|
16
|
+
## 0.6.0
|
|
17
|
+
|
|
18
|
+
- `<lattice-board>`, in `@harmonics/lattice-ui/board`: a surface of lattice pieces a person drags,
|
|
19
|
+
steps, turns, glues, breaks apart, pulls parts off and throws away, with an optional tray of new
|
|
20
|
+
cells and triangles. The tree's Build mode, as an element: the same pull into a slot, click,
|
|
21
|
+
refusal and glue glow. A cancelable `change` after each thing done; `catch` when a slot catches.
|
|
22
|
+
Its own entry: pages that do not use it load none of it. Additive: nothing in 0.5.1 changes.
|
|
23
|
+
|
|
6
24
|
## 0.5.1
|
|
7
25
|
|
|
8
26
|
- What 0.5.0 says, built. 0.5.0 shipped this README and CHANGELOG over a `dist` built before
|
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
|
|
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.
|
|
@@ -71,7 +71,10 @@ of the tree's woods.
|
|
|
71
71
|
| `tone` | 0–7 | `0` | 0–4 the tree's woods, 5 good fruit, 6 bitter, 7 untasted |
|
|
72
72
|
| `lift` | number | `8` | How high it stands, in lattice units |
|
|
73
73
|
| `scale` | number | `1` | 1 is the tree's own size: a cell 76 pixels across |
|
|
74
|
-
| `label` | string | | Without one it is hidden from screen readers |
|
|
74
|
+
| `label` | string | | Without one it is hidden from screen readers; when pressable, its name |
|
|
75
|
+
| `pressable` | boolean | `false` | A button shaped like itself (below) |
|
|
76
|
+
| `pressed` | boolean | unset | Makes a pressable shape a toggle (`aria-pressed`); the page sets it |
|
|
77
|
+
| `disabled` | boolean | `false` | A pressable shape that cannot be pressed, out of the tab order |
|
|
75
78
|
|
|
76
79
|
A part is a cell `{ kind: "cell", at: { q, r } }` on the axial hex grid, or a triangle
|
|
77
80
|
`{ kind: "tri", at: { i, j, k } }` (corner `i, j` of the triangle grid, `k` 0 pointing right, 1
|
|
@@ -84,6 +87,22 @@ shape.parts = [
|
|
|
84
87
|
];
|
|
85
88
|
```
|
|
86
89
|
|
|
90
|
+
With `pressable` it is a button shaped like itself, for a palette of woods, a picker of shapes or
|
|
91
|
+
a button that is a shape. It is in the tab order with `role="button"` and its `label` as its name
|
|
92
|
+
(one without a label warns in the console). A click on its faces, Enter, or Space (on release)
|
|
93
|
+
fires `press`, `{ shape, parts }`. Only its faces take the pointer: a press in the gap round a
|
|
94
|
+
hexagon's corner goes to whatever is under it. It stands a little higher under the pointer and
|
|
95
|
+
sinks to half its lift while pressed, or while `pressed`; the keyboard's ring runs round its own
|
|
96
|
+
outline, and a `pressed` one keeps a quiet ring, so a palette shows which is picked by more than
|
|
97
|
+
its depth. The shape never presses itself: keep one `pressed` in a palette from `press`.
|
|
98
|
+
|
|
99
|
+
```js
|
|
100
|
+
for (const swatch of swatches)
|
|
101
|
+
swatch.addEventListener("press", () => {
|
|
102
|
+
for (const s of swatches) s.pressed = s === swatch;
|
|
103
|
+
});
|
|
104
|
+
```
|
|
105
|
+
|
|
87
106
|
### `<hex-sky>`
|
|
88
107
|
|
|
89
108
|
The tree's sky, its hexagon lattice drawn faint over it, filling the element. Size it as any block.
|
|
@@ -119,8 +138,68 @@ see [Cutting](#cutting).
|
|
|
119
138
|
|
|
120
139
|
### `<lattice-icon>`
|
|
121
140
|
|
|
122
|
-
|
|
123
|
-
(`--lattice-icon-size` to change it). Hidden from screen readers unless it has a `label`.
|
|
141
|
+
One of the tree's marks (`ICON_NAMES`), in the text's colour, a step square
|
|
142
|
+
(`--lattice-icon-size` to change it). Hidden from screen readers unless it has a `label`. Every
|
|
143
|
+
mark is drawn from the lattice's pieces: hexagons, triangles and diamonds, every line upright or
|
|
144
|
+
at 30°.
|
|
145
|
+
|
|
146
|
+
| `name` | | Parts |
|
|
147
|
+
|---|---|---|
|
|
148
|
+
| `shears` (default) | two hexagon handles, two diamond blades crossing | `shears-handle`, `shears-blade` |
|
|
149
|
+
| `done` | a check in a hexagon | `done-cell`, `done-check` |
|
|
150
|
+
| `note` | a hexagon with two lines of writing | `note-cell`, `note-line` |
|
|
151
|
+
| `turn` | a hexagon open at one side, a triangle pointing on round (R) | `turn-path`, `turn-arrow` |
|
|
152
|
+
| `glue` | two cells sharing a heavy side (G) | `glue-cell`, `glue-seam` |
|
|
153
|
+
| `apart` | two cells with a gap (Shift+G) | `apart-cell` |
|
|
154
|
+
| `bin` | a cup under a diamond lid (Delete) | `bin-can`, `bin-rib`, `bin-lid` |
|
|
155
|
+
|
|
156
|
+
The last four are `<lattice-board>`'s keyboard actions, for a page that gives each a button.
|
|
157
|
+
|
|
158
|
+
## Board
|
|
159
|
+
|
|
160
|
+
`<lattice-board>` is a surface of the lattice's pieces a person builds with, the way the Harmonics
|
|
161
|
+
tree's Build mode does. It is an entry of its own, so a page without one loads none of it.
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
import { defineLatticeBoard } from "@harmonics/lattice-ui/board";
|
|
165
|
+
defineLatticeBoard();
|
|
166
|
+
|
|
167
|
+
const board = document.querySelector("lattice-board");
|
|
168
|
+
board.pieces = [
|
|
169
|
+
{ id: "a", parts: [{ kind: "cell", at: { q: 1, r: 1 }, tone: 0 }, { kind: "cell", at: { q: 2, r: 1 }, tone: 0 }] },
|
|
170
|
+
{ id: "b", parts: [{ kind: "tri", at: { i: -6, j: 16, k: 0 }, tone: 5 }] }, // a triangle of cell (7, 1)
|
|
171
|
+
];
|
|
172
|
+
board.addEventListener("change", (e) => save(e.detail.pieces));
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```html
|
|
176
|
+
<lattice-board tray style="height: 400px"></lattice-board>
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
Drag a piece and the lattice pulls it in: near a slot it leans in and the slot lights, nearer it is
|
|
180
|
+
caught and held, and let go it clicks into the slot, or goes to the nearest place it fits. A piece
|
|
181
|
+
with the focus (Tab) steps with the arrows; R and Shift+R (or a double-click) turn it a sixth;
|
|
182
|
+
G glues it to every piece it shares a side with (the sides glow first); Shift+G breaks it into its
|
|
183
|
+
units; Alt-drag pulls one part off; Delete throws it away. Under reduced motion a carried piece
|
|
184
|
+
follows the pointer exactly and nothing animates.
|
|
185
|
+
|
|
186
|
+
| Input | Type | Default | |
|
|
187
|
+
|---|---|---|---|
|
|
188
|
+
| `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 |
|
|
189
|
+
| `fixed` | `{ id?, parts }[]` (property) | | Drawn flat and in the way, never handled, glued to or handed back |
|
|
190
|
+
| `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 |
|
|
191
|
+
| `scale` | number | `1` | 1 is the tree's own size: a cell 76 pixels across |
|
|
192
|
+
| `label` | string | "A board of lattice pieces" | What a screen reader calls it |
|
|
193
|
+
|
|
194
|
+
| Event | `detail` | |
|
|
195
|
+
|---|---|---|
|
|
196
|
+
| `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 |
|
|
197
|
+
| `catch` | `{ id }` | A slot caught the carried piece: a page's own sound goes here |
|
|
198
|
+
|
|
199
|
+
The board fills the element; size it as any block. Its lattice starts at its top-left, so a
|
|
200
|
+
`<hex-sky>` of the same size and `scale` under it shows the slots. `LatticeBoardEventMap` types the
|
|
201
|
+
events on the board's own `addEventListener`. Pieces are the `Piece`s of
|
|
202
|
+
[Geometry](#geometry): a page can lay them out with those functions before handing them over.
|
|
124
203
|
|
|
125
204
|
## Styling
|
|
126
205
|
|
|
@@ -151,13 +230,14 @@ The ones the elements use:
|
|
|
151
230
|
| `--space-tree-2`, `--space-tree-4` | how far a face sinks; an icon's size |
|
|
152
231
|
|
|
153
232
|
Each element also exposes its drawing as a part: `::part(face)`, `::part(shape)`, `::part(sky)`,
|
|
154
|
-
`::part(trail)`, `::part(icon)
|
|
155
|
-
|
|
156
|
-
|
|
233
|
+
`::part(trail)`, `::part(icon)`, `::part(board)`, and a shape's focus ring `::part(ring)`. A
|
|
234
|
+
mark's own paths are parts too (see `<lattice-icon>`), for a hover that recolours them:
|
|
235
|
+
`lattice-icon::part(done-cell)`.
|
|
157
236
|
|
|
158
237
|
## Frameworks
|
|
159
238
|
|
|
160
|
-
- **React 19**: use the tags directly
|
|
239
|
+
- **React 19**: use the tags directly (define the board before it renders, as the others);
|
|
240
|
+
add `import type {} from "@harmonics/lattice-ui/react"`
|
|
161
241
|
for their props. React 19 sets inputs as properties, so `parts={[…]}` works, and listens with
|
|
162
242
|
`onstroke` / `onstrokeend`. Define the elements before React first renders them: until then
|
|
163
243
|
React cannot see the property and sets `parts` as the attribute `"[object Object]"`, which draws
|