@blueshed/joined 0.2.2 → 0.3.1

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.
Files changed (237) hide show
  1. package/.claude/skills/joined/SKILL.md +9 -1
  2. package/.claude/skills/joined/reference.md +316 -63
  3. package/.claude/skills/joined-door/SKILL.md +57 -0
  4. package/README.md +19 -50
  5. package/docs/design.md +158 -37
  6. package/docs/introduction.md +27 -27
  7. package/docs/light-and-shadow.svg +2 -1
  8. package/docs/links-and-trust.svg +1 -0
  9. package/docs/stories-to-code.svg +2 -1
  10. package/docs/wire-op.svg +1 -0
  11. package/examples/README.md +20 -0
  12. package/examples/account/account.json +1 -0
  13. package/examples/account/derive.ts +41 -0
  14. package/examples/account/generated/elements.ts +52 -0
  15. package/examples/account/generated/rows.ts +22 -0
  16. package/examples/account/generated/rules.ts +32 -0
  17. package/examples/account/routes.ts +5 -0
  18. package/examples/app.css +11 -1
  19. package/examples/cafe/books.html +2 -2
  20. package/examples/cafe/cafe.css +96 -85
  21. package/examples/cafe/generated/books.rows.ts +22 -0
  22. package/examples/cafe/generated/books.rules.ts +3 -2
  23. package/examples/cafe/generated/kitchen.rows.ts +27 -0
  24. package/examples/cafe/generated/kitchen.rules.ts +11 -1
  25. package/examples/cafe/generated/menu.rows.ts +22 -0
  26. package/examples/cafe/generated/menu.rules.ts +3 -2
  27. package/examples/cafe/generated/order.rows.ts +27 -0
  28. package/examples/cafe/generated/order.rules.ts +11 -1
  29. package/examples/cafe/generated/staff.elements.ts +7 -2
  30. package/examples/cafe/generated/staff.rows.ts +22 -0
  31. package/examples/cafe/generated/staff.rules.ts +9 -1
  32. package/examples/cafe/generated/supplies.queries.ts +4 -2
  33. package/examples/cafe/generated/supplies.rows.ts +22 -0
  34. package/examples/cafe/generated/supplies.rules.ts +17 -1
  35. package/examples/cafe/generated/till.queries.ts +2 -0
  36. package/examples/cafe/generated/till.rows.ts +27 -0
  37. package/examples/cafe/generated/till.rules.ts +11 -1
  38. package/examples/cafe/index.html +14 -15
  39. package/examples/cafe/kitchen.css +11 -19
  40. package/examples/cafe/kitchen.ts +7 -3
  41. package/examples/cafe/look.ts +30 -0
  42. package/examples/cafe/menu.html +10 -26
  43. package/examples/cafe/menu.ts +8 -80
  44. package/examples/cafe/migrations/002-guard-supplies.ts +15 -0
  45. package/examples/cafe/order.html +8 -7
  46. package/examples/cafe/order.ts +6 -2
  47. package/examples/cafe/routes.ts +0 -1
  48. package/examples/cafe/staff.json +5 -0
  49. package/examples/cafe/stories.jsonl +6 -2
  50. package/examples/cafe/supplies.html +35 -34
  51. package/examples/cafe/supplies.ts +59 -39
  52. package/examples/cafe/till.ts +19 -11
  53. package/examples/cafe/views.ts +7 -5
  54. package/examples/chart/arches.ts +150 -0
  55. package/examples/chart/chart.css +11 -0
  56. package/examples/chart/chart.json +87 -0
  57. package/examples/chart/generated/elements.ts +105 -0
  58. package/examples/chart/generated/queries.ts +36 -0
  59. package/examples/chart/generated/rows.ts +27 -0
  60. package/examples/chart/generated/rules.ts +111 -0
  61. package/examples/chart/grid.ts +118 -0
  62. package/examples/chart/index.html +78 -0
  63. package/examples/chart/migrations/001-chart.ts +6 -0
  64. package/examples/chart/migrations/002-create-conditions.ts +6 -0
  65. package/examples/chart/page.ts +20 -0
  66. package/examples/chart/routes.ts +7 -0
  67. package/examples/chart/stories.jsonl +14 -0
  68. package/examples/chart/teeth.ts +57 -0
  69. package/examples/desk/desk.css +6 -10
  70. package/examples/desk/generated/elements.ts +1 -1
  71. package/examples/desk/generated/rows.ts +22 -0
  72. package/examples/desk/generated/rules.ts +34 -1
  73. package/examples/desk/index.html +10 -3
  74. package/examples/desk/lanes.css +21 -19
  75. package/examples/desk/routes.ts +0 -2
  76. package/examples/desk/stories.jsonl +4 -3
  77. package/examples/desk/tally.css +1 -1
  78. package/examples/desk/thumbs.ts +2 -2
  79. package/examples/docs.ts +7 -4
  80. package/examples/hello/generated/elements.ts +2 -2
  81. package/examples/hello/generated/rules.ts +3 -2
  82. package/examples/hello/hello.css +2 -4
  83. package/examples/hello/index.html +10 -3
  84. package/examples/hello/page.ts +4 -4
  85. package/examples/index.html +20 -12
  86. package/examples/notes/generated/elements.ts +112 -0
  87. package/examples/notes/generated/queries.ts +42 -0
  88. package/examples/notes/generated/rows.ts +27 -0
  89. package/examples/notes/generated/rules.ts +133 -0
  90. package/examples/notes/index.html +32 -0
  91. package/examples/notes/look.ts +41 -0
  92. package/examples/notes/migrations/001-notes.ts +7 -0
  93. package/examples/notes/notes.json +78 -0
  94. package/examples/notes/page.ts +21 -0
  95. package/examples/notes/routes.ts +6 -0
  96. package/examples/notes/stories.jsonl +24 -0
  97. package/examples/page.ts +9 -2
  98. package/examples/people/generated/rows.ts +22 -0
  99. package/examples/people/generated/rules.ts +11 -1
  100. package/examples/people/links.ts +8 -9
  101. package/examples/people/people.css +1 -1
  102. package/examples/people/routes.ts +1 -3
  103. package/examples/people/stories.jsonl +1 -0
  104. package/examples/people/view.ts +5 -2
  105. package/examples/trip/generated/elements.ts +5 -3
  106. package/examples/trip/generated/queries.ts +12 -1
  107. package/examples/trip/generated/rows.ts +27 -0
  108. package/examples/trip/generated/rules.ts +56 -2
  109. package/examples/trip/index.html +58 -12
  110. package/examples/trip/line.css +186 -0
  111. package/examples/trip/line.ts +51 -40
  112. package/examples/trip/page.ts +65 -71
  113. package/examples/trip/routes.ts +9 -5
  114. package/examples/trip/stays.css +13 -13
  115. package/examples/trip/stays.ts +15 -10
  116. package/examples/trip/stories.jsonl +2 -0
  117. package/examples/trip/told.ts +3 -26
  118. package/examples/trip/trip.css +16 -0
  119. package/examples/trips/generated/elements.ts +1 -1
  120. package/examples/trips/generated/rows.ts +22 -0
  121. package/examples/trips/generated/rules.ts +9 -1
  122. package/examples/trips/index.html +10 -10
  123. package/examples/trips/map.ts +3 -14
  124. package/examples/trips/new-trip.ts +14 -16
  125. package/examples/trips/trips.css +24 -23
  126. package/examples/weeks/generated/elements.ts +1 -1
  127. package/examples/weeks/generated/queries.ts +11 -0
  128. package/examples/weeks/generated/rows.ts +22 -0
  129. package/examples/weeks/generated/rules.ts +11 -5
  130. package/examples/weeks/routes.ts +3 -2
  131. package/examples/weeks/stories.jsonl +1 -0
  132. package/examples/welcome.css +43 -33
  133. package/package.json +8 -2
  134. package/src/attachment.ts +17 -2
  135. package/src/awesome.ts +103 -0
  136. package/src/board.css +76 -0
  137. package/src/board.ts +173 -0
  138. package/src/cli.ts +28 -3
  139. package/src/compile.ts +821 -109
  140. package/src/definitions.ts +113 -27
  141. package/src/demo.css +2 -5
  142. package/src/draft.ts +48 -27
  143. package/src/drawer.ts +248 -0
  144. package/src/engine.ts +253 -170
  145. package/src/fields.ts +341 -0
  146. package/src/file-value.ts +12 -2
  147. package/src/files.ts +113 -33
  148. package/src/ground.ts +110 -0
  149. package/src/icon-names.ts +19 -2
  150. package/src/keep.ts +16 -3
  151. package/src/kit.ts +51 -0
  152. package/src/link.ts +3 -3
  153. package/src/map.css +140 -0
  154. package/src/map.ts +200 -0
  155. package/src/mcp.ts +129 -24
  156. package/src/members/demo.ts +13 -12
  157. package/src/members/generated/rows.ts +22 -0
  158. package/src/members/generated/rules.ts +3 -2
  159. package/src/members/group.ts +105 -55
  160. package/src/members/keys.ts +95 -79
  161. package/src/members/panel.css +40 -35
  162. package/src/members/panel.ts +58 -37
  163. package/src/migrate.ts +178 -125
  164. package/src/migrations/005-change-kept.ts +7 -0
  165. package/src/month.css +129 -0
  166. package/src/month.ts +179 -0
  167. package/src/ops.ts +40 -1
  168. package/src/page.css +11 -2
  169. package/src/page.ts +68 -17
  170. package/src/parts.css +614 -230
  171. package/src/parts.ts +259 -36
  172. package/src/plane.css +61 -0
  173. package/src/plane.ts +153 -0
  174. package/src/postgres-server.ts +60 -0
  175. package/src/reading.css +73 -0
  176. package/src/reading.ts +238 -0
  177. package/src/rows.css +289 -0
  178. package/src/rows.ts +864 -0
  179. package/src/search.css +80 -0
  180. package/src/search.ts +130 -0
  181. package/src/server.ts +355 -137
  182. package/src/settings.ts +9 -4
  183. package/src/sheet.ts +116 -0
  184. package/src/skill.ts +40 -0
  185. package/src/slots.css +90 -0
  186. package/src/slots.ts +213 -0
  187. package/src/specs.ts +38 -0
  188. package/src/starter.ts +19 -2
  189. package/src/store.ts +224 -161
  190. package/src/stories.ts +43 -11
  191. package/src/surface.ts +164 -0
  192. package/src/time.ts +2 -0
  193. package/src/timeline.css +111 -0
  194. package/src/timeline.ts +235 -0
  195. package/src/toast.ts +21 -48
  196. package/src/together.ts +15 -24
  197. package/src/tokens.css +89 -3
  198. package/src/tokens.json +287 -7
  199. package/src/tool.ts +210 -0
  200. package/src/upkeep.ts +47 -22
  201. package/src/views.css +43 -0
  202. package/src/views.ts +111 -0
  203. package/src/week.css +150 -0
  204. package/src/week.ts +254 -0
  205. package/src/write.ts +326 -78
  206. package/starter/CHANGELOG.md +8 -0
  207. package/starter/CLAUDE.md +9 -3
  208. package/starter/bunfig +5 -0
  209. package/starter/githooks/pre-commit +13 -0
  210. package/starter/prettierignore +5 -0
  211. package/starter/tests/hello.test.ts +2 -0
  212. package/starter/tests/records.test.ts +40 -0
  213. package/starter/todo.jsonl +0 -0
  214. package/docs/learning.md +0 -76
  215. package/examples/cafe/trust.ts +0 -20
  216. package/examples/desk/trust.ts +0 -24
  217. package/examples/people/trust.ts +0 -14
  218. package/examples/trip/answer-rows.ts +0 -70
  219. package/examples/trip/bar.ts +0 -89
  220. package/examples/trip/calendar-map.css +0 -711
  221. package/examples/trip/calendar-map.ts +0 -249
  222. package/examples/trip/drags.ts +0 -143
  223. package/examples/trip/drawer.ts +0 -250
  224. package/examples/trip/event-form.ts +0 -200
  225. package/examples/trip/holding.ts +0 -61
  226. package/examples/trip/map.ts +0 -234
  227. package/examples/trip/month.ts +0 -87
  228. package/examples/trip/other-weeks.ts +0 -67
  229. package/examples/trip/peek.ts +0 -71
  230. package/examples/trip/people-chips.ts +0 -74
  231. package/examples/trip/shell.ts +0 -39
  232. package/examples/trip/trust.ts +0 -51
  233. package/examples/trip/week.ts +0 -237
  234. package/examples/trip/writes.ts +0 -91
  235. package/examples/trip/zones.ts +0 -16
  236. package/examples/weeks/derive.ts +0 -23
  237. package/src/scrim.ts +0 -81
@@ -5,6 +5,8 @@
5
5
  {"window":{"events":{"week":{"from":"start","for":"P7D","length":"duration"},"month":{"from":"start","for":"P42D","length":"duration"}}}}
6
6
  {"links":{"keen":"people","asked":"people","declined":"people","arrives":"people","leaves":"people"}}
7
7
  {"noOverlap":{"stays":{"range":["from","until"]}}}
8
+ {"within":{"events":[{"lists":["keen","asked","declined"],"of":"people","refused":"an answer is from someone on the event"},{"lists":["arrives","leaves"],"of":"people","refused":"who comes or goes at an event is on it"}]}}
9
+ {"apart":{"events":[{"lists":["keen","asked","declined"],"refused":"one answer each"}]}}
8
10
  {"story":"Nora adds dinner in Gion, and Peter's phone shows it on the calendar and on the map","as":"nora","does":{"doc":"trip:1","ops":[{"op":"add","path":"/events/-","value":{"title":"Dinner in Gion","start":"2026-11-07T19:00:00","duration":"PT2H","location":"Gion, Kyoto","coordinates":"geo:35.0037,135.7788","people":[1,2]}}]},"seen":["peter","phone","nick","nora"],"unseen":["dev"]}
9
11
  {"story":"Peter adds a day to rest: with no place yet, it is on the calendar alone","as":"peter","does":{"doc":"trip:1","ops":[{"op":"add","path":"/events/-","value":{"title":"A day to rest","start":"2026-11-05T10:00:00","duration":"PT6H"}}]},"seen":["peter","phone","nora"]}
10
12
  {"story":"The shinkansen leaves an hour later: Nick moves it, and it moves on every calendar","as":"nick","does":{"doc":"trip:1","ops":[{"op":"replace","path":"/events/3/start","value":"2026-11-06T10:00:00"}]},"seen":["peter","phone","nick"]}
@@ -1,7 +1,6 @@
1
- // The lists <calendar-map> is told of by id, beyond it on the page, each read from a live list, never a search: the
2
- // people (people="…"), who give each event its people's colours and the form a chip for each, watched for a person
3
- // renamed, come or gone, or said to be someone; and the stays (stays="…"), drawn on the line, watched for one booked,
4
- // changed or cancelled.
1
+ // The lists the line (./line.ts) is told of by id, beyond it on the page (each where its sheet holds it, so never the
2
+ // sheet itself), each read from a live list, never a search: the people (people="…"), who give the line its faces, and
3
+ // the stays (stays="…"), drawn on it.
5
4
 
6
5
  import type { JPerson } from "../people/generated/elements.ts";
7
6
  import type { JStay } from "./generated/elements.ts";
@@ -23,26 +22,4 @@ export class Told {
23
22
  persons = () => (this.#list("people")?.getElementsByTagName(people.people.tag) ?? []) as Iterable<JPerson>;
24
23
  /** The stays, as their elements. */
25
24
  stays = () => [...((this.#list("stays")?.getElementsByTagName(trip.stays.tag) ?? []) as Iterable<JStay>)];
26
-
27
- /** Both watched, by `watch` (let go with the display): the keys of the people changed, and that a stay has. */
28
- watch(watch: <O extends MutationObserver>(o: O) => O, changed: (keys: Set<number>) => void, stayed: () => void) {
29
- const list = this.#list("people");
30
- if (list)
31
- watch(
32
- new MutationObserver((records) => {
33
- const keys = new Set(
34
- records.flatMap((r) =>
35
- r.type === "attributes"
36
- ? [(r.target as JPerson).key]
37
- : (r.target as Element).localName === people.people.place
38
- ? [...r.addedNodes, ...r.removedNodes].map((n) => (n as JPerson).key)
39
- : [],
40
- ),
41
- );
42
- if (keys.size) changed(keys);
43
- }),
44
- ).observe(list, { childList: true, subtree: true, attributeFilter: ["name", "member"] });
45
- const stays = this.#list("stays");
46
- if (stays) watch(new MutationObserver(stayed)).observe(stays, { childList: true, subtree: true, attributes: true });
47
- }
48
25
  }
@@ -0,0 +1,16 @@
1
+ /* The trip's page: its readings (joined's kit, and its line) with the map beside them, narrow; above them, as wide as
2
+ the page, where there's no room beside. */
3
+ .beside {
4
+ display: flex;
5
+ flex-wrap: wrap-reverse;
6
+ gap: var(--space-16);
7
+ align-items: flex-end; /* wrapped in reverse, the end is the top */
8
+ }
9
+ .beside j-views {
10
+ flex: 3 1 calc(var(--space-64) * 8);
11
+ min-width: 0;
12
+ }
13
+ .beside j-map {
14
+ flex: 1 1 calc(var(--space-64) * 4);
15
+ min-width: 0;
16
+ }
@@ -17,7 +17,7 @@ const send = (from: Element, ops: object[], why?: string) => new Promise<Answer>
17
17
  /** A trip's fields, as the stories give them. */
18
18
  export type JTripData = { "name": string; "organisers": number[]; "travellers": number[] };
19
19
  /** An add of a trip, as it's sent: its fields as the stories write them. */
20
- export type JTripValue = { "name": string; "organisers": number[]; "travellers": number[] };
20
+ export type JTripValue = { "name": string; "organisers": (number | `$${number}`)[]; "travellers": (number | `$${number}`)[] };
21
21
 
22
22
  /** <j-trip key>: name (string), organisers (ids in members), travellers (ids in members), each an attribute. */
23
23
  export class JTrip extends HTMLElement {
@@ -0,0 +1,22 @@
1
+ // Written by src/compile.ts from examples/trips/stories.jsonl: change the stories, not this.
2
+
3
+ // Each collection of trips as rows (joined/rows, the skill's §3): a page defines the ones it shows, as they are or
4
+ // extended, by define() from joined/rows, and holds each collection's element in its rows:
5
+ // <j-trips-rows><j-trips></j-trips></j-trips-rows>
6
+ // A collection whose items are each of one of another's is drawn under it there, where its element is put in too.
7
+ // To change what one says or does, extend its class and override a part (label, named, says, facts, deeds, row,
8
+ // step, asks); to change how it looks, style its parts (::part(row), title, state, facts, deeds, mine, step, add,
9
+ // under, drawer). Its sheet, a search of it and how a field reads are joined/kit's, given these collections by
10
+ // use(specs) (define() gives a display's own). To draw something else altogether, don't define it: a display of the app's own holds the same
11
+ // elements. Never change this file: change the stories.
12
+
13
+ import { rows, type Spec } from "joined/rows";
14
+ import { JTrip } from "./elements.ts";
15
+
16
+ const trips: Spec = {"doc":"trips","name":"trips","place":"j-trips","tag":"j-trip","one":"trip","title":"name","fields":[{"name":"name","type":"string","needed":true},{"name":"organisers","type":"ids","needed":true,"how":"ids","to":{"tag":"j-member","people":true},"ref":true},{"name":"travellers","type":"ids","needed":true,"how":"ids","to":{"tag":"j-member","people":true},"ref":true}]};
17
+
18
+ /** Each collection as joined's kit (joined/kit) is given it, by name: use(specs). */
19
+ export const specs = { "trips": trips };
20
+
21
+ /** <j-trips-rows>: trips's trips as rows, each named by its name. */
22
+ export class JTripsRows extends rows(trips, { "j-trip": JTrip }) {}
@@ -3,7 +3,7 @@
3
3
  export type Op = { op: "add" | "replace" | "remove"; path: string; value?: any };
4
4
 
5
5
  /** The document, and each collection: its element, the element its items are, their fields, those an add needs, and
6
- * what each link is to. */
6
+ * what each link is to and what each field pops (a value with a form, its view; a reference, what it points at). */
7
7
  export const doc = "trips";
8
8
  export const collections = {
9
9
  "trips": {
@@ -22,6 +22,14 @@ export const collections = {
22
22
  "links": {
23
23
  "organisers": "members",
24
24
  "travellers": "members"
25
+ },
26
+ "pops": {
27
+ "organisers": {
28
+ "to": "members"
29
+ },
30
+ "travellers": {
31
+ "to": "members"
32
+ }
25
33
  }
26
34
  }
27
35
  } as const;
@@ -27,21 +27,21 @@
27
27
  <div class="held" hidden></div>
28
28
  </main>
29
29
  <p class="note">Only the trips you're on are here. <a href="/">← joined</a></p>
30
- <dialog class="modal new-trip">
31
- <form method="dialog">
32
- <header><h2>A new trip</h2></header>
33
- <label>Its name<input name="name" required autocomplete="off" /></label>
30
+ <wa-dialog class="new-trip" light-dismiss>
31
+ <h2 slot="label">A new trip</h2>
32
+ <form id="new-trip">
33
+ <wa-input name="name" label="Its name" required autocomplete="off"></wa-input>
34
34
  <fieldset>
35
35
  <legend>Who travels</legend>
36
36
  <div class="who"></div>
37
37
  </fieldset>
38
- <p class="said" role="status"></p>
39
- <footer>
40
- <button type="button" class="act" name="never">Never mind</button>
41
- <button class="act ink" name="go" data-icon="add">Start it</button>
42
- </footer>
38
+ <wa-callout class="said" variant="danger" size="small" role="status" hidden></wa-callout>
43
39
  </form>
44
- </dialog>
40
+ <footer slot="footer">
41
+ <button type="button" class="act" name="never" form="new-trip">Never mind</button>
42
+ <button class="act ink" name="go" form="new-trip" data-icon="add">Start it</button>
43
+ </footer>
44
+ </wa-dialog>
45
45
  <script type="module" src="./page.ts"></script>
46
46
  </body>
47
47
  </html>
@@ -2,7 +2,8 @@
2
2
  // its hue, drawn about its middle so any card's frame shows them; no places, said so.
3
3
 
4
4
  import { hueOf } from "joined/hues";
5
- import { TILE, bounds, geo, tileAt, world } from "joined/geo";
5
+ import { bounds, geo, world } from "joined/geo";
6
+ import { tiles } from "joined/ground";
6
7
 
7
8
  /** The map of a trip's places, from its events: each its key (its pin's hue) and where it is, if it's settled. */
8
9
  export function mapOf(events: { key: number; coordinates?: string }[]) {
@@ -27,19 +28,7 @@ export function mapOf(events: { key: number; coordinates?: string }[]) {
27
28
  const [left, right, top, bottom] = bounds(xy);
28
29
  const [x0, y0] = [(left + right) / 2 - W / 2, (top + bottom) / 2 - H / 2];
29
30
  const ground = Object.assign(document.createElement("div"), { className: "ground" });
30
- const n = 2 ** z;
31
- for (let ty = Math.floor(y0 / TILE); ty * TILE < y0 + H; ty++)
32
- for (let tx = Math.floor(x0 / TILE); tx * TILE < x0 + W; tx++) {
33
- if (ty < 0 || ty >= n) continue;
34
- const img = Object.assign(document.createElement("img"), {
35
- src: tileAt(z, tx, ty),
36
- alt: "",
37
- loading: "lazy",
38
- });
39
- img.style.left = `${tx * TILE - x0}px`;
40
- img.style.top = `${ty * TILE - y0}px`;
41
- ground.append(img);
42
- }
31
+ ground.append(...tiles(z, x0, y0, W, H));
43
32
  for (const p of xy) {
44
33
  const pin = Object.assign(document.createElement("i"), { className: "pin" });
45
34
  pin.style.left = `${p.x - x0}px`;
@@ -9,7 +9,7 @@ import { collections } from "./generated/rules.ts";
9
9
  let me: number | undefined;
10
10
  signedIn((m) => (me = m));
11
11
 
12
- const dialog = document.querySelector<HTMLDialogElement>("dialog.new-trip")!,
12
+ const dialog = document.querySelector<HTMLElement & { open: boolean }>("wa-dialog.new-trip")!,
13
13
  form = dialog.querySelector("form")!,
14
14
  who = dialog.querySelector<HTMLElement>(".who")!;
15
15
  document.querySelector("button.new")!.addEventListener("click", () => {
@@ -18,29 +18,27 @@ document.querySelector("button.new")!.addEventListener("click", () => {
18
18
  ...[...members]
19
19
  .filter((m) => m.key !== me)
20
20
  .map((m) => {
21
- const label = Object.assign(document.createElement("label"), { className: "tick" });
22
- const box = Object.assign(document.createElement("input"), {
23
- type: "checkbox",
24
- name: "traveller",
25
- value: String(m.key),
26
- });
27
- label.append(m.data.name, box);
28
- return label;
21
+ // named and valued as attributes, so the form finds it at once (Web Awesome reflects them only as it draws)
22
+ const box = document.createElement("wa-checkbox");
23
+ box.setAttribute("name", "traveller");
24
+ box.setAttribute("value", String(m.key));
25
+ box.append(m.data.name);
26
+ return box;
29
27
  }),
30
28
  );
31
- dialog.showModal();
29
+ dialog.open = true;
32
30
  });
33
- dialog.querySelector("[name=never]")!.addEventListener("click", () => dialog.close());
31
+ dialog.querySelector("[name=never]")!.addEventListener("click", () => (dialog.open = false));
34
32
  form.addEventListener("submit", (e) => {
35
33
  e.preventDefault();
36
- const name = (form.elements.namedItem("name") as HTMLInputElement).value.trim();
34
+ const name = ((form.elements.namedItem("name") as HTMLInputElement).value ?? "").trim();
37
35
  if (!name || me === undefined) return;
38
- const travellers = [...form.querySelectorAll<HTMLInputElement>("[name=traveller]:checked")].map((b) =>
39
- Number(b.value),
40
- );
36
+ const travellers = [...form.querySelectorAll<HTMLInputElement>("[name=traveller]")]
37
+ .filter((b) => b.checked)
38
+ .map((b) => Number(b.value));
41
39
  // refused, it stays open with what was typed, and why is said in it; kept, it closes
42
40
  said(
43
41
  form.querySelector(".said")!,
44
42
  document.querySelector<JTrips>(collections.trips.place)!.add({ name, organisers: [me], travellers }),
45
- ).then((why) => why || dialog.close());
43
+ ).then((why) => why || (dialog.open = false));
46
44
  });
@@ -6,7 +6,6 @@
6
6
  display: flex;
7
7
  align-items: center;
8
8
  gap: var(--space-16);
9
- padding: var(--space-20) 0 0;
10
9
  }
11
10
  .trips .brand {
12
11
  flex: 1;
@@ -27,7 +26,7 @@
27
26
  margin: 0;
28
27
  }
29
28
  .trips .head .new {
30
- min-height: 44px;
29
+ min-height: var(--size-finger);
31
30
  padding: 0 var(--space-16);
32
31
  }
33
32
 
@@ -47,7 +46,7 @@ j-trips:empty::before {
47
46
  min-height: 18rem;
48
47
  background: var(--card);
49
48
  border: 1px solid var(--edge);
50
- border-radius: 4px;
49
+ border-radius: var(--radius);
51
50
  overflow: hidden;
52
51
  color: var(--ink);
53
52
  text-decoration: none;
@@ -76,30 +75,32 @@ j-trips:empty::before {
76
75
  width: 256px;
77
76
  height: 256px;
78
77
  }
78
+ /* a pin: solid in its hue, in a white ring (design.md, Colour); no shadow */
79
79
  .map .pin {
80
80
  position: absolute;
81
- width: 14px;
82
- height: 14px;
83
- margin: -7px 0 0 -7px;
84
- border: 2px solid var(--card);
85
- border-radius: 50%;
81
+ box-sizing: border-box;
82
+ width: var(--size-pin);
83
+ height: var(--size-pin);
84
+ margin: calc(var(--size-pin) / -2) 0 0 calc(var(--size-pin) / -2);
85
+ border: var(--size-ring) solid var(--pin-ring);
86
+ border-radius: var(--radius-dot);
86
87
  background: var(--hue);
87
- box-shadow: 0 0 0 1px rgb(0 0 0 / 0.25);
88
88
  }
89
89
  .map small {
90
90
  position: absolute;
91
- right: 4px;
92
- bottom: 4px;
93
- padding: 0 4px;
94
- border-radius: 3px;
95
- background: rgb(255 255 255 / 0.8);
96
- color: #333;
91
+ right: var(--space-4);
92
+ bottom: var(--space-4);
93
+ padding: 0 var(--space-4);
94
+ border-radius: var(--radius-inner);
95
+ background: color-mix(in srgb, var(--card) 80%, transparent);
96
+ color: var(--muted);
97
97
  font: var(--font-tiny);
98
98
  }
99
99
  .map.none {
100
100
  display: grid;
101
101
  place-items: center;
102
- background: color-mix(in srgb, var(--hue-3) var(--tint), var(--card));
102
+ /* no map yet: the well, as a map before its tiles (design.md, Colour); a hue is a thing's, and this is none */
103
+ background: var(--well);
103
104
  color: var(--muted);
104
105
  font: var(--font-small);
105
106
  }
@@ -120,10 +121,10 @@ j-trips:empty::before {
120
121
  }
121
122
  .next {
122
123
  display: grid;
123
- gap: 2px;
124
+ gap: var(--space-4);
124
125
  padding: var(--space-10) var(--space-12);
125
- border-radius: 3px;
126
- background: color-mix(in srgb, var(--hue-0) var(--tint), var(--card));
126
+ border-radius: var(--radius-inner);
127
+ background: var(--well);
127
128
  font: var(--font-small);
128
129
  }
129
130
  .next .label {
@@ -151,22 +152,22 @@ j-trips:empty::before {
151
152
  }
152
153
 
153
154
  /* New trip: its name, and who travels, a tick each */
154
- dialog.new-trip fieldset {
155
+ wa-dialog.new-trip fieldset {
155
156
  display: grid;
156
157
  gap: var(--space-6);
157
158
  margin: 0;
158
159
  padding: 0;
159
160
  border: 0;
160
161
  }
161
- dialog.new-trip legend {
162
+ wa-dialog.new-trip legend {
162
163
  margin-bottom: var(--space-6);
163
164
  font: var(--font-label);
164
165
  }
165
- dialog.new-trip label.tick {
166
+ wa-dialog.new-trip label.tick {
166
167
  display: flex;
167
168
  justify-content: space-between;
168
169
  align-items: center;
169
- min-height: 36px;
170
+ min-height: var(--size-touch);
170
171
  font: var(--font-row);
171
172
  }
172
173
 
@@ -1,4 +1,4 @@
1
- // Written by src/compile.ts from examples/weeks/derive.ts: change it and its example, not this.
1
+ // Written by src/compile.ts from examples/weeks/stories.jsonl: change the stories, not this.
2
2
 
3
3
  // Each collection is an element, defined here: on a page, it holds the document, and its items
4
4
  // are put inside it. Each item is an element, defined by the page: as it is, or by a view that
@@ -0,0 +1,11 @@
1
+ // Written by src/compile.ts from examples/weeks/stories.jsonl: change the stories, not this.
2
+
3
+ /** weeks, as a member has it, one statement over the app's tables (SQLite): its parameters $doc and $member. */
4
+ export const query = `SELECT json_object('version', COALESCE((SELECT version FROM documents WHERE name = $doc), 0),
5
+ 'weeks', json((SELECT json_group_array(json_object('id', w.id, 'trip', w.item, 'week', w.week, 'events', w.n) ORDER BY w.id)
6
+ FROM (SELECT ROW_NUMBER() OVER (ORDER BY o."trip", date(o."start", 'weekday 0', '-6 days')) AS id, o."trip" AS item, date(o."start", 'weekday 0', '-6 days') AS week, COUNT(*) AS n FROM "events" o WHERE (EXISTS (SELECT 1 FROM "trips_organisers" p WHERE p."trips" = o."trip" AND p."organisers" = $member) OR EXISTS (SELECT 1 FROM "trips_travellers" p WHERE p."trips" = o."trip" AND p."travellers" = $member)) GROUP BY o."trip", date(o."start", 'weekday 0', '-6 days')) w))) AS doc`;
7
+
8
+ /** Its query, as Postgres says it. */
9
+ export const postgres = {
10
+ "query": "SELECT json_build_object('version', COALESCE((SELECT version FROM documents WHERE name = $doc), 0),\n 'weeks', (SELECT COALESCE(json_agg(json_build_object('id', w.id, 'trip', w.item, 'week', w.week, 'events', w.n) ORDER BY w.id), '[]')\n FROM (SELECT ROW_NUMBER() OVER (ORDER BY o.\"trip\", to_char(date_trunc('week', CAST(o.\"start\" AS timestamp)), 'YYYY-MM-DD')) AS id, o.\"trip\" AS item, to_char(date_trunc('week', CAST(o.\"start\" AS timestamp)), 'YYYY-MM-DD') AS week, COUNT(*) AS n FROM \"events\" o WHERE (EXISTS (SELECT 1 FROM \"trips_organisers\" p WHERE p.\"trips\" = o.\"trip\" AND p.\"organisers\" = $member) OR EXISTS (SELECT 1 FROM \"trips_travellers\" p WHERE p.\"trips\" = o.\"trip\" AND p.\"travellers\" = $member)) GROUP BY o.\"trip\", to_char(date_trunc('week', CAST(o.\"start\" AS timestamp)), 'YYYY-MM-DD')) w)) AS doc"
11
+ };
@@ -0,0 +1,22 @@
1
+ // Written by src/compile.ts from examples/weeks/stories.jsonl: change the stories, not this.
2
+
3
+ // Each collection of weeks as rows (joined/rows, the skill's §3): a page defines the ones it shows, as they are or
4
+ // extended, by define() from joined/rows, and holds each collection's element in its rows:
5
+ // <j-weeks-rows><j-weeks></j-weeks></j-weeks-rows>
6
+ // A collection whose items are each of one of another's is drawn under it there, where its element is put in too.
7
+ // To change what one says or does, extend its class and override a part (label, named, says, facts, deeds, row,
8
+ // step, asks); to change how it looks, style its parts (::part(row), title, state, facts, deeds, mine, step, add,
9
+ // under, drawer). Its sheet, a search of it and how a field reads are joined/kit's, given these collections by
10
+ // use(specs) (define() gives a display's own). To draw something else altogether, don't define it: a display of the app's own holds the same
11
+ // elements. Never change this file: change the stories.
12
+
13
+ import { rows, type Spec } from "joined/rows";
14
+ import { JWeek } from "./elements.ts";
15
+
16
+ const weeks: Spec = {"doc":"weeks","name":"weeks","place":"j-weeks","tag":"j-week","one":"week","title":"week","fields":[{"name":"trip","type":"integer","needed":true},{"name":"week","type":"string","needed":true},{"name":"events","type":"integer","needed":true}]};
17
+
18
+ /** Each collection as joined's kit (joined/kit) is given it, by name: use(specs). */
19
+ export const specs = { "weeks": weeks };
20
+
21
+ /** <j-weeks-rows>: weeks's weeks as rows, each named by its week. */
22
+ export class JWeeksRows extends rows(weeks, { "j-week": JWeek }) {}
@@ -1,9 +1,9 @@
1
- // Written by src/compile.ts from examples/weeks/derive.ts: change it and its example, not this.
1
+ // Written by src/compile.ts from examples/weeks/stories.jsonl: change the stories, not this.
2
2
 
3
3
  export type Op = { op: "add" | "replace" | "remove"; path: string; value?: any };
4
4
 
5
5
  /** The document, and each collection: its element, the element its items are, their fields, those an add needs, and
6
- * what each link is to. */
6
+ * what each link is to and what each field pops (a value with a form, its view; a reference, what it points at). */
7
7
  export const doc = "weeks";
8
8
  export const collections = {
9
9
  "weeks": {
@@ -19,7 +19,8 @@ export const collections = {
19
19
  "week",
20
20
  "events"
21
21
  ],
22
- "links": {}
22
+ "links": {},
23
+ "pops": {}
23
24
  }
24
25
  } as const;
25
26
  /** Whether every story is anonymous, none told as a member: where every app's is, the project has no members. */
@@ -27,7 +28,12 @@ export const anonymous = true;
27
28
  /** What kind of document weeks is, by the flows it uses: static, changed only with a release (a page reads it, and
28
29
  * never subscribes); read-only, live, but no page writes it (derived); or shared, its members' to write. */
29
30
  export const type = "read-only";
31
+ /** The tables its query reads: a change to any of them moves its version, and is told to each page holding it, as
32
+ * its member has it. */
33
+ export const reads = ["events","trips_organisers","trips_travellers"];
34
+ /** It's read as each member has it: a parameter of its query. */
35
+ export const member = true;
30
36
  /** The parts of weeks a page may hold alone, by its query's parameters (its definitions' window): null, none. */
31
37
  export const window = null;
32
- /** The documents this one is derived from (its derive.ts): what the server derives it again on a write to. */
33
- export const derived = ["trips","trip"];
38
+ /** The document as one statement over its tables (generated/queries.ts). */
39
+ export { query, postgres } from "./queries.ts";
@@ -1,4 +1,5 @@
1
- // The weeks of each trip a member is on: a document derived from the trips (derive.ts), read by a trip's page.
1
+ // The weeks of each trip a member is on, and how many of its events each holds: a read-only document, its query
2
+ // written from its definition (stories.jsonl), the member its parameter. A trip's page holds one week
3
+ // (trip:1?week=2026-11-02) and says beneath it what's on its other weeks, a way to each.
2
4
 
3
5
  export * as document from "./generated/rules.ts";
4
- export { derive } from "./derive.ts";
@@ -0,0 +1 @@
1
+ {"documents":{"weeks":{"weeks":{"from":"events","by":{"trip":"trips"},"seen":["organisers","travellers"],"week":"start","count":"events"}}}}
@@ -7,7 +7,6 @@
7
7
  flex-wrap: wrap;
8
8
  align-items: center;
9
9
  gap: var(--space-12) var(--space-24);
10
- padding: var(--space-20) 0 0;
11
10
  }
12
11
  .welcome .brand {
13
12
  margin: 0;
@@ -20,8 +19,16 @@
20
19
  font: var(--font-row);
21
20
  }
22
21
  .welcome nav a {
22
+ display: inline-flex;
23
+ align-items: center;
24
+ min-height: var(--size-touch);
23
25
  text-decoration: none;
24
26
  }
27
+ @media (max-width: 40rem), (pointer: coarse) {
28
+ .welcome nav a {
29
+ min-height: var(--size-finger);
30
+ }
31
+ }
25
32
  .welcome nav a:hover,
26
33
  .welcome .examples a:hover .open {
27
34
  text-decoration: underline;
@@ -74,7 +81,7 @@
74
81
  margin: var(--space-4) 0 0;
75
82
  }
76
83
  .hero .go .act {
77
- min-height: 44px;
84
+ min-height: var(--size-finger);
78
85
  padding: 0 var(--space-16);
79
86
  text-decoration: none;
80
87
  }
@@ -83,19 +90,18 @@
83
90
  display: grid;
84
91
  gap: var(--space-10);
85
92
  }
86
- /* the trip's picture, cut to its map and its week: its page's margins and its drawer left out */
93
+ /* the trip's picture, light or dark as the page is, cut by the build to the page as far as its week and map run
94
+ (design/scenes.ts): drawn whole, never cropped here */
87
95
  .hero .frame {
88
- aspect-ratio: 1280 / 1208;
89
96
  overflow: hidden;
90
97
  border: 1px solid var(--edge);
91
- border-radius: 4px;
98
+ border-radius: var(--radius);
92
99
  background: var(--paper);
93
100
  }
94
101
  .hero .frame img {
95
102
  display: block;
96
- width: 148.7%;
103
+ width: 100%;
97
104
  height: auto;
98
- margin: -1.5% 0 0 -14.5%;
99
105
  }
100
106
  .hero figcaption {
101
107
  font: var(--font-small);
@@ -116,7 +122,7 @@
116
122
  padding: 0 0 var(--space-16);
117
123
  background: var(--card);
118
124
  border: 1px solid var(--edge);
119
- border-radius: 4px;
125
+ border-radius: var(--radius);
120
126
  overflow: hidden;
121
127
  color: var(--ink);
122
128
  text-decoration: none;
@@ -148,15 +154,21 @@
148
154
  .picture.hello {
149
155
  background: color-mix(in srgb, var(--hue-4) var(--tint), var(--card));
150
156
  }
151
- .picture.cafe {
157
+ /* (not .cafe: the cafe's own page has that, and the design system holds both) */
158
+ .picture.tickets {
159
+ align-items: flex-start;
152
160
  background: color-mix(in srgb, var(--hue-1) var(--tint), var(--card));
153
161
  }
162
+ /* (a picture light or dark: the picture element only chooses, the img is what's drawn) */
163
+ .examples picture {
164
+ display: contents;
165
+ }
154
166
  /* the trip read as a line, its beads and their events */
155
167
  .picture.shot {
156
168
  width: 100%;
157
169
  padding: 0;
158
170
  object-fit: cover;
159
- object-position: 50% 60%;
171
+ object-position: top;
160
172
  border-bottom: 1px solid var(--line);
161
173
  }
162
174
  .mini {
@@ -169,7 +181,7 @@
169
181
  box-sizing: border-box;
170
182
  background: var(--card);
171
183
  border: 1px solid var(--edge);
172
- border-radius: 4px;
184
+ border-radius: var(--radius);
173
185
  font: var(--font-small);
174
186
  }
175
187
  .mini > b {
@@ -178,12 +190,12 @@
178
190
  }
179
191
  .mini .field {
180
192
  border: 1px solid var(--edge);
181
- border-radius: 4px;
193
+ border-radius: var(--radius);
182
194
  padding: var(--space-4) var(--space-8);
183
195
  color: var(--muted);
184
196
  }
185
197
  .mini .button {
186
- border-radius: 4px;
198
+ border-radius: var(--radius);
187
199
  padding: var(--space-4) var(--space-10);
188
200
  background: var(--ink);
189
201
  color: var(--card);
@@ -202,10 +214,10 @@
202
214
  }
203
215
  .pill {
204
216
  align-self: flex-start;
205
- border-radius: 99px;
217
+ border-radius: var(--radius-pill);
206
218
  padding: 0 var(--space-8);
207
- background: var(--hue-1);
208
- color: #111;
219
+ background: color-mix(in srgb, var(--hue-1) var(--tint-strong), var(--card));
220
+ color: var(--ink);
209
221
  font: var(--font-tiny);
210
222
  }
211
223
  .pill.ready {
@@ -235,13 +247,12 @@
235
247
  padding: var(--space-12) var(--space-14);
236
248
  background: var(--card);
237
249
  border: 1px solid var(--edge);
238
- border-radius: 4px;
239
- font:
240
- 400 12.5px/1.55 ui-monospace,
241
- Menlo,
242
- monospace;
243
- white-space: pre;
244
- overflow-x: auto;
250
+ border-radius: var(--radius);
251
+ /* the small style, in a monospace face; a line wrapped, never cut at the box's edge */
252
+ font: var(--font-small);
253
+ font-family: var(--mono);
254
+ white-space: pre-wrap;
255
+ overflow-wrap: anywhere;
245
256
  }
246
257
 
247
258
  /* what two AIs said, in ink (a .said is a refusal, in danger), side by side where there's room */
@@ -265,16 +276,22 @@ section.quotes figcaption {
265
276
  font: var(--font-small);
266
277
  }
267
278
 
268
- /* the film */
279
+ /* the film: its own play at the poster's foot, at its start (the poster's words are at its middle) */
269
280
  figure.film {
281
+ position: relative;
270
282
  margin: var(--space-48) 0 0;
271
283
  }
284
+ figure.film .play {
285
+ position: absolute;
286
+ left: var(--space-16);
287
+ top: var(--space-16);
288
+ }
272
289
  figure.film video {
273
290
  display: block;
274
291
  width: 100%;
275
292
  height: auto;
276
- border-radius: 4px;
277
- background: #1a1f36;
293
+ border-radius: var(--radius);
294
+ background: var(--well);
278
295
  }
279
296
  figure.film figcaption {
280
297
  margin-top: var(--space-8);
@@ -289,11 +306,4 @@ figure.film figcaption {
289
306
  .welcome .brand {
290
307
  flex: 1;
291
308
  }
292
- .hero .frame {
293
- aspect-ratio: 375 / 600;
294
- }
295
- .hero .frame img {
296
- width: 100%;
297
- margin: -94.5% 0 0;
298
- }
299
309
  }