@cameronsjo/artificer 0.22.1 → 0.24.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/README.md +21 -11
- package/package.json +43 -8
- package/reference/SKILL.md +23 -9
- package/src/artificer-editorial.css +4 -4
- package/src/artificer-whimsy.js +47 -9
- package/src/artificer.css +407 -88
- package/src/primitives.json +134 -20
- package/src/tokens.json +4 -2
- package/types/focus.d.ts +17 -0
- package/types/icons.d.ts +23 -0
- package/types/options.d.ts +33 -0
- package/types/tabs.d.ts +26 -0
- package/types/theme.d.ts +28 -0
- package/types/tree.d.ts +31 -0
- package/types/whimsy.d.ts +47 -0
- package/src/assets/fonts/ia-writer-quattro-400-italic.woff2 +0 -0
- package/src/assets/fonts/ia-writer-quattro-400.woff2 +0 -0
- package/src/assets/fonts/ia-writer-quattro-700-italic.woff2 +0 -0
- package/src/assets/fonts/ia-writer-quattro-700.woff2 +0 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Artificer · Design System Handoff
|
|
2
2
|
|
|
3
3
|
Cameron's personal design system, packaged for use in real codebases.
|
|
4
|
-
**v0.
|
|
4
|
+
**v0.24.0 · 2026** — the chrome ships once: a compiled React adapter lands at `@cameronsjo/artificer/react` (ESM + `d.ts`, `react >=18` peer) with the whole app shell as components — `AppShell`, `Appbar`, `NavDrawer`, `SideNav` (flat or collapsible sections), `SideNavFooter`, and the canonical `ThemeToggle` — so consumers import the chrome instead of hand-assembling recipes that drift. Ambient TypeScript types ship for all seven vanilla behavior modules. `.app-shell` gains knobs (`--shell-rail`, `--shell-gap`) and `.sidenav--sticky` mints the pinned rail, replacing per-app grid overrides. Nav `href`s pass a scheme guard; the export pipeline rebuilds `dist/` from reviewed sources and hard-fails on missing package exports. See `CHANGELOG.md` for what changed.
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -221,16 +221,19 @@ These are starters, not the whole system. They cover the 80% case; for new patte
|
|
|
221
221
|
|
|
222
222
|
## Fonts
|
|
223
223
|
|
|
224
|
-
Artificer ships
|
|
224
|
+
Artificer ships three SIL OFL font faces (two typeface families), self-hosted as WOFF2 in `src/assets/fonts/`. **Pick the face by role** (see CLAUDE.md → "First decision — what surface is this?"):
|
|
225
225
|
|
|
226
226
|
- **JetBrains Mono** (weights 400 / 500 / 700) — body face on **tool surfaces** (dashboards, consoles, terminals, settings panels, data tables). Always used for code, identifiers, file paths, and numerals — even in document surfaces.
|
|
227
|
-
- **iA Writer Quattro**
|
|
227
|
+
- **iA Writer Quattro V** — `--font-body`, the prose face on **document surfaces** (writeups, READMEs, reports, design docs). Ships 400 only (plus italic), so bold headlines synthesize faux-bold.
|
|
228
|
+
- **iA Writer Quattro S** — `--font-interface`, the chrome face: labels, controls, badges, form fields, nav, tabular UI numerals — on **both** tool and document surfaces. Ships 400 / 700 with italics.
|
|
228
229
|
|
|
229
|
-
|
|
230
|
+
Both Quattro faces were designed by Bold Monday for iA Writer; humanist sans tuned to share rhythm with monospace. `--font-sans` remains resolvable as a legacy alias of `--font-body`.
|
|
230
231
|
|
|
231
|
-
|
|
232
|
+
A useful rule of thumb: if the page has more than ~3 paragraphs of running prose, it's a document — set body in Quattro V. If it's mostly chrome around data, it's a tool — set body in JetBrains Mono. Mixing within a project is normal: the settings page is a tool, the README explaining it is a document.
|
|
232
233
|
|
|
233
|
-
|
|
234
|
+
JetBrains Mono is on Google Fonts; Quattro is **not** — that's why we self-host. Each `@font-face` chain points at the bundled WOFF2 files and falls back through Iowan Old Style → Charter → Source Sans 3 → system-ui, so the page still renders if fonts haven't loaded yet.
|
|
235
|
+
|
|
236
|
+
Full loading recipes, the weight-coverage table, and the Windows faux-bold disposition: **[`FONTS.md`](FONTS.md)**. Upstream source for both Quattro faces is [iaolo/iA-Fonts](https://github.com/iaolo/iA-Fonts).
|
|
234
237
|
|
|
235
238
|
---
|
|
236
239
|
|
|
@@ -289,19 +292,26 @@ The CSS uses `color-scheme: dark` / `light` so form controls and scrollbars matc
|
|
|
289
292
|
## Editor & terminal themes
|
|
290
293
|
|
|
291
294
|
Artificer also ships as themes for the surfaces where Cameron actually
|
|
292
|
-
lives — same palette,
|
|
295
|
+
lives — same palette, every surface. The editors and agent CLIs:
|
|
293
296
|
|
|
294
297
|
- **Claude Code** — `themes/claude-code/artificer-{dark,light}.json`
|
|
295
|
-
- **Ghostty** — `themes/ghostty/artificer-{dark,light}`
|
|
296
298
|
- **VS Code / Cursor** — `themes/vscode/` (sideload or `vsce package`)
|
|
299
|
+
- **Helix** — `themes/helix/artificer-{dark,light}.toml` (+ `-opaque` twins)
|
|
300
|
+
- **Neovim** — `themes/neovim/colors/artificer.lua` (one file, both modes)
|
|
301
|
+
- **Codex CLI** — `themes/codex/artificer-{dark,light}.tmTheme`
|
|
297
302
|
- **Obsidian** — `themes/obsidian/Artificer/` (drop-in theme folder, hand-authored sister)
|
|
298
303
|
|
|
299
|
-
|
|
300
|
-
|
|
304
|
+
Plus the terminal and TUI surfaces around them — Ghostty, tmux, gitmux, cmux,
|
|
305
|
+
bat/delta, glamour, gum, fzf, eza, starship, yazi, lazygit, gh-dash, herdr, and
|
|
306
|
+
flux. **`themes/README.md` carries the full list**; it is the one place that
|
|
307
|
+
enumerates them, so this section never has to be counted again.
|
|
308
|
+
|
|
309
|
+
Everything except Obsidian is generated from `themes/_palette.json`. To re-tune
|
|
310
|
+
any color across every generated surface in lockstep:
|
|
301
311
|
|
|
302
312
|
```bash
|
|
303
313
|
# 1. Edit the hex in themes/_palette.json
|
|
304
|
-
# 2. Regenerate
|
|
314
|
+
# 2. Regenerate every generated surface:
|
|
305
315
|
node themes/build.mjs
|
|
306
316
|
# 3. Manually re-check obsidian/Artificer/theme.css (--art-* tokens at top)
|
|
307
317
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cameronsjo/artificer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "Cameron's personal design system — AuDHD-friendly, dark-first, for tools and dashboards. Apache-2.0 but Cameron-first: published for my own reuse, unsupported, no stability guarantees implied.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Cameron Sjo",
|
|
@@ -23,21 +23,56 @@
|
|
|
23
23
|
"./texture.css": "./src/artificer-texture.css",
|
|
24
24
|
"./editorial.css": "./src/artificer-editorial.css",
|
|
25
25
|
"./print.css": "./src/print.css",
|
|
26
|
-
"./theme.js":
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"./
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
"./theme.js": {
|
|
27
|
+
"types": "./types/theme.d.ts",
|
|
28
|
+
"default": "./src/artificer-theme.js"
|
|
29
|
+
},
|
|
30
|
+
"./focus.js": {
|
|
31
|
+
"types": "./types/focus.d.ts",
|
|
32
|
+
"default": "./src/artificer-focus.js"
|
|
33
|
+
},
|
|
34
|
+
"./tabs.js": {
|
|
35
|
+
"types": "./types/tabs.d.ts",
|
|
36
|
+
"default": "./src/artificer-tabs.js"
|
|
37
|
+
},
|
|
38
|
+
"./options.js": {
|
|
39
|
+
"types": "./types/options.d.ts",
|
|
40
|
+
"default": "./src/artificer-options.js"
|
|
41
|
+
},
|
|
42
|
+
"./tree.js": {
|
|
43
|
+
"types": "./types/tree.d.ts",
|
|
44
|
+
"default": "./src/artificer-tree.js"
|
|
45
|
+
},
|
|
46
|
+
"./icons.js": {
|
|
47
|
+
"types": "./types/icons.d.ts",
|
|
48
|
+
"default": "./src/artificer-icons.js"
|
|
49
|
+
},
|
|
50
|
+
"./whimsy.js": {
|
|
51
|
+
"types": "./types/whimsy.d.ts",
|
|
52
|
+
"default": "./src/artificer-whimsy.js"
|
|
53
|
+
},
|
|
54
|
+
"./react": {
|
|
55
|
+
"types": "./dist/react/index.d.ts",
|
|
56
|
+
"default": "./dist/react/index.js"
|
|
57
|
+
},
|
|
33
58
|
"./tokens.json": "./src/tokens.json",
|
|
34
59
|
"./package.json": "./package.json"
|
|
35
60
|
},
|
|
36
61
|
"files": [
|
|
37
62
|
"src",
|
|
38
63
|
"bin",
|
|
64
|
+
"types",
|
|
65
|
+
"dist",
|
|
39
66
|
"reference/SKILL.md"
|
|
40
67
|
],
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"react": ">=18"
|
|
70
|
+
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"react": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
41
76
|
"publishConfig": {
|
|
42
77
|
"access": "public"
|
|
43
78
|
},
|
package/reference/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: Artificer
|
|
|
3
3
|
description: Cameron's personal design system. AuDHD-optimized, Ghostty-rooted, dark-first with a paper-stock light mode and a Jazz Age Deco palette (burnished gold + royal purple). Use for tools, dashboards, agent UIs, terminals, settings panels — anything that must stay calm until something demands action. Do NOT use for marketing sites, kid-facing UI, or anywhere the goal is delight-via-stimulation.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Artificer · v0.
|
|
6
|
+
# Artificer · v0.24.0
|
|
7
7
|
|
|
8
8
|
A neurodivergent-first design system for Cameron. Every token and rule here exists to reduce cognitive load for an AuDHD brain that **scans instead of reads** and holds **3–4 items** in working memory.
|
|
9
9
|
|
|
@@ -92,13 +92,16 @@ If you have **no file system** (chat-only artifact), inline the contents of `art
|
|
|
92
92
|
| Top app bar | `app-shell.html` — `.appbar` + `__brand`/`__search`/`__actions`/`__menu-btn`/`__spacer`; sticky tool chrome, clears the notch via `safe-area-inset` |
|
|
93
93
|
| Side navigation | `app-shell.html` — `.sidenav` + `.sidenav__group` (+ `.label`/`.count` slots); the section spine, one level deep, `.tree` for deeper |
|
|
94
94
|
| Mobile nav drawer | `app-shell.html` — `.nav-drawer` + `.nav-scrim`; takes over below `--bp-tablet` |
|
|
95
|
+
| Collapsible drawer groups | `navigation.html` — `<details class="sidenav__section">` per group; `<summary>` = group label + twisty, rows keep sidenav styling; the section holding `[aria-current="page"]` must be rendered `open` (consumer JS) |
|
|
96
|
+
| Theme toggle in the drawer | `navigation.html` — `.sidenav__footer` bottom-anchored row: label + canonical `.theme-toggle--inline` `[data-theme-toggle]` button |
|
|
95
97
|
| Breadcrumb | `navigation.html` — `.crumb` + `.crumb__sep`; where-am-I, nav's first rung |
|
|
96
98
|
| Button | `.btn` + `--primary`/`--secondary`/`--ghost`/`--icon` — one primary per view — `components.html` |
|
|
97
99
|
| Dashboard with file/agent list | `patterns.html` sidebar + tabs + content pane |
|
|
98
100
|
| Add a settings page | `forms-extended.html` `.field` blocks + fieldsets, grouped 3–5 per section |
|
|
99
101
|
| Form field / form (any kind) | `forms-extended.html` — label → input → hint/error, never placeholder-as-label |
|
|
100
102
|
| Confirmation dialog / modal | `overlay.html` — `.scrim` + `.modal`, wire `ArtificerFocus.trap()` for focus-trap |
|
|
101
|
-
| Tooltip / popover | `overlay.html` — `.tooltip` (label) or `.popover` (body content) |
|
|
103
|
+
| Tooltip / popover | `overlay.html` — `.tooltip` (label) or `.popover` (body content). Reveal on hover + keyboard focus: wrap trigger + `.tooltip` in `.has-tooltip`; place/arrow via `.tooltip--top/bottom/left/right`. Bare `.tooltip` stays a static box |
|
|
104
|
+
| Horizontal bar / meter / usage bar | `charts.html` — `.bar` + `.bar__track` + `.bar__fill` (width inline; fill bg any semantic token; fill bakes `display:block;height:100%` so it never collapses). Determinate % → `.progress` |
|
|
102
105
|
| Page layout (sidebar/main) | `layout.html` — `.page-shell`, `.container` + `.container--{sm\|md\|lg}` (the base class is required — it carries width, centering, and inline padding; the size modifier only sets max-width) |
|
|
103
106
|
| Blog / editorial / document top nav / masthead | `.masthead` (`artificer-editorial.css`) — non-sticky, no border; document counterpart to `.appbar`. Brand via `.wordmark`, toggle via `.theme-toggle--inline` — `navigation.html` |
|
|
104
107
|
| Stacking children | `layout.html` — `.stack` (vertical), `.cluster` (horizontal wrap) |
|
|
@@ -114,11 +117,15 @@ If you have **no file system** (chat-only artifact), inline the contents of `art
|
|
|
114
117
|
| Toast / alert | `notifications.html` — pick tier by *action required*, not severity; silent by default — audible escalation only as a named, opt-in carve-out |
|
|
115
118
|
| Transient toast placement | Mount the `.notif` in a `.toast-region` (fixed corner stack on `--z-toast`, `+N more` via `.toast-region__more`); roles set at INSERT: urgent → `alert`, attention/info → `status`, background → none — `notifications.html` |
|
|
116
119
|
| Tree / file explorer / nested nav | `.tree` > `.tree__group` > `.tree__row` (+ `.tree__twisty`, `.tree__leaf`); `role=tree/treeitem/group`; keyboard ships via `data-tree` / `ArtificerTree.enhance()` — `components-extended.html` |
|
|
120
|
+
| HTML diagram node / flow / pipeline | `.dia-box` (HTML twin of `.dia-node`; `--accent`/`--ghost`/`--tab`) + `.flow`/`.flow__step`/`.flow__link`/`.flow-frame` for horizontal step-chains — `diagrams.html` |
|
|
121
|
+
| Phased timeline / numbered grouped stages | `.spine` + `.phase` (`.phase__marker` + `.phase__body` `.stack` of `.dia-box`) + `.phase--accent` — vertical numbered timeline where each step is a set — `diagrams.html` |
|
|
122
|
+
| Static / no-JS tree (SSR, docs) | `.tree--static` — nested `<details><summary class="tree__row">`; disclosure semantics, no JS — `components-extended.html` |
|
|
117
123
|
| Pagination | `.pagination` + `.pagination__gap`; `[aria-current=page]` marks the page; prev/next disable at ends; counted ranges only — `components-extended.html` |
|
|
118
124
|
| Persistent page banner | `.banner` + `--info/attention/urgent/success` + `.banner__body`/`.banner__actions` — a standing layout band, NOT the transient `.notif` — `components-extended.html` |
|
|
119
|
-
| Footer / colophon / fine print / attribution | `.
|
|
125
|
+
| Footer / colophon / fine print / attribution | **Three zones, in order — 1 and 3 optional, the spine always present.** (1) a `.grid-auto` of `.colophon__label` sections; (2) `.colophon__spine` — three POSITIONAL slots: **identity · sign-off · links**, first child starts, last ends, middle centres on the page; (3) `.colophon__fine` for the legal tier. A site with only a sign-off and a site with a full disclosure grid use the same primitive and differ only in which zones they fill. Any slot may be empty — keep the element to hold its column. Links slot: `<a>` for navigation, `<button class="btn btn--link">` for a control that ACTS (an SPA switching views) — never an `<a>` with a click handler. Prose auto-sans even inside `.surface-tool`; `.surface-document` flips any other prose island back — `layout.html` |
|
|
120
126
|
| Selected card / selected row / active choice | `.card--active` (`background: var(--bg)` + accent left border) for a card, `.is-active` (`background: var(--bg-raised)`) for a list row — never `--accent-fill` as a large surface bg, its only rated text color is `--on-accent` — `components.html` |
|
|
121
127
|
| Split pane / master-detail | `.split-pane` + `.pane--active`/`.pane--inactive`; recession marks the unfocused pane — `composition.html` |
|
|
128
|
+
| Text workbench / editor panes / paste target | `.workbench` + `.workbench__pane` (`.workbench__header` + `.workbench__editor`); label lives in `.workbench__header` as a real `<label for>`, not a placeholder — a `.dash` BODY, not a sixth dash recipe — `composition.html` |
|
|
122
129
|
| Status pill | `.badge--{tier}` with a `.dot--{tier}` inside — dot AND text, never color alone |
|
|
123
130
|
| Status indicator (bare, no count) | `.dot--{accent\|attention\|urgent\|success}` |
|
|
124
131
|
| Count indicator | `.badge--{accent\|attention\|urgent\|success}` with number |
|
|
@@ -155,10 +162,11 @@ If you have **no file system** (chat-only artifact), inline the contents of `art
|
|
|
155
162
|
|
|
156
163
|
### SPA lifecycle (icons / whimsy / theme + modal re-trap)
|
|
157
164
|
|
|
158
|
-
Icons and
|
|
159
|
-
`[data-icon]` / `[data-theme-toggle]`
|
|
160
|
-
|
|
161
|
-
|
|
165
|
+
Icons, theme, and whimsy arm their own `MutationObserver` on DOM ready —
|
|
166
|
+
SPA-mounted `[data-icon]` / `[data-theme-toggle]` / `[data-whimsy]` /
|
|
167
|
+
`[data-whimsy-greeting]`
|
|
168
|
+
nodes hydrate and bind automatically. Tabs, options, and tree enhance on
|
|
169
|
+
explicit calls. For nodes that mount after first paint in those modules,
|
|
162
170
|
use the lifecycle API:
|
|
163
171
|
|
|
164
172
|
- **`ArtificerIcons.observe(root?)` / `Whimsy.observe(root?)` /
|
|
@@ -244,10 +252,13 @@ TYPE --font-mono JetBrains Mono
|
|
|
244
252
|
terminals, data tables, settings panels)
|
|
245
253
|
· ALWAYS for code, identifiers, file paths,
|
|
246
254
|
numerals — including inside documents
|
|
247
|
-
--font-
|
|
255
|
+
--font-body iA Writer Quattro V
|
|
248
256
|
· BODY FACE for document surfaces (writeups,
|
|
249
257
|
READMEs, reports, design docs)
|
|
250
|
-
|
|
258
|
+
--font-interface iA Writer Quattro S
|
|
259
|
+
· Labels, controls, badges, form fields, nav
|
|
260
|
+
— on both tool AND document surfaces
|
|
261
|
+
· --font-sans is a legacy alias of --font-body
|
|
251
262
|
|
|
252
263
|
Decision rule. >3 paragraphs of running prose → document → sans body.
|
|
253
264
|
Mostly chrome around data → tool → mono body. Same project can mix.
|
|
@@ -377,6 +388,9 @@ there is no `.dash-*` class):
|
|
|
377
388
|
### Diagrams — non-negotiable
|
|
378
389
|
|
|
379
390
|
- **`.dia-node` + `.dia-edge` + `.dia-edge-label`** — apply directly to inline SVG `<rect>`/`<path>`/`<text>`.
|
|
391
|
+
- **`.dia-box`** — HTML/CSS twin of `.dia-node` for DOM diagrams (React Flow, hand-laid flows); same `--dia-*` tokens. Variants `--accent` / `--ghost` / `--tab` (tint via `style="--dia-tab: var(--series-3)"`, any series token).
|
|
392
|
+
- **`.flow`** — horizontal step-chain: `.flow__step` (a `.dia-box`) + `.flow__link` connector (`--dashed` = async/return) + `.flow-frame` (dashed, labeled phase group). Vertical numbered grouped-step timeline = `.spine`/`.phase`.
|
|
393
|
+
- **`.spine`** — vertical numbered timeline where each `.phase` holds a GROUP of nodes: `.phase__marker` (numbered badge) + `.phase__body` (a `.stack` of `.dia-box`). `.phase--accent` marks the pivotal station (one per timeline).
|
|
380
394
|
- **1 accent node per diagram** (`.dia-node--accent`) — the diagram's subject.
|
|
381
395
|
- **Ghost = planned** (`.dia-node--ghost`, dashed border).
|
|
382
396
|
- **Edge stroke encodes resolution:** default = step, `--strong` = closes the flow, `--dashed` = async/return.
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
rhythm. Wrap a long-form page in <body class="surface-editorial"> (or any
|
|
23
23
|
container). It is the inverse of .surface-tool — never combine the two. */
|
|
24
24
|
.surface-editorial {
|
|
25
|
-
font-family: var(--font-
|
|
25
|
+
font-family: var(--font-body);
|
|
26
26
|
color: var(--fg);
|
|
27
27
|
line-height: var(--t-body-lg-lh);
|
|
28
28
|
}
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
display: flex; align-items: center; flex-wrap: wrap;
|
|
40
40
|
gap: var(--s-md) var(--s-lg);
|
|
41
41
|
padding: var(--s-lg) 0;
|
|
42
|
-
font-family: var(--font-
|
|
42
|
+
font-family: var(--font-body);
|
|
43
43
|
}
|
|
44
44
|
.masthead__brand { margin-right: auto; } /* pushes nav + meta to the right */
|
|
45
45
|
.masthead__nav {
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
margin-bottom: var(--s-md);
|
|
113
113
|
}
|
|
114
114
|
.editorial-hero__title {
|
|
115
|
-
font-family: var(--font-
|
|
115
|
+
font-family: var(--font-body); font-weight: 700;
|
|
116
116
|
font-size: var(--t-headline-lg-size);
|
|
117
117
|
line-height: var(--t-headline-lg-lh);
|
|
118
118
|
letter-spacing: var(--t-headline-lg-ls);
|
|
@@ -130,7 +130,7 @@
|
|
|
130
130
|
.entries { display: flex; flex-direction: column; gap: var(--s-2xl); max-width: var(--editorial-measure); }
|
|
131
131
|
.entry { display: flex; flex-direction: column; gap: var(--s-sm); }
|
|
132
132
|
.entry__title {
|
|
133
|
-
font-family: var(--font-
|
|
133
|
+
font-family: var(--font-body); font-weight: 700;
|
|
134
134
|
font-size: var(--t-headline-md-size); line-height: var(--t-headline-md-lh);
|
|
135
135
|
color: var(--fg); margin: 0; text-decoration: none;
|
|
136
136
|
}
|
package/src/artificer-whimsy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
-
ARTIFICER · Whimsy helper · v0.
|
|
2
|
+
ARTIFICER · Whimsy helper · v0.24.0
|
|
3
3
|
─────────────────────────────────────────────────────────────────────────
|
|
4
4
|
Tiny, dependency-free. Pairs with artificer-whimsy.css. Exposes window.Whimsy.
|
|
5
5
|
|
|
@@ -47,7 +47,14 @@
|
|
|
47
47
|
(function () {
|
|
48
48
|
"use strict";
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
// igniteEl is the opposite of clearEl (below) — un-clearing lets a fresh
|
|
51
|
+
// celebrate()/run()/ignite() re-light an element the caller previously
|
|
52
|
+
// turned off on purpose.
|
|
53
|
+
function igniteEl(el) {
|
|
54
|
+
if (!el) return;
|
|
55
|
+
delete el.dataset.whimsyCleared;
|
|
56
|
+
el.classList.add("whimsy");
|
|
57
|
+
}
|
|
51
58
|
|
|
52
59
|
/* ── Dissolve bookkeeping ── el → in-flight { t1, t2 } timers ──────────────
|
|
53
60
|
One entry per element currently mid-exit. cancelDissolve() is the single
|
|
@@ -71,10 +78,17 @@
|
|
|
71
78
|
el.style.removeProperty("--whimsy-dissolve-fade");
|
|
72
79
|
}
|
|
73
80
|
|
|
81
|
+
// Marks the element so the now-permanent observe() (autoInit, #325) can't
|
|
82
|
+
// re-light it: hydrate() skips a data-whimsy node flagged whimsyCleared,
|
|
83
|
+
// making a manual clear/dissolve durable across later DOM mutations
|
|
84
|
+
// instead of just the one hydrate pass a one-shot DOMContentLoaded used to
|
|
85
|
+
// guarantee. igniteEl() clears the flag so a fresh celebrate/run/ignite
|
|
86
|
+
// can still re-light it on purpose.
|
|
74
87
|
function clearEl(el) {
|
|
75
88
|
if (!el) return;
|
|
76
89
|
cancelDissolve(el);
|
|
77
90
|
el.classList.remove("whimsy");
|
|
91
|
+
el.dataset.whimsyCleared = "1";
|
|
78
92
|
}
|
|
79
93
|
|
|
80
94
|
/* ── Settle ── flow for N hue-cycles, then come to rest ────────────────── */
|
|
@@ -139,12 +153,18 @@
|
|
|
139
153
|
root = root || document;
|
|
140
154
|
var waves = root.querySelectorAll('[data-whimsy~="wave"]');
|
|
141
155
|
for (var i = 0; i < waves.length; i++) {
|
|
156
|
+
// A whimsyCleared node was deliberately turned off (clearEl) — the
|
|
157
|
+
// permanent observer must not re-light it on the next mutation.
|
|
158
|
+
if (waves[i].dataset.whimsyCleared === "1") continue;
|
|
142
159
|
waves[i].classList.add("whimsy", "whimsy--wave");
|
|
143
160
|
splitWave(waves[i]);
|
|
144
161
|
}
|
|
145
162
|
// plain [data-whimsy] (no "wave") just gets the flowing gradient
|
|
146
163
|
var plain = root.querySelectorAll('[data-whimsy=""], [data-whimsy="whimsy"]');
|
|
147
|
-
for (var j = 0; j < plain.length; j++)
|
|
164
|
+
for (var j = 0; j < plain.length; j++) {
|
|
165
|
+
if (plain[j].dataset.whimsyCleared === "1") continue;
|
|
166
|
+
plain[j].classList.add("whimsy");
|
|
167
|
+
}
|
|
148
168
|
}
|
|
149
169
|
|
|
150
170
|
/* The "ultrathink" gesture. Watch a text input; when its value contains any
|
|
@@ -297,6 +317,15 @@
|
|
|
297
317
|
|
|
298
318
|
/* ── Seasonal greeting ── pure spec + DOM application ──────────────────── */
|
|
299
319
|
|
|
320
|
+
// Off-season class token must be a single "whimsy--<word>" class — the
|
|
321
|
+
// observer now re-scans on every DOM mutation (#325), so this validates an
|
|
322
|
+
// attacker-controlled `data-whimsy-greeting-class` on any later-inserted
|
|
323
|
+
// node before it reaches classList.add(). An invalid token (whitespace,
|
|
324
|
+
// wrong prefix) falls back to the default rather than throwing
|
|
325
|
+
// InvalidCharacterError mid-observer-batch, which would otherwise abort
|
|
326
|
+
// hydration for every other node in that batch.
|
|
327
|
+
var WHIMSY_CLASS_RE = /^whimsy--[a-z0-9-]+$/;
|
|
328
|
+
|
|
300
329
|
/* PURE — no DOM. Given a date, return the footer-greeting spec for its
|
|
301
330
|
season. June (getMonth() === 5) is Pride: "happy pride" (no trailing
|
|
302
331
|
period — explicit) with always-on vivid flow — intentionally the one view
|
|
@@ -324,9 +353,12 @@
|
|
|
324
353
|
// drift: "kindness is a choice" (default) or "abide no hatred".
|
|
325
354
|
// (Future idea: rotate one per day/month via a modulus on the date; for
|
|
326
355
|
// now it's a deliberately stable per-surface choice, not a slot machine.)
|
|
356
|
+
var defaultClass = WHIMSY_CLASS_RE.test(opts.defaultClass || "")
|
|
357
|
+
? opts.defaultClass
|
|
358
|
+
: "whimsy--glacial";
|
|
327
359
|
return { season: "default",
|
|
328
360
|
text: opts.default || "kindness is a choice",
|
|
329
|
-
classes: ["whimsy",
|
|
361
|
+
classes: ["whimsy", defaultClass] };
|
|
330
362
|
}
|
|
331
363
|
|
|
332
364
|
/* DOM — scan [data-whimsy-greeting]; the element's inline text IS the
|
|
@@ -395,14 +427,20 @@
|
|
|
395
427
|
if (typeof window !== "undefined") window.Whimsy = api;
|
|
396
428
|
else if (typeof globalThis !== "undefined") globalThis.Whimsy = api;
|
|
397
429
|
|
|
430
|
+
// Arms observe() on ready so SPA-mounted [data-whimsy] / [data-whimsy-greeting]
|
|
431
|
+
// nodes hydrate without a manual call (matches the icons/theme autoInit
|
|
432
|
+
// shape — src/artificer-icons.js:231). Declared at IIFE scope, not inside
|
|
433
|
+
// the guard below, so a strict-mode ES5 parser never sees a block-scoped
|
|
434
|
+
// function declaration. observe() itself falls back to a single
|
|
435
|
+
// hydrate()+greeting() pass when MutationObserver is unavailable, so no
|
|
436
|
+
// separate branch is needed here.
|
|
437
|
+
function autoInit() { observe(document.body); }
|
|
438
|
+
|
|
398
439
|
// DOM auto-run — guarded so `import`ing the module in Node (the unit test)
|
|
399
440
|
// doesn't touch a document that isn't there.
|
|
400
441
|
if (typeof document !== "undefined") {
|
|
401
442
|
if (document.readyState === "loading") {
|
|
402
|
-
document.addEventListener("DOMContentLoaded",
|
|
403
|
-
} else {
|
|
404
|
-
hydrate();
|
|
405
|
-
greeting();
|
|
406
|
-
}
|
|
443
|
+
document.addEventListener("DOMContentLoaded", autoInit);
|
|
444
|
+
} else { autoInit(); }
|
|
407
445
|
}
|
|
408
446
|
})();
|