@blueshed/joined 0.2.1 → 0.3.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/.claude/skills/joined/SKILL.md +9 -1
- package/.claude/skills/joined/reference.md +270 -55
- package/.claude/skills/joined-door/SKILL.md +57 -0
- package/README.md +19 -50
- package/docs/design.md +76 -10
- package/docs/introduction.md +18 -18
- package/docs/light-and-shadow.svg +1 -1
- package/examples/README.md +20 -0
- package/examples/account/account.json +1 -0
- package/examples/account/derive.ts +41 -0
- package/examples/account/generated/elements.ts +52 -0
- package/examples/account/generated/rows.ts +22 -0
- package/examples/account/generated/rules.ts +32 -0
- package/examples/account/routes.ts +5 -0
- package/examples/app.css +2 -1
- package/examples/cafe/books.html +2 -2
- package/examples/cafe/cafe.css +9 -16
- package/examples/cafe/generated/books.rows.ts +22 -0
- package/examples/cafe/generated/books.rules.ts +3 -2
- package/examples/cafe/generated/kitchen.rows.ts +27 -0
- package/examples/cafe/generated/kitchen.rules.ts +11 -1
- package/examples/cafe/generated/menu.rows.ts +22 -0
- package/examples/cafe/generated/menu.rules.ts +3 -2
- package/examples/cafe/generated/order.rows.ts +27 -0
- package/examples/cafe/generated/order.rules.ts +11 -1
- package/examples/cafe/generated/staff.rows.ts +22 -0
- package/examples/cafe/generated/staff.rules.ts +6 -1
- package/examples/cafe/generated/supplies.queries.ts +4 -2
- package/examples/cafe/generated/supplies.rows.ts +22 -0
- package/examples/cafe/generated/supplies.rules.ts +12 -1
- package/examples/cafe/generated/till.queries.ts +2 -0
- package/examples/cafe/generated/till.rows.ts +27 -0
- package/examples/cafe/generated/till.rules.ts +11 -1
- package/examples/cafe/index.html +14 -15
- package/examples/cafe/kitchen.ts +1 -1
- package/examples/cafe/look.ts +30 -0
- package/examples/cafe/menu.html +10 -26
- package/examples/cafe/menu.ts +8 -80
- package/examples/cafe/order.html +6 -6
- package/examples/cafe/order.ts +5 -1
- package/examples/cafe/routes.ts +0 -1
- package/examples/cafe/stories.jsonl +3 -1
- package/examples/cafe/supplies.html +34 -34
- package/examples/cafe/supplies.ts +14 -11
- package/examples/cafe/till.ts +5 -1
- package/examples/chart/arches.ts +148 -0
- package/examples/chart/chart.css +6 -0
- package/examples/chart/chart.json +87 -0
- package/examples/chart/generated/elements.ts +105 -0
- package/examples/chart/generated/queries.ts +36 -0
- package/examples/chart/generated/rows.ts +27 -0
- package/examples/chart/generated/rules.ts +111 -0
- package/examples/chart/grid.ts +118 -0
- package/examples/chart/index.html +78 -0
- package/examples/chart/migrations/001-chart.ts +6 -0
- package/examples/chart/migrations/002-create-conditions.ts +6 -0
- package/examples/chart/page.ts +20 -0
- package/examples/chart/routes.ts +7 -0
- package/examples/chart/stories.jsonl +14 -0
- package/examples/chart/teeth.ts +57 -0
- package/examples/desk/generated/rows.ts +22 -0
- package/examples/desk/generated/rules.ts +34 -1
- package/examples/desk/index.html +9 -2
- package/examples/desk/routes.ts +0 -2
- package/examples/desk/stories.jsonl +3 -2
- package/examples/desk/thumbs.ts +2 -2
- package/examples/hello/generated/elements.ts +2 -2
- package/examples/hello/generated/rules.ts +3 -2
- package/examples/hello/hello.css +2 -4
- package/examples/hello/index.html +10 -3
- package/examples/hello/page.ts +4 -4
- package/examples/index.html +4 -5
- package/examples/notes/generated/elements.ts +112 -0
- package/examples/notes/generated/queries.ts +36 -0
- package/examples/notes/generated/rows.ts +27 -0
- package/examples/notes/generated/rules.ts +133 -0
- package/examples/notes/index.html +32 -0
- package/examples/notes/look.ts +41 -0
- package/examples/notes/migrations/001-notes.ts +7 -0
- package/examples/notes/notes.json +78 -0
- package/examples/notes/page.ts +21 -0
- package/examples/notes/routes.ts +6 -0
- package/examples/notes/stories.jsonl +21 -0
- package/examples/people/generated/rows.ts +22 -0
- package/examples/people/generated/rules.ts +11 -1
- package/examples/people/links.ts +2 -1
- package/examples/people/routes.ts +1 -3
- package/examples/people/stories.jsonl +1 -0
- package/examples/people/view.ts +5 -2
- package/examples/trip/generated/elements.ts +4 -2
- package/examples/trip/generated/queries.ts +12 -1
- package/examples/trip/generated/rows.ts +27 -0
- package/examples/trip/generated/rules.ts +56 -2
- package/examples/trip/index.html +58 -12
- package/examples/trip/line.css +186 -0
- package/examples/trip/line.ts +51 -40
- package/examples/trip/page.ts +65 -71
- package/examples/trip/routes.ts +9 -5
- package/examples/trip/stays.css +12 -12
- package/examples/trip/stays.ts +15 -10
- package/examples/trip/stories.jsonl +2 -0
- package/examples/trip/told.ts +3 -26
- package/examples/trip/trip.css +16 -0
- package/examples/trips/generated/rows.ts +22 -0
- package/examples/trips/generated/rules.ts +9 -1
- package/examples/trips/index.html +10 -10
- package/examples/trips/map.ts +3 -14
- package/examples/trips/new-trip.ts +14 -16
- package/examples/weeks/generated/elements.ts +1 -1
- package/examples/weeks/generated/queries.ts +11 -0
- package/examples/weeks/generated/rows.ts +22 -0
- package/examples/weeks/generated/rules.ts +11 -5
- package/examples/weeks/routes.ts +3 -2
- package/examples/weeks/stories.jsonl +1 -0
- package/examples/welcome.css +7 -5
- package/package.json +8 -2
- package/src/awesome.ts +103 -0
- package/src/board.css +75 -0
- package/src/board.ts +173 -0
- package/src/cli.ts +15 -2
- package/src/compile.ts +569 -35
- package/src/definitions.ts +53 -15
- package/src/draft.ts +38 -23
- package/src/drawer.ts +222 -0
- package/src/engine.ts +240 -166
- package/src/fields.ts +268 -0
- package/src/files.ts +6 -4
- package/src/ground.ts +110 -0
- package/src/icon-names.ts +15 -2
- package/src/kit.ts +51 -0
- package/src/link.ts +3 -3
- package/src/map.css +133 -0
- package/src/map.ts +200 -0
- package/src/mcp.ts +176 -38
- package/src/members/demo.ts +13 -12
- package/src/members/generated/rows.ts +22 -0
- package/src/members/generated/rules.ts +3 -2
- package/src/members/group.ts +65 -39
- package/src/members/keys.ts +93 -77
- package/src/members/panel.css +23 -17
- package/src/members/panel.ts +49 -35
- package/src/migrate.ts +120 -104
- package/src/month.css +125 -0
- package/src/month.ts +179 -0
- package/src/page.css +8 -0
- package/src/page.ts +11 -7
- package/src/parts.css +462 -170
- package/src/parts.ts +209 -26
- package/src/plane.css +56 -0
- package/src/plane.ts +151 -0
- package/src/postgres-server.ts +60 -0
- package/src/reading.css +77 -0
- package/src/reading.ts +238 -0
- package/src/rows.css +308 -0
- package/src/rows.ts +780 -0
- package/src/search.css +80 -0
- package/src/search.ts +130 -0
- package/src/server.ts +211 -114
- package/src/settings.ts +9 -4
- package/src/sheet.ts +114 -0
- package/src/skill.ts +40 -0
- package/src/slots.css +94 -0
- package/src/slots.ts +213 -0
- package/src/specs.ts +38 -0
- package/src/starter.ts +5 -2
- package/src/store.ts +184 -143
- package/src/stories.ts +43 -11
- package/src/surface.ts +159 -0
- package/src/timeline.css +111 -0
- package/src/timeline.ts +226 -0
- package/src/toast.ts +21 -48
- package/src/together.ts +0 -7
- package/src/tokens.css +78 -1
- package/src/tokens.json +249 -0
- package/src/tool.ts +211 -0
- package/src/upkeep.ts +18 -20
- package/src/views.css +44 -0
- package/src/views.ts +94 -0
- package/src/week.css +151 -0
- package/src/week.ts +250 -0
- package/src/write.ts +219 -73
- package/starter/CLAUDE.md +3 -3
- package/starter/bunfig +4 -0
- package/starter/prettierignore +4 -0
- package/starter/tests/hello.test.ts +2 -0
- package/docs/learning.md +0 -76
- package/examples/cafe/trust.ts +0 -20
- package/examples/desk/trust.ts +0 -24
- package/examples/people/trust.ts +0 -14
- package/examples/trip/answer-rows.ts +0 -70
- package/examples/trip/bar.ts +0 -89
- package/examples/trip/calendar-map.css +0 -711
- package/examples/trip/calendar-map.ts +0 -249
- package/examples/trip/drags.ts +0 -143
- package/examples/trip/drawer.ts +0 -250
- package/examples/trip/event-form.ts +0 -200
- package/examples/trip/holding.ts +0 -61
- package/examples/trip/map.ts +0 -234
- package/examples/trip/month.ts +0 -87
- package/examples/trip/other-weeks.ts +0 -67
- package/examples/trip/peek.ts +0 -71
- package/examples/trip/people-chips.ts +0 -74
- package/examples/trip/shell.ts +0 -39
- package/examples/trip/trust.ts +0 -51
- package/examples/trip/week.ts +0 -237
- package/examples/trip/writes.ts +0 -91
- package/examples/trip/zones.ts +0 -16
- package/examples/weeks/derive.ts +0 -23
- package/src/scrim.ts +0 -81
package/src/toast.ts
CHANGED
|
@@ -1,52 +1,25 @@
|
|
|
1
|
-
// A toast: a page's own words, for a moment, with toast():
|
|
2
|
-
// toast rather than fading (a walk-through saying each step as it's made). A
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// as its change), nor a refusal (whoever sent it says why, beside what sent it).
|
|
1
|
+
// A toast: a page's own words, for a moment, with toast(): Web Awesome's (wa-toast), at the foot of the page, an icon
|
|
2
|
+
// before them, and held until the next toast rather than fading (a walk-through saying each step as it's made). A
|
|
3
|
+
// page that wants it imports this. Words in quick succession replace it, never stack. A write that lands isn't
|
|
4
|
+
// toasted (what it did shows as its change), nor a refusal (whoever sent it says why, beside what sent it).
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
position: fixed;
|
|
12
|
-
left: 50%;
|
|
13
|
-
bottom: calc(var(--space-16) + env(safe-area-inset-bottom));
|
|
14
|
-
z-index: 20;
|
|
15
|
-
display: flex;
|
|
16
|
-
gap: var(--space-10);
|
|
17
|
-
align-items: center;
|
|
18
|
-
box-sizing: border-box;
|
|
19
|
-
/* as wide as its words, as the screen allows: fixed at the middle, it would fit only the half to its right */
|
|
20
|
-
width: max-content;
|
|
21
|
-
max-width: min(36rem, calc(100vw - 2rem));
|
|
22
|
-
margin: 0;
|
|
23
|
-
padding: var(--space-6) var(--space-16);
|
|
24
|
-
border-radius: 4px;
|
|
25
|
-
background: var(--ink);
|
|
26
|
-
color: var(--card);
|
|
27
|
-
font: var(--font-small);
|
|
28
|
-
translate: -50% 0;
|
|
29
|
-
opacity: 0;
|
|
30
|
-
transition: opacity 0.2s;
|
|
31
|
-
pointer-events: none;
|
|
32
|
-
}
|
|
33
|
-
p.shown { opacity: 1; }
|
|
34
|
-
svg { flex: none; }
|
|
35
|
-
@media (prefers-reduced-motion: reduce) { p { transition: none; } }
|
|
36
|
-
</style><p role="status" aria-live="polite"></p>`;
|
|
37
|
-
const said = root.querySelector("p")!;
|
|
38
|
-
let hide: ReturnType<typeof setTimeout> | undefined;
|
|
6
|
+
import "./awesome.ts";
|
|
7
|
+
|
|
8
|
+
const stack = Object.assign(document.createElement("wa-toast"), { placement: "bottom-center" });
|
|
9
|
+
document.body.append(stack);
|
|
39
10
|
|
|
40
|
-
/** Words in the toast, an icon before them if given: for 1.5s, or held until the next toast. The words
|
|
41
|
-
*
|
|
11
|
+
/** Words in the toast, an icon before them if given: for 1.5s, or held until the next toast. The words are text,
|
|
12
|
+
* or a node of the page's own (a name in bold); empty words take it away. */
|
|
42
13
|
export function toast(words: string | Node, { icon, hold = false }: { icon?: Element; hold?: boolean } = {}) {
|
|
43
|
-
|
|
44
|
-
if (!words) return
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
14
|
+
for (const old of stack.querySelectorAll("wa-toast-item")) old.remove();
|
|
15
|
+
if (!words) return;
|
|
16
|
+
const item = Object.assign(document.createElement("wa-toast-item"), { duration: hold ? 0 : 1500 });
|
|
17
|
+
item.setAttribute("variant", "neutral");
|
|
18
|
+
if (icon) {
|
|
19
|
+
const at = Object.assign(document.createElement("span"), { slot: "icon" });
|
|
20
|
+
at.append(icon);
|
|
21
|
+
item.append(at);
|
|
22
|
+
}
|
|
23
|
+
item.append(words);
|
|
24
|
+
stack.append(item);
|
|
50
25
|
}
|
|
51
|
-
|
|
52
|
-
document.body.append(host);
|
package/src/together.ts
CHANGED
|
@@ -58,13 +58,6 @@ export function named(w: Part, adds: Added[], rootOf: (name: string) => string |
|
|
|
58
58
|
};
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
/** A write's parts, each named as the write names it (named) and landed in turn (`land`: its ops as they were made). */
|
|
62
|
-
export function inTurn(writes: Part[], rootOf: (name: string) => string | undefined, land: (part: Part) => Op[]) {
|
|
63
|
-
const adds: Added[] = [];
|
|
64
|
-
for (const w of writes)
|
|
65
|
-
adds.push(...addsOf(land(named(w, adds, rootOf))).map((o) => ({ coll: parts(o.path).coll, id: o.value.id })));
|
|
66
|
-
}
|
|
67
|
-
|
|
68
61
|
/** Why a list of writes, a story's does or cannot (or a write of one), isn't one, or null: each a write, and a part's
|
|
69
62
|
* document named by an add (`board:$1`) only by one a part before it makes. */
|
|
70
63
|
export function unwritten(writes: unknown[]): string | null {
|
package/src/tokens.css
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/* joined's tokens, made from src/tokens.json by scripts/design.ts (bun run design): never edited by
|
|
2
2
|
hand. Linked by every page, before app.css. A display's shadow reads them as they are, since custom
|
|
3
3
|
properties pass into a shadow; never import this file as text into one (a page that links it makes
|
|
4
|
-
it {} in its bundle). What each is for: src/tokens.json, and docs/design.md.
|
|
4
|
+
it {} in its bundle). What each is for: src/tokens.json, and docs/design.md. Web Awesome's theme
|
|
5
|
+
comes first, its tokens (--wa-) then set to joined's (src/awesome.ts). */
|
|
6
|
+
|
|
7
|
+
@import "@awesome.me/webawesome/dist/styles/themes/default.css";
|
|
8
|
+
@import "@awesome.me/webawesome/dist/styles/utilities/scroll-lock.css";
|
|
5
9
|
|
|
6
10
|
:root {
|
|
7
11
|
color-scheme: light dark;
|
|
@@ -60,11 +64,84 @@
|
|
|
60
64
|
--space-48: 48px;
|
|
61
65
|
--space-64: 64px;
|
|
62
66
|
--gutter: clamp(1rem, 4vw, 1.5rem);
|
|
67
|
+
--radius: 4px;
|
|
68
|
+
--radius-sheet: 14px;
|
|
69
|
+
--radius-inner: 3px;
|
|
70
|
+
--radius-pill: 999px;
|
|
71
|
+
--radius-dot: 50%;
|
|
72
|
+
--size-finger: 44px;
|
|
73
|
+
--size-touch: 32px;
|
|
74
|
+
--size-control: 32px;
|
|
75
|
+
--size-panel: 320px;
|
|
76
|
+
--size-modal: 25rem;
|
|
77
|
+
--size-sheet: 22rem;
|
|
78
|
+
--size-list: 40rem;
|
|
79
|
+
--size-said: 36rem;
|
|
80
|
+
--size-pin: 16px;
|
|
81
|
+
--size-dot: 7px;
|
|
82
|
+
--size-grip: 7px;
|
|
83
|
+
--size-stripe: 3px;
|
|
63
84
|
--rise: 420ms cubic-bezier(0.32, 0.72, 0, 1);
|
|
64
85
|
--fall: 280ms cubic-bezier(0.4, 0, 1, 1);
|
|
65
86
|
--ask: 220ms cubic-bezier(0.32, 0.72, 0, 1);
|
|
66
87
|
--ask-out: 160ms ease-out;
|
|
67
88
|
--drop: 160ms ease-out;
|
|
89
|
+
--wa-font-family-body: var(--sans);
|
|
90
|
+
--wa-font-family-heading: var(--sans);
|
|
91
|
+
--wa-font-weight-action: 600;
|
|
92
|
+
--wa-color-surface-default: var(--card);
|
|
93
|
+
--wa-color-surface-raised: var(--card);
|
|
94
|
+
--wa-color-surface-lowered: var(--well);
|
|
95
|
+
--wa-color-surface-border: var(--edge);
|
|
96
|
+
--wa-color-text-normal: var(--ink);
|
|
97
|
+
--wa-color-text-quiet: var(--muted);
|
|
98
|
+
--wa-color-text-link: var(--ink);
|
|
99
|
+
--wa-color-overlay-modal: var(--scrim);
|
|
100
|
+
--wa-color-focus: var(--ink);
|
|
101
|
+
--wa-color-brand-fill-quiet: var(--card-hover);
|
|
102
|
+
--wa-color-brand-fill-normal: var(--well);
|
|
103
|
+
--wa-color-brand-fill-loud: var(--add);
|
|
104
|
+
--wa-color-brand-border-quiet: var(--line);
|
|
105
|
+
--wa-color-brand-border-normal: var(--edge);
|
|
106
|
+
--wa-color-brand-border-loud: var(--ink);
|
|
107
|
+
--wa-color-brand-on-quiet: var(--ink);
|
|
108
|
+
--wa-color-brand-on-normal: var(--ink);
|
|
109
|
+
--wa-color-brand-on-loud: var(--add-ink);
|
|
110
|
+
--wa-color-neutral-fill-quiet: var(--card-hover);
|
|
111
|
+
--wa-color-neutral-fill-normal: var(--well);
|
|
112
|
+
--wa-color-neutral-fill-loud: var(--ink);
|
|
113
|
+
--wa-color-neutral-border-quiet: var(--line);
|
|
114
|
+
--wa-color-neutral-border-normal: var(--edge);
|
|
115
|
+
--wa-color-neutral-border-loud: var(--control-edge);
|
|
116
|
+
--wa-color-neutral-on-quiet: var(--ink);
|
|
117
|
+
--wa-color-neutral-on-normal: var(--ink);
|
|
118
|
+
--wa-color-neutral-on-loud: var(--card);
|
|
119
|
+
--wa-color-danger-fill-quiet: color-mix(in srgb, var(--danger) 10%, var(--card));
|
|
120
|
+
--wa-color-danger-fill-normal: color-mix(in srgb, var(--danger) 20%, var(--card));
|
|
121
|
+
--wa-color-danger-fill-loud: var(--danger);
|
|
122
|
+
--wa-color-danger-border-quiet: color-mix(in srgb, var(--danger) 30%, var(--card));
|
|
123
|
+
--wa-color-danger-border-normal: var(--danger);
|
|
124
|
+
--wa-color-danger-border-loud: var(--danger);
|
|
125
|
+
--wa-color-danger-on-quiet: var(--danger);
|
|
126
|
+
--wa-color-danger-on-normal: var(--danger);
|
|
127
|
+
--wa-color-danger-on-loud: var(--danger-ink);
|
|
128
|
+
--wa-border-radius-s: var(--radius-inner);
|
|
129
|
+
--wa-border-radius-m: var(--radius);
|
|
130
|
+
--wa-border-radius-l: var(--radius-sheet);
|
|
131
|
+
--wa-panel-border-radius: var(--radius);
|
|
132
|
+
--wa-form-control-background-color: var(--card);
|
|
133
|
+
--wa-form-control-border-color: var(--control-edge);
|
|
134
|
+
--wa-form-control-border-radius: var(--radius);
|
|
135
|
+
--wa-form-control-activated-color: var(--ink);
|
|
136
|
+
--wa-form-control-label-color: var(--ink);
|
|
137
|
+
--wa-form-control-label-font-weight: 600;
|
|
138
|
+
--wa-form-control-value-color: var(--ink);
|
|
139
|
+
--wa-form-control-hint-color: var(--muted);
|
|
140
|
+
--wa-form-control-placeholder-color: var(--muted);
|
|
141
|
+
--wa-form-control-required-content: '';
|
|
142
|
+
--wa-tooltip-background-color: var(--ink);
|
|
143
|
+
--wa-tooltip-content-color: var(--card);
|
|
144
|
+
--wa-tooltip-border-radius: var(--radius);
|
|
68
145
|
}
|
|
69
146
|
@media (prefers-color-scheme: dark) {
|
|
70
147
|
:root {
|
package/src/tokens.json
CHANGED
|
@@ -400,6 +400,11 @@
|
|
|
400
400
|
"size": {
|
|
401
401
|
"note": "One breakpoint, 40rem (640px): above it the drawer docks at the right and the week stands beside the map; below it the drawer and a sheet rise from the foot and the week is a strip of its days. Under a finger (pointer: coarse) or below 40rem, a button and a field are 44px.",
|
|
402
402
|
"tokens": [
|
|
403
|
+
{
|
|
404
|
+
"name": "finger",
|
|
405
|
+
"value": "44px",
|
|
406
|
+
"usage": "The least a finger needs: a row, a tick, and a button or a field under a finger (pointer: coarse) or below 40rem."
|
|
407
|
+
},
|
|
403
408
|
{
|
|
404
409
|
"name": "touch",
|
|
405
410
|
"value": "32px",
|
|
@@ -425,6 +430,16 @@
|
|
|
425
430
|
"value": "22rem",
|
|
426
431
|
"usage": "A sheet's width at most, within the screen less 1rem a side."
|
|
427
432
|
},
|
|
433
|
+
{
|
|
434
|
+
"name": "list",
|
|
435
|
+
"value": "40rem",
|
|
436
|
+
"usage": "A list's width at most (a collection's rows, and the search at its head), in the middle of a wide page."
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"name": "said",
|
|
440
|
+
"value": "36rem",
|
|
441
|
+
"usage": "A toast's and the group's notice's width at most, as wide as their words, within the screen less 1rem a side."
|
|
442
|
+
},
|
|
428
443
|
{
|
|
429
444
|
"name": "pin",
|
|
430
445
|
"value": "16px",
|
|
@@ -439,6 +454,11 @@
|
|
|
439
454
|
"name": "grip",
|
|
440
455
|
"value": "7px",
|
|
441
456
|
"usage": "The foot of an event's block: dragged, it lasts longer or shorter, in 15-minute steps."
|
|
457
|
+
},
|
|
458
|
+
{
|
|
459
|
+
"name": "stripe",
|
|
460
|
+
"value": "3px",
|
|
461
|
+
"usage": "What's open, marked: a stripe of the accent at its row's start; a chip's or a block's stripe of its hue."
|
|
442
462
|
}
|
|
443
463
|
]
|
|
444
464
|
},
|
|
@@ -488,5 +508,234 @@
|
|
|
488
508
|
"usage": "A menu dropping a few pixels from its button as it fades in."
|
|
489
509
|
}
|
|
490
510
|
]
|
|
511
|
+
},
|
|
512
|
+
"wa": {
|
|
513
|
+
"note": "Web Awesome's tokens (--wa-), each set to joined's own, so its components (src/awesome.ts) draw in joined's colours, type and corners, light and dark as joined's tokens are. Its theme (themes/default.css) gives the rest: its scale of sizes and spaces.",
|
|
514
|
+
"tokens": [
|
|
515
|
+
{
|
|
516
|
+
"name": "font-family-body",
|
|
517
|
+
"value": "var(--sans)"
|
|
518
|
+
},
|
|
519
|
+
{
|
|
520
|
+
"name": "font-family-heading",
|
|
521
|
+
"value": "var(--sans)"
|
|
522
|
+
},
|
|
523
|
+
{
|
|
524
|
+
"name": "font-weight-action",
|
|
525
|
+
"value": "600"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
"name": "color-surface-default",
|
|
529
|
+
"value": "var(--card)"
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
"name": "color-surface-raised",
|
|
533
|
+
"value": "var(--card)"
|
|
534
|
+
},
|
|
535
|
+
{
|
|
536
|
+
"name": "color-surface-lowered",
|
|
537
|
+
"value": "var(--well)"
|
|
538
|
+
},
|
|
539
|
+
{
|
|
540
|
+
"name": "color-surface-border",
|
|
541
|
+
"value": "var(--edge)"
|
|
542
|
+
},
|
|
543
|
+
{
|
|
544
|
+
"name": "color-text-normal",
|
|
545
|
+
"value": "var(--ink)"
|
|
546
|
+
},
|
|
547
|
+
{
|
|
548
|
+
"name": "color-text-quiet",
|
|
549
|
+
"value": "var(--muted)"
|
|
550
|
+
},
|
|
551
|
+
{
|
|
552
|
+
"name": "color-text-link",
|
|
553
|
+
"value": "var(--ink)"
|
|
554
|
+
},
|
|
555
|
+
{
|
|
556
|
+
"name": "color-overlay-modal",
|
|
557
|
+
"value": "var(--scrim)"
|
|
558
|
+
},
|
|
559
|
+
{
|
|
560
|
+
"name": "color-focus",
|
|
561
|
+
"value": "var(--ink)"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
"name": "color-brand-fill-quiet",
|
|
565
|
+
"value": "var(--card-hover)"
|
|
566
|
+
},
|
|
567
|
+
{
|
|
568
|
+
"name": "color-brand-fill-normal",
|
|
569
|
+
"value": "var(--well)"
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
"name": "color-brand-fill-loud",
|
|
573
|
+
"value": "var(--add)"
|
|
574
|
+
},
|
|
575
|
+
{
|
|
576
|
+
"name": "color-brand-border-quiet",
|
|
577
|
+
"value": "var(--line)"
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
"name": "color-brand-border-normal",
|
|
581
|
+
"value": "var(--edge)"
|
|
582
|
+
},
|
|
583
|
+
{
|
|
584
|
+
"name": "color-brand-border-loud",
|
|
585
|
+
"value": "var(--ink)"
|
|
586
|
+
},
|
|
587
|
+
{
|
|
588
|
+
"name": "color-brand-on-quiet",
|
|
589
|
+
"value": "var(--ink)"
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
"name": "color-brand-on-normal",
|
|
593
|
+
"value": "var(--ink)"
|
|
594
|
+
},
|
|
595
|
+
{
|
|
596
|
+
"name": "color-brand-on-loud",
|
|
597
|
+
"value": "var(--add-ink)"
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
"name": "color-neutral-fill-quiet",
|
|
601
|
+
"value": "var(--card-hover)"
|
|
602
|
+
},
|
|
603
|
+
{
|
|
604
|
+
"name": "color-neutral-fill-normal",
|
|
605
|
+
"value": "var(--well)"
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
"name": "color-neutral-fill-loud",
|
|
609
|
+
"value": "var(--ink)"
|
|
610
|
+
},
|
|
611
|
+
{
|
|
612
|
+
"name": "color-neutral-border-quiet",
|
|
613
|
+
"value": "var(--line)"
|
|
614
|
+
},
|
|
615
|
+
{
|
|
616
|
+
"name": "color-neutral-border-normal",
|
|
617
|
+
"value": "var(--edge)"
|
|
618
|
+
},
|
|
619
|
+
{
|
|
620
|
+
"name": "color-neutral-border-loud",
|
|
621
|
+
"value": "var(--control-edge)"
|
|
622
|
+
},
|
|
623
|
+
{
|
|
624
|
+
"name": "color-neutral-on-quiet",
|
|
625
|
+
"value": "var(--ink)"
|
|
626
|
+
},
|
|
627
|
+
{
|
|
628
|
+
"name": "color-neutral-on-normal",
|
|
629
|
+
"value": "var(--ink)"
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
"name": "color-neutral-on-loud",
|
|
633
|
+
"value": "var(--card)"
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
"name": "color-danger-fill-quiet",
|
|
637
|
+
"value": "color-mix(in srgb, var(--danger) 10%, var(--card))"
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
"name": "color-danger-fill-normal",
|
|
641
|
+
"value": "color-mix(in srgb, var(--danger) 20%, var(--card))"
|
|
642
|
+
},
|
|
643
|
+
{
|
|
644
|
+
"name": "color-danger-fill-loud",
|
|
645
|
+
"value": "var(--danger)"
|
|
646
|
+
},
|
|
647
|
+
{
|
|
648
|
+
"name": "color-danger-border-quiet",
|
|
649
|
+
"value": "color-mix(in srgb, var(--danger) 30%, var(--card))"
|
|
650
|
+
},
|
|
651
|
+
{
|
|
652
|
+
"name": "color-danger-border-normal",
|
|
653
|
+
"value": "var(--danger)"
|
|
654
|
+
},
|
|
655
|
+
{
|
|
656
|
+
"name": "color-danger-border-loud",
|
|
657
|
+
"value": "var(--danger)"
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
"name": "color-danger-on-quiet",
|
|
661
|
+
"value": "var(--danger)"
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
"name": "color-danger-on-normal",
|
|
665
|
+
"value": "var(--danger)"
|
|
666
|
+
},
|
|
667
|
+
{
|
|
668
|
+
"name": "color-danger-on-loud",
|
|
669
|
+
"value": "var(--danger-ink)"
|
|
670
|
+
},
|
|
671
|
+
{
|
|
672
|
+
"name": "border-radius-s",
|
|
673
|
+
"value": "var(--radius-inner)"
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
"name": "border-radius-m",
|
|
677
|
+
"value": "var(--radius)"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
"name": "border-radius-l",
|
|
681
|
+
"value": "var(--radius-sheet)"
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
"name": "panel-border-radius",
|
|
685
|
+
"value": "var(--radius)"
|
|
686
|
+
},
|
|
687
|
+
{
|
|
688
|
+
"name": "form-control-background-color",
|
|
689
|
+
"value": "var(--card)"
|
|
690
|
+
},
|
|
691
|
+
{
|
|
692
|
+
"name": "form-control-border-color",
|
|
693
|
+
"value": "var(--control-edge)"
|
|
694
|
+
},
|
|
695
|
+
{
|
|
696
|
+
"name": "form-control-border-radius",
|
|
697
|
+
"value": "var(--radius)"
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
"name": "form-control-activated-color",
|
|
701
|
+
"value": "var(--ink)"
|
|
702
|
+
},
|
|
703
|
+
{
|
|
704
|
+
"name": "form-control-label-color",
|
|
705
|
+
"value": "var(--ink)"
|
|
706
|
+
},
|
|
707
|
+
{
|
|
708
|
+
"name": "form-control-label-font-weight",
|
|
709
|
+
"value": "600"
|
|
710
|
+
},
|
|
711
|
+
{
|
|
712
|
+
"name": "form-control-value-color",
|
|
713
|
+
"value": "var(--ink)"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
"name": "form-control-hint-color",
|
|
717
|
+
"value": "var(--muted)"
|
|
718
|
+
},
|
|
719
|
+
{
|
|
720
|
+
"name": "form-control-placeholder-color",
|
|
721
|
+
"value": "var(--muted)"
|
|
722
|
+
},
|
|
723
|
+
{
|
|
724
|
+
"name": "form-control-required-content",
|
|
725
|
+
"value": "''"
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"name": "tooltip-background-color",
|
|
729
|
+
"value": "var(--ink)"
|
|
730
|
+
},
|
|
731
|
+
{
|
|
732
|
+
"name": "tooltip-content-color",
|
|
733
|
+
"value": "var(--card)"
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
"name": "tooltip-border-radius",
|
|
737
|
+
"value": "var(--radius)"
|
|
738
|
+
}
|
|
739
|
+
]
|
|
491
740
|
}
|
|
492
741
|
}
|
package/src/tool.ts
ADDED
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// <j-tool> (joined/kit): a map's tool, chosen first and then tapped, as a pencil was. Put in a map (<j-plane>,
|
|
2
|
+
// <j-slots>), it draws nothing itself: the map draws its tools in a bar, one chosen of each kind, and a tap on the map
|
|
3
|
+
// makes the write the chosen ones say.
|
|
4
|
+
//
|
|
5
|
+
// <j-tool adds="crossings" finished="true">Finish</j-tool> an item added to that collection, for what's tapped
|
|
6
|
+
// <j-tool sets="material" value="amalgam">Amalgam</j-tool> that field of what's tapped written, or of a new one
|
|
7
|
+
// <j-tool sets="status" value="existing" default></j-tool> no button: what's set while none of its kind is chosen
|
|
8
|
+
// <j-tool for="conditions" sets="state" value="crown">Crown</j-tool> another collection's item written instead: the
|
|
9
|
+
// one the tapped place names that is this tool's (the tooth's crown), or a new one
|
|
10
|
+
// <j-tool clears>Clear</j-tool> what's tapped taken off: its charting, or (with a tool for another chosen) that item
|
|
11
|
+
//
|
|
12
|
+
// Any other attribute is a value the write gives, typed by its field (finished="true" a yes). What may be written is
|
|
13
|
+
// the stories': the server refuses in the story's words. Nothing is overwritten that isn't the tool's own: a tooth's
|
|
14
|
+
// crown and its root filling are two items. The bar ends with Undo: the map's last write put back, then the one before.
|
|
15
|
+
|
|
16
|
+
import { el } from "./fields.ts";
|
|
17
|
+
import { undo, type Answer } from "./page.ts";
|
|
18
|
+
import type { Reading } from "./reading.ts";
|
|
19
|
+
import type { Field, Item, Spec } from "./rows.ts";
|
|
20
|
+
import { send } from "./sheet.ts";
|
|
21
|
+
import { specOf } from "./specs.ts";
|
|
22
|
+
|
|
23
|
+
/** A collection given to the kit, once it is. */
|
|
24
|
+
const specNamed = (name: string) => new Promise<Spec>((ready) => specOf(name, ready));
|
|
25
|
+
|
|
26
|
+
/** A value said in an attribute, as its field has it: a number, a yes or no, or words. */
|
|
27
|
+
export const typed = (f: Field | undefined, raw: string): unknown =>
|
|
28
|
+
!f ? raw : f.type === "boolean" ? raw === "true" : f.type === "integer" || f.type === "decimal" ? Number(raw) : raw;
|
|
29
|
+
/** Values said in attributes, each as its field in a collection has it; those it hasn't, left out. */
|
|
30
|
+
const typedFor = (s: Spec, given: Record<string, string>) =>
|
|
31
|
+
Object.fromEntries(
|
|
32
|
+
Object.entries(given).flatMap(([k, v]) => {
|
|
33
|
+
const f = s.fields.find((f) => f.name === k);
|
|
34
|
+
return f ? [[k, typed(f, v)]] : [];
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
export class JTool extends HTMLElement {
|
|
39
|
+
connectedCallback() {
|
|
40
|
+
this.hidden = true;
|
|
41
|
+
}
|
|
42
|
+
get words() {
|
|
43
|
+
return this.textContent?.trim() ?? "";
|
|
44
|
+
}
|
|
45
|
+
/** The collection it adds to, if it adds. */
|
|
46
|
+
get adds() {
|
|
47
|
+
return this.getAttribute("adds") ?? "";
|
|
48
|
+
}
|
|
49
|
+
/** The field it writes, if it sets one. */
|
|
50
|
+
get sets() {
|
|
51
|
+
return this.getAttribute("sets") ?? "";
|
|
52
|
+
}
|
|
53
|
+
/** Another collection it writes in place of the map's own, if it does. */
|
|
54
|
+
get for() {
|
|
55
|
+
return this.getAttribute("for") ?? "";
|
|
56
|
+
}
|
|
57
|
+
/** Whether it's what's set while nothing of its kind is chosen, with no button. */
|
|
58
|
+
get default() {
|
|
59
|
+
return this.hasAttribute("default");
|
|
60
|
+
}
|
|
61
|
+
/** Whether it takes off what's tapped. */
|
|
62
|
+
get clears() {
|
|
63
|
+
return this.hasAttribute("clears");
|
|
64
|
+
}
|
|
65
|
+
/** Its kind: one tool of each is chosen at once (each field set, what's added, or a clearing). */
|
|
66
|
+
get kind() {
|
|
67
|
+
return this.clears ? "clears" : this.sets ? `sets:${this.sets}` : "adds";
|
|
68
|
+
}
|
|
69
|
+
/** The values its write gives, by field, as said: the field it sets, and every other attribute. */
|
|
70
|
+
get given(): Record<string, string> {
|
|
71
|
+
const out: Record<string, string> = {};
|
|
72
|
+
for (const a of this.attributes)
|
|
73
|
+
if (!["adds", "sets", "value", "hidden", "for", "default", "clears"].includes(a.name)) out[a.name] = a.value;
|
|
74
|
+
if (this.sets) out[this.sets] = this.getAttribute("value") ?? "";
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** A tap on a map with tools chosen: the writes they say, for the item tapped, or for a new one at `at` (a place on
|
|
80
|
+
* the water, a slot's fields). Nothing chosen, nothing done: the tap opens what's tapped instead. */
|
|
81
|
+
export async function applied(map: Reading, tools: Tools, it: Item | null, at: Record<string, unknown>) {
|
|
82
|
+
const chosen = tools.chosen,
|
|
83
|
+
own = map.spec!,
|
|
84
|
+
said = (why: Answer) => void (why && (map.line.textContent = `Refused: ${why}`)),
|
|
85
|
+
values = (s: Spec) => typedFor(s, Object.assign({}, ...chosen.filter((t) => t.sets).map((t) => t.given))),
|
|
86
|
+
clears = chosen.some((t) => t.clears);
|
|
87
|
+
if (!chosen.length) return false;
|
|
88
|
+
map.line.textContent = "";
|
|
89
|
+
// a tool for another collection: its item for the tapped place, by the place's fields and the tool's own value
|
|
90
|
+
const other = chosen.find((t) => t.for);
|
|
91
|
+
if (other) {
|
|
92
|
+
const s = await specNamed(other.for),
|
|
93
|
+
has = (k: string) => s.fields.some((f) => f.name === k),
|
|
94
|
+
named = {
|
|
95
|
+
...Object.fromEntries(Object.entries(at).filter(([k]) => has(k))),
|
|
96
|
+
...typedFor(s, { [other.sets]: other.getAttribute("value") ?? "" }),
|
|
97
|
+
},
|
|
98
|
+
item = [...(document.getElementsByTagName(s.tag) as HTMLCollectionOf<Item>)].find(
|
|
99
|
+
(x) => x.isConnected && Object.entries(named).every(([k, v]) => x.data[k] === v),
|
|
100
|
+
);
|
|
101
|
+
if (clears) said(item ? await tools.kept(item.removeItem!(), item) : undefined);
|
|
102
|
+
else if (item) said(await tools.kept(item.replace!(values(s))));
|
|
103
|
+
else
|
|
104
|
+
said(
|
|
105
|
+
await tools.kept(
|
|
106
|
+
send(document.querySelector(s.place)!, s.doc, [
|
|
107
|
+
{ op: "add", path: `/${s.name}/-`, value: { ...named, ...values(s) } },
|
|
108
|
+
]),
|
|
109
|
+
),
|
|
110
|
+
);
|
|
111
|
+
return true;
|
|
112
|
+
}
|
|
113
|
+
if (clears) {
|
|
114
|
+
if (it) said(await tools.kept(it.removeItem!(), it));
|
|
115
|
+
return true;
|
|
116
|
+
}
|
|
117
|
+
for (const t of chosen.filter((t) => t.adds)) {
|
|
118
|
+
if (t.adds === own.name) {
|
|
119
|
+
map.sheet?.show("new", at as Record<string, number>, typedFor(own, t.given));
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const s = await specNamed(t.adds),
|
|
123
|
+
link = s.fields.find((f) => f.to?.tag === own.tag);
|
|
124
|
+
if (it && link)
|
|
125
|
+
said(
|
|
126
|
+
await tools.kept(
|
|
127
|
+
send(document.querySelector(s.place)!, s.doc, [
|
|
128
|
+
{ op: "add", path: `/${s.name}/-`, value: { ...typedFor(s, t.given), [link.name]: it.key } },
|
|
129
|
+
]),
|
|
130
|
+
),
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
if (chosen.some((t) => t.sets)) {
|
|
134
|
+
if (it) said(await tools.kept(it.replace!(values(own))));
|
|
135
|
+
else
|
|
136
|
+
said(
|
|
137
|
+
await tools.kept(
|
|
138
|
+
send(document.querySelector(own.place)!, own.doc, [
|
|
139
|
+
{ op: "add", path: `/${own.name}/-`, value: { ...at, ...values(own) } },
|
|
140
|
+
]),
|
|
141
|
+
),
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** A map's tools: its <j-tool>s drawn as buttons in a bar, one chosen of each kind, the chosen one pressed again let
|
|
148
|
+
* go; and Undo, the map's writes put back, last first. What's chosen is the map's alone, read as a tap lands. */
|
|
149
|
+
export class Tools {
|
|
150
|
+
bar = el("div", { className: "tools", role: "toolbar" });
|
|
151
|
+
#host: Reading;
|
|
152
|
+
#chosen = new Map<string, JTool>();
|
|
153
|
+
/** The map's writes, each by its document and the version it made, last last. */
|
|
154
|
+
#made: { doc: string; version: number }[] = [];
|
|
155
|
+
/** The map's write not yet answered: Undo waits for it, so it never puts back the one before. */
|
|
156
|
+
#sending: Promise<unknown> = Promise.resolve();
|
|
157
|
+
|
|
158
|
+
constructor(host: Reading) {
|
|
159
|
+
this.#host = host;
|
|
160
|
+
}
|
|
161
|
+
get all() {
|
|
162
|
+
return [...this.#host.querySelectorAll<JTool>(":scope > j-tool")];
|
|
163
|
+
}
|
|
164
|
+
/** The tools chosen, one of each kind; once one is, each default of a kind none of whose tools is. */
|
|
165
|
+
get chosen() {
|
|
166
|
+
const pressed = [...this.#chosen.values()].filter((t) => t.isConnected);
|
|
167
|
+
if (!pressed.length) return [];
|
|
168
|
+
const kinds = new Set(pressed.map((t) => t.kind));
|
|
169
|
+
return [...pressed, ...this.all.filter((t) => t.default && !kinds.has(t.kind))];
|
|
170
|
+
}
|
|
171
|
+
/** A write of the map's, its version kept as it lands (its `landed`), so Undo can put it back. A removal is heard
|
|
172
|
+
* on what it removes, which has left the page by the time it's told, so its `landed` never reaches the document. */
|
|
173
|
+
async kept(request: Promise<Answer>, from: EventTarget = document) {
|
|
174
|
+
const landed = (e: Event) => this.#made.push((e as CustomEvent<{ doc: string; version: number }>).detail);
|
|
175
|
+
from.addEventListener("landed", landed);
|
|
176
|
+
this.#sending = request.catch(() => {});
|
|
177
|
+
try {
|
|
178
|
+
return await request;
|
|
179
|
+
} finally {
|
|
180
|
+
from.removeEventListener("landed", landed);
|
|
181
|
+
this.draw();
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
draw() {
|
|
185
|
+
const shown = this.all.filter((t) => !t.default);
|
|
186
|
+
this.bar.hidden = !shown.length;
|
|
187
|
+
const back = el("button", { type: "button", className: "act tool undo", textContent: "Undo" });
|
|
188
|
+
back.disabled = !this.#made.length;
|
|
189
|
+
back.addEventListener("click", async () => {
|
|
190
|
+
await this.#sending;
|
|
191
|
+
const last = this.#made.pop();
|
|
192
|
+
if (!last) return;
|
|
193
|
+
const { why } = await undo(last.doc, last.version);
|
|
194
|
+
this.#host.line.textContent = why ? `Refused: ${why}` : "";
|
|
195
|
+
this.draw();
|
|
196
|
+
});
|
|
197
|
+
this.bar.replaceChildren(
|
|
198
|
+
...shown.map((t) => {
|
|
199
|
+
const b = el("button", { type: "button", className: "act tool", textContent: t.words });
|
|
200
|
+
b.ariaPressed = String(this.#chosen.get(t.kind) === t);
|
|
201
|
+
b.addEventListener("click", () => {
|
|
202
|
+
if (this.#chosen.get(t.kind) === t) this.#chosen.delete(t.kind);
|
|
203
|
+
else this.#chosen.set(t.kind, t);
|
|
204
|
+
this.draw();
|
|
205
|
+
});
|
|
206
|
+
return b;
|
|
207
|
+
}),
|
|
208
|
+
back,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|