@harmonics/lattice-ui 0.0.0-stage → 0.1.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 +15 -0
- package/LICENSE +21 -0
- package/README.md +164 -2
- package/dist/define.js +4 -0
- package/dist/elements-DMimFemm.js +2023 -0
- package/dist/index.js +1 -0
- package/dist/types/elements/define.d.ts +1 -0
- package/dist/types/elements/face.d.ts +32 -0
- package/dist/types/elements/host.d.ts +24 -0
- package/dist/types/elements/icon.d.ts +16 -0
- package/dist/types/elements/index.d.ts +31 -0
- package/dist/types/elements/shape.d.ts +29 -0
- package/dist/types/elements/shapes.d.ts +45 -0
- package/dist/types/elements/shears.d.ts +20 -0
- package/dist/types/elements/sky.d.ts +20 -0
- package/dist/types/elements/solid.d.ts +46 -0
- package/dist/types/faceLattice.d.ts +56 -0
- package/dist/types/hexes.d.ts +329 -0
- package/package.json +45 -4
- package/react.d.ts +48 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
`@harmonics/lattice-ui` follows semantic versioning; while it is `0.x`, a minor version may change
|
|
4
|
+
an element's inputs, events or tokens, and says so here.
|
|
5
|
+
|
|
6
|
+
## 0.1.0
|
|
7
|
+
|
|
8
|
+
- `<lattice-face>`: the tree's face, by mood or by expression, idling, with a laugh of relief on
|
|
9
|
+
`pulse`.
|
|
10
|
+
- `<lattice-shape>`: nine ready-made shapes of lattice cells and triangles, or any `parts`, in eight
|
|
11
|
+
woods.
|
|
12
|
+
- `<hex-sky>`: the sky and the earth lattices, at any scale and origin.
|
|
13
|
+
- `<shears-pad>`: the cut gesture, as `stroke` and `strokeend` events.
|
|
14
|
+
- `<lattice-icon>`: the shears and done marks.
|
|
15
|
+
- Types for React 19 (`/react`) and Solid (`/solid`); `HTMLElementTagNameMap` for every tag.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Daniel Blankenship
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,165 @@
|
|
|
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
|
|
5
|
+
on any page and in any framework (React, Vue, Svelte, Solid, plain HTML) with no build step. Each
|
|
6
|
+
draws in its own shadow root and carries the tree's colours with it, so it needs nothing else from
|
|
7
|
+
the page. You bring the state; the elements draw it.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
npm install @harmonics/lattice-ui
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## In five minutes
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<script type="module">
|
|
17
|
+
import "@harmonics/lattice-ui/define"; // registers every element
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<lattice-face mood="distressed"></lattice-face>
|
|
21
|
+
<lattice-shape shape="flower" tone="4"></lattice-shape>
|
|
22
|
+
<hex-sky style="height: 200px"></hex-sky>
|
|
23
|
+
<button><lattice-icon name="shears"></lattice-icon> Prune</button>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`@harmonics/lattice-ui` itself defines nothing when imported: call `defineLatticeElements()` (or
|
|
27
|
+
one element's `defineLatticeFace()`, …) in a browser. Both are safe to import in a server render;
|
|
28
|
+
there they do nothing. Every input is both an attribute and a property.
|
|
29
|
+
|
|
30
|
+
## Elements
|
|
31
|
+
|
|
32
|
+
### `<lattice-face>`
|
|
33
|
+
|
|
34
|
+
A pale hexagon plate raised off the page with a face on it, in 1,536 of the lattice's triangles.
|
|
35
|
+
It idles (blinks, bobs), laughs with relief when `pulse` goes up, and sinks the old face as a new
|
|
36
|
+
one comes. Under `prefers-reduced-motion`, or `still`, it holds still and only changes.
|
|
37
|
+
|
|
38
|
+
| Input | Type | Default | |
|
|
39
|
+
|---|---|---|---|
|
|
40
|
+
| `mood` | `happy` `content` `asleep` `sad` `distressed` `puzzled` `relieved` (`MOODS`) | `happy` | The tree's moods, each wearing a face |
|
|
41
|
+
| `expression` | a name from `FACES` (`Happy`, `Laughing`, `Sad`, `Surprised`, `Angry`, `Worried`, `Sleepy`, `Wink`, `Smitten`) | | Wins over `mood` |
|
|
42
|
+
| `pulse` | number | `0` | Raise it by one for a laugh of relief |
|
|
43
|
+
| `still` | boolean | `false` | No idle, no laugh, no fade |
|
|
44
|
+
| `size` | number (pixels) | `96` | Its width; the height follows |
|
|
45
|
+
| `label` | string | "A happy face" | What a screen reader says |
|
|
46
|
+
| `decorative` | boolean | `false` | Hidden from screen readers |
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
const face = document.querySelector("lattice-face");
|
|
50
|
+
face.pulse += 1;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### `<lattice-shape>`
|
|
54
|
+
|
|
55
|
+
A shape made of the sky lattice's own cells and triangles, raised off the page, each part in one
|
|
56
|
+
of the tree's woods.
|
|
57
|
+
|
|
58
|
+
| Input | Type | Default | |
|
|
59
|
+
|---|---|---|---|
|
|
60
|
+
| `shape` | `cell` `pair` `line` `flower` `triangle` `diamond` `trapezoid` `big-triangle` `hexagon` (`SHAPE_NAMES`) | `cell` | |
|
|
61
|
+
| `parts` | `Part[]`, or the same as JSON | | Any shape on the lattice; wins over `shape` |
|
|
62
|
+
| `tone` | 0–7 | `0` | 0–4 the tree's woods, 5 good fruit, 6 bitter, 7 untasted |
|
|
63
|
+
| `lift` | number | `8` | How high it stands, in lattice units |
|
|
64
|
+
| `scale` | number | `1` | 1 is the tree's own size: a cell 76 pixels across |
|
|
65
|
+
| `label` | string | | Without one it is hidden from screen readers |
|
|
66
|
+
|
|
67
|
+
A part is a cell `{ kind: "cell", at: { q, r } }` on the axial hex grid, or a triangle
|
|
68
|
+
`{ kind: "tri", at: { i, j, k } }` (corner `i, j` of the triangle grid, `k` 0 pointing right, 1
|
|
69
|
+
left), each with an optional `tone`.
|
|
70
|
+
|
|
71
|
+
```js
|
|
72
|
+
shape.parts = [
|
|
73
|
+
{ kind: "cell", at: { q: 0, r: 0 }, tone: 1 },
|
|
74
|
+
{ kind: "tri", at: { i: 0, j: 3, k: 0 }, tone: 5 },
|
|
75
|
+
];
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### `<hex-sky>`
|
|
79
|
+
|
|
80
|
+
The tree's sky, its hexagon lattice drawn faint over it, filling the element. Size it as any block.
|
|
81
|
+
Decorative.
|
|
82
|
+
|
|
83
|
+
| Input | Type | Default | |
|
|
84
|
+
|---|---|---|---|
|
|
85
|
+
| `kind` | `sky` `earth` | `sky` | Earth: cells broken into triangles, on the earth's colour |
|
|
86
|
+
| `scale` | number | `1` | The lattice's size |
|
|
87
|
+
| `x`, `y` | number (pixels) | `0` | Where the lattice's origin sits from the element's top-left, so a sky showing part of a larger one keeps its cells in place |
|
|
88
|
+
|
|
89
|
+
### `<shears-pad>`
|
|
90
|
+
|
|
91
|
+
The cut gesture. A drag across it draws the blade's fading trail and reports the stroke; what it
|
|
92
|
+
cuts is yours to decide. Put it over what can be cut and size it as any block.
|
|
93
|
+
|
|
94
|
+
| Event | `detail` | |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `stroke` | `{ points, fresh }` | At every move; `fresh` on a stroke's first point |
|
|
97
|
+
| `strokeend` | `{ points }` | When the pointer lifts |
|
|
98
|
+
|
|
99
|
+
Points are in the element's own pixels from its top-left. `disabled` stops it taking strokes. A
|
|
100
|
+
cut by pointer has no keyboard of its own: give the same action a button.
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
pad.addEventListener("stroke", (e) => cutAlong(e.detail.points));
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### `<lattice-icon>`
|
|
107
|
+
|
|
108
|
+
`name="shears"` or `name="done"`, in the text's colour, a step square
|
|
109
|
+
(`--lattice-icon-size` to change it). Hidden from screen readers unless it has a `label`.
|
|
110
|
+
|
|
111
|
+
## Styling
|
|
112
|
+
|
|
113
|
+
Every element carries the tree's colour tokens, light and dark (it follows
|
|
114
|
+
`prefers-color-scheme`). Set any of them on the element itself to change it:
|
|
115
|
+
|
|
116
|
+
```css
|
|
117
|
+
lattice-face, lattice-shape {
|
|
118
|
+
--color-tree-ink: #222;
|
|
119
|
+
--color-tree-raised: #fffdf6;
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Set them on the elements, not on `body`: an element's own tokens sit nearer than an ancestor's.
|
|
124
|
+
The ones the elements use:
|
|
125
|
+
|
|
126
|
+
| Token | Used for |
|
|
127
|
+
|---|---|
|
|
128
|
+
| `--color-tree-sky` | the sky, and what woods and plates are mixed with |
|
|
129
|
+
| `--color-tree-earth` | the earth sky |
|
|
130
|
+
| `--color-tree-ink` | the face's features |
|
|
131
|
+
| `--color-tree-raised` | the face's plate, a glint, untasted fruit |
|
|
132
|
+
| `--color-tree-wood-0` … `--color-tree-wood-4` | the five woods; `wood-0` is also the plate's edge |
|
|
133
|
+
| `--color-tree-olive` | fruit |
|
|
134
|
+
| `--color-tree-alert` | blush, the tongue, the blade's trail |
|
|
135
|
+
| `--color-tree-lattice-sky`, `--color-tree-lattice-earth` | the lattice lines |
|
|
136
|
+
| `--tree-rule-width`, `--tree-rule-thick-width` | edges, seams, the blade |
|
|
137
|
+
| `--space-tree-2`, `--space-tree-4` | how far a face sinks; an icon's size |
|
|
138
|
+
|
|
139
|
+
Each element also exposes its drawing as a part: `::part(face)`, `::part(shape)`, `::part(sky)`,
|
|
140
|
+
`::part(trail)`, `::part(icon)`. A mark's own paths are parts too, for a hover that recolours
|
|
141
|
+
them: `lattice-icon::part(done-cell)`, `::part(done-check)`, `::part(shears-blade)`,
|
|
142
|
+
`::part(shears-handle)`.
|
|
143
|
+
|
|
144
|
+
## Frameworks
|
|
145
|
+
|
|
146
|
+
- **React 19**: use the tags directly; add `import type {} from "@harmonics/lattice-ui/react"`
|
|
147
|
+
for their props. React 19 sets inputs as properties, so `parts={[…]}` works, and listens with
|
|
148
|
+
`onstroke` / `onstrokeend`.
|
|
149
|
+
- **Solid**: `import type {} from "@harmonics/lattice-ui/solid"`; set objects with `prop:parts`;
|
|
150
|
+
listen with `on:stroke`.
|
|
151
|
+
- **Vue**: tell the compiler the tags are custom elements
|
|
152
|
+
(`compilerOptions.isCustomElement: (tag) => /^(lattice|hex|shears)-/.test(tag)`); bind objects
|
|
153
|
+
with `.prop` (`:parts.prop="parts"`); listen with `@stroke`.
|
|
154
|
+
- **Svelte, Angular, plain HTML**: as any custom element.
|
|
155
|
+
|
|
156
|
+
TypeScript knows the tags from `HTMLElementTagNameMap` once the package is imported.
|
|
157
|
+
|
|
158
|
+
## Server rendering
|
|
159
|
+
|
|
160
|
+
Importing either entry on a server does nothing and throws nothing. Render the tags as markup;
|
|
161
|
+
they draw when the page defines them in the browser.
|
|
162
|
+
|
|
163
|
+
## Licence
|
|
164
|
+
|
|
165
|
+
MIT. The package bundles [Solid](https://www.solidjs.com) (MIT).
|
package/dist/define.js
ADDED