@cameronsjo/artificer 0.12.0 → 0.18.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 +47 -4
- package/package.json +5 -2
- package/src/artificer-icons.js +4 -1
- package/src/artificer-options.js +353 -0
- package/src/artificer-texture.css +153 -0
- package/src/artificer-theme.js +4 -1
- package/src/artificer-tree.js +227 -0
- package/src/artificer-whimsy.css +82 -0
- package/src/artificer-whimsy.js +88 -7
- package/src/artificer.css +506 -46
- package/src/assets/favicon.svg +4 -8
- package/src/assets/og-image.svg +19 -20
- package/src/print.css +1 -1
- package/src/tokens.json +4 -2
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.18.0 · 2026** — the re-true: the root is never overridden (`html { font-size: 100% }`), so every `--t-*-size` token now renders at its labeled px and the whole system scales with the browser font-size preference (#211, owner-ruled). Token-bound type grows ~14.3% — body copy lands at a true 14px (it had double-applied to 12.25px); the owner optical pass is #214. The px-literal chrome rebinds to exact-match tokens as identity swaps, the `lint:tokens` font-size watch arms, the `.toast` ghost leaves print.css, and app-shell lands on canonical `.section-title`. See `CHANGELOG.md` for what changed.
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -19,7 +19,7 @@ A complete, self-contained design system you can drop into any project. Five fil
|
|
|
19
19
|
|
|
20
20
|
Plus `src/print.css` (paper-mode for PDF/print) and two SVG assets (favicon, OG card).
|
|
21
21
|
|
|
22
|
-
The optional **Whimsy** layer (`src/artificer-whimsy.css` + `src/artificer-whimsy.js`) is the *one sanctioned exception* to the no-looping-decoration / no-raw-color rules — a flowing burnished rainbow on text, for **user-defined fun elements** and whimsical operations only. Opt-in; load it after `artificer.css`. Full doctrine in `CLAUDE.md` § Whimsy; interactive reference + playground at `live-spec/whimsy.html`.
|
|
22
|
+
The optional **Whimsy** layer (`src/artificer-whimsy.css` + `src/artificer-whimsy.js`) is the *one sanctioned exception* to the no-looping-decoration / no-raw-color rules — a flowing burnished rainbow on text, for **user-defined fun elements** and whimsical operations only. Opt-in; load it after `artificer.css`. It also ships `Whimsy.greeting()` — a seasonal footer line (`<span data-whimsy-greeting>`) that lights up for Pride every June. Full doctrine in `CLAUDE.md` § Whimsy; interactive reference + playground at `live-spec/whimsy.html`.
|
|
23
23
|
|
|
24
24
|
The full live spec for every component lives at the project URL (the HTML pages — `colors.html`, `typography.html`, `components.html`, etc). This bundle ships the source; visit the live system for the visual reference.
|
|
25
25
|
|
|
@@ -72,14 +72,29 @@ cp -r src/ packages/artificer/
|
|
|
72
72
|
|
|
73
73
|
```ts
|
|
74
74
|
// In your app entry (e.g. src/main.ts, app/layout.tsx)
|
|
75
|
-
import 'artificer/artificer.css'
|
|
75
|
+
import 'artificer/artificer.css' // tokens + .tabs .appbar .crumb .sidenav .split-pane …
|
|
76
76
|
import 'artificer/artificer-theme.js'
|
|
77
77
|
import 'artificer/artificer-focus.js' // only if using modals
|
|
78
78
|
import 'artificer/artificer-icons.js' // only if using <i data-icon>
|
|
79
|
+
import 'artificer/artificer-tabs.js' // only if using .tabs (ships the APG keyboard model)
|
|
80
|
+
import 'artificer/artificer-options.js' // only if using .menu/.listbox/.palette (option navigation)
|
|
81
|
+
import 'artificer/artificer-tree.js' // only if using .tree (ships the APG tree keyboard)
|
|
79
82
|
```
|
|
80
83
|
|
|
81
84
|
The CSS uses CSS custom properties (variables) and `data-theme` attribute — no preprocessing needed.
|
|
82
85
|
|
|
86
|
+
**Nav primitives.** `.tabs`, `.appbar`, `.crumb`, `.sidenav`, and `.split-pane` ship in `artificer.css`. The `.tabs` CSS is style-only — load `artificer-tabs.js` for the WAI-ARIA keyboard behavior (roving tabindex, arrows, Home/End). Full reference: `live-spec/navigation.html`.
|
|
87
|
+
|
|
88
|
+
```html
|
|
89
|
+
<div class="tabs" data-tabs role="tablist">
|
|
90
|
+
<button class="tabs__tab" role="tab" aria-controls="p1">Overview</button>
|
|
91
|
+
<!-- … -->
|
|
92
|
+
</div>
|
|
93
|
+
```
|
|
94
|
+
```ts
|
|
95
|
+
ArtificerTabs.observe(document) // wires APG keyboard for every [data-tabs]
|
|
96
|
+
```
|
|
97
|
+
|
|
83
98
|
### Path C · Tailwind / utility-first
|
|
84
99
|
|
|
85
100
|
The CSS already provides utility classes for layout (`.stack`, `.cluster`, `.grid-auto`, `.container`). For Tailwind shops, see `framework-adapters/tailwind.config.js` — it imports `tokens.json` so your Tailwind utilities use Artificer values.
|
|
@@ -175,7 +190,7 @@ You don't need to reinvent any of this. Just don't undo it.
|
|
|
175
190
|
- Selection color (`::selection`) themed
|
|
176
191
|
- Scrollbar styled to match (Webkit + Firefox)
|
|
177
192
|
|
|
178
|
-
The `
|
|
193
|
+
The `live-spec/a11y.html` page (in the live system) has the 12-point shipping checklist.
|
|
179
194
|
|
|
180
195
|
---
|
|
181
196
|
|
|
@@ -241,6 +256,34 @@ See `themes/README.md` for install instructions per surface.
|
|
|
241
256
|
|
|
242
257
|
---
|
|
243
258
|
|
|
259
|
+
## Quality gates — two test lanes
|
|
260
|
+
|
|
261
|
+
Maintainer-facing. Both run in CI on every PR; consumers never need either.
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
# Lane 1 · data gates — zero dependencies, instant
|
|
265
|
+
npm test # unit tests (node --test scripts/*.test.mjs)
|
|
266
|
+
npm run check:contrast # WCAG floors on $roles.syntax
|
|
267
|
+
npm run lint:palette # every CSS hex is a palette value
|
|
268
|
+
npm run check:version # all version stamps agree
|
|
269
|
+
npm run check:livespec # src/ <-> live-spec/ mirror parity
|
|
270
|
+
|
|
271
|
+
# Lane 2 · browser trust layer — Playwright (devDependencies only)
|
|
272
|
+
npm install # once; then:
|
|
273
|
+
npx playwright install chromium webkit # once; downloads engines
|
|
274
|
+
npm run test:browser # behavioral assertions on live-spec/
|
|
275
|
+
npm run test:browser:headed # watch it run
|
|
276
|
+
npm run test:browser:ui # interactive debugging
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
The browser lane loads `live-spec/` pages in **Chromium** (Chrome class) and
|
|
280
|
+
**WebKit as iPhone 13** (Safari class — on iOS every browser is WebKit) and
|
|
281
|
+
asserts behavior: no horizontal overflow, touch-target floors, a11y, keyboard
|
|
282
|
+
patterns. The data gates check what the system *says*; the browser lane checks
|
|
283
|
+
what it *does*.
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
244
287
|
## Where to ask
|
|
245
288
|
|
|
246
289
|
- **Live system** — every page is a live spec. Read first, then code.
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cameronsjo/artificer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.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
|
-
"author": "Cameron Sjo
|
|
6
|
+
"author": "Cameron Sjo",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/cameronsjo/artificer.git"
|
|
@@ -16,11 +16,14 @@
|
|
|
16
16
|
"exports": {
|
|
17
17
|
"./artificer.css": "./src/artificer.css",
|
|
18
18
|
"./whimsy.css": "./src/artificer-whimsy.css",
|
|
19
|
+
"./texture.css": "./src/artificer-texture.css",
|
|
19
20
|
"./editorial.css": "./src/artificer-editorial.css",
|
|
20
21
|
"./print.css": "./src/print.css",
|
|
21
22
|
"./theme.js": "./src/artificer-theme.js",
|
|
22
23
|
"./focus.js": "./src/artificer-focus.js",
|
|
23
24
|
"./tabs.js": "./src/artificer-tabs.js",
|
|
25
|
+
"./options.js": "./src/artificer-options.js",
|
|
26
|
+
"./tree.js": "./src/artificer-tree.js",
|
|
24
27
|
"./icons.js": "./src/artificer-icons.js",
|
|
25
28
|
"./whimsy.js": "./src/artificer-whimsy.js",
|
|
26
29
|
"./tokens.json": "./src/tokens.json",
|
package/src/artificer-icons.js
CHANGED
|
@@ -117,6 +117,9 @@
|
|
|
117
117
|
root = root || document.body;
|
|
118
118
|
hydrate(root);
|
|
119
119
|
if (typeof MutationObserver === 'undefined') return function () {};
|
|
120
|
+
var schedule = window.requestAnimationFrame
|
|
121
|
+
? function (cb) { window.requestAnimationFrame(cb); }
|
|
122
|
+
: function (cb) { window.setTimeout(cb, 0); };
|
|
120
123
|
var scheduled = false;
|
|
121
124
|
var mo = new MutationObserver(function (mutations) {
|
|
122
125
|
// Clear the hydration lock on any node whose icon attrs changed so
|
|
@@ -128,7 +131,7 @@
|
|
|
128
131
|
});
|
|
129
132
|
if (scheduled) return;
|
|
130
133
|
scheduled = true;
|
|
131
|
-
(
|
|
134
|
+
schedule(function () { scheduled = false; hydrate(root); });
|
|
132
135
|
});
|
|
133
136
|
mo.observe(root, {
|
|
134
137
|
childList: true,
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/* Artificer · option-navigation core (WAI-ARIA APG listbox/menu patterns).
|
|
2
|
+
The option-popover primitive (.menu / .listbox) ships the LOOK; this ships
|
|
3
|
+
the unavoidable-JS BEHAVIOR for BOTH of its keyboard models — the same way
|
|
4
|
+
artificer-tabs.js ships the tabs pattern (#92 precedent):
|
|
5
|
+
|
|
6
|
+
enhance(el) roving-tabindex mode — a standalone role="listbox"
|
|
7
|
+
or role="menu": arrows move focus, Home/End,
|
|
8
|
+
type-to-select, Enter/Space selects.
|
|
9
|
+
combobox(input, list) activedescendant mode — a combobox input driving a
|
|
10
|
+
listbox popup (the command-palette recipe): focus
|
|
11
|
+
stays PINNED to the input; arrows move .is-active +
|
|
12
|
+
aria-activedescendant over the VISIBLE options.
|
|
13
|
+
|
|
14
|
+
Usage:
|
|
15
|
+
<ul class="listbox" role="listbox" data-options>…</ul> → observe()
|
|
16
|
+
<div class="menu" role="menu" data-options>…</div> → observe()
|
|
17
|
+
<input data-combobox="listId"> → observe()
|
|
18
|
+
ArtificerOptions.enhance(el, { onSelect(opt, i){…}, wrap });
|
|
19
|
+
ArtificerOptions.combobox(input, list, { onSelect(opt, i){…} });
|
|
20
|
+
ArtificerOptions.observe(document); // auto-enhance (SPA lifecycle)
|
|
21
|
+
|
|
22
|
+
Scope — keyboard/ARIA mechanics ONLY (deliberate hard line):
|
|
23
|
+
· printable keys are never consumed in combobox mode (typing is the
|
|
24
|
+
consumer's filter; type-to-select lives only in roving mode)
|
|
25
|
+
· Escape is never handled (ArtificerFocus.trap owns it)
|
|
26
|
+
· open/close, filtering, and dispatch stay consumer-side; the filtering
|
|
27
|
+
contract is: hide filtered-out options with [hidden], then refresh()
|
|
28
|
+
· aria-disabled options stay FOCUSABLE/navigable but select() no-ops
|
|
29
|
+
(the APG-correct half of disabled options — never skipped, never inert
|
|
30
|
+
to the cursor)
|
|
31
|
+
|
|
32
|
+
Movement clamps by default (APG listbox never wraps); menus wrap (APG menu).
|
|
33
|
+
enhance()/combobox() are idempotent and return cached handles. */
|
|
34
|
+
(function () {
|
|
35
|
+
'use strict';
|
|
36
|
+
|
|
37
|
+
// --- pure: the cursor state machine (unit-tested, no DOM) ------------------
|
|
38
|
+
// Returns the index the cursor should move to for `key`, or null if the key
|
|
39
|
+
// isn't an option-navigation key (caller does nothing, no preventDefault).
|
|
40
|
+
// opts.wrap default false = clamp (APG listbox); menus pass wrap: true.
|
|
41
|
+
function nextOption(key, current, count, opts) {
|
|
42
|
+
if (!(count > 0)) return null;
|
|
43
|
+
var wrap = !!(opts && opts.wrap);
|
|
44
|
+
switch (key) {
|
|
45
|
+
case 'ArrowDown':
|
|
46
|
+
return wrap ? (current + 1) % count : Math.min(current + 1, count - 1);
|
|
47
|
+
case 'ArrowUp':
|
|
48
|
+
return wrap ? (current - 1 + count) % count : Math.max(current - 1, 0);
|
|
49
|
+
case 'Home':
|
|
50
|
+
return 0;
|
|
51
|
+
case 'End':
|
|
52
|
+
return count - 1;
|
|
53
|
+
default:
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// --- pure: typeahead (unit-tested, no DOM) ---------------------------------
|
|
59
|
+
// Case-insensitive startsWith over labels, searching current+1…end then
|
|
60
|
+
// 0…current (current itself last, so a buffer that still prefixes the
|
|
61
|
+
// current option stays put). A buffer of one repeated char ("ddd") cycles
|
|
62
|
+
// through options starting with that char. Returns the matched index, or
|
|
63
|
+
// null when nothing matches.
|
|
64
|
+
function matchOption(labels, buffer, current) {
|
|
65
|
+
if (!labels || !labels.length || !buffer) return null;
|
|
66
|
+
var b = String(buffer).toLowerCase();
|
|
67
|
+
var allSame = b.length > 1;
|
|
68
|
+
for (var k = 1; k < b.length; k++) if (b[k] !== b[0]) { allSame = false; break; }
|
|
69
|
+
var needle = allSame ? b[0] : b;
|
|
70
|
+
var n = labels.length;
|
|
71
|
+
var from = typeof current === 'number' && current >= 0 ? current : -1;
|
|
72
|
+
for (var step = 1; step <= n; step++) {
|
|
73
|
+
var i = (from + step) % n;
|
|
74
|
+
var label = String(labels[i] == null ? '' : labels[i]).trim().toLowerCase();
|
|
75
|
+
if (label.indexOf(needle) === 0) return i;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
var noop = { setActive: function () {}, select: function () {}, refresh: function () {}, destroy: function () {} };
|
|
81
|
+
var OPTION_SELECTOR = '[role="option"], [role="menuitem"]';
|
|
82
|
+
var uid = 0;
|
|
83
|
+
|
|
84
|
+
function isDisabled(opt) {
|
|
85
|
+
return opt.getAttribute('aria-disabled') === 'true';
|
|
86
|
+
}
|
|
87
|
+
function isHidden(opt) {
|
|
88
|
+
return !!opt.closest('[hidden]');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// --- DOM: roving-tabindex mode (standalone .listbox / .menu) ---------------
|
|
92
|
+
function enhance(el, opts) {
|
|
93
|
+
opts = opts || {};
|
|
94
|
+
if (!el) return noop;
|
|
95
|
+
if (el.__artificerOptions) return el.__artificerOptions;
|
|
96
|
+
|
|
97
|
+
var options = [];
|
|
98
|
+
var current = 0;
|
|
99
|
+
var isMenu = el.getAttribute('role') === 'menu';
|
|
100
|
+
var wrap = typeof opts.wrap === 'boolean' ? opts.wrap : isMenu; // APG: menus wrap, listboxes clamp
|
|
101
|
+
var buffer = '';
|
|
102
|
+
var bufferTimer = null;
|
|
103
|
+
|
|
104
|
+
function refresh() {
|
|
105
|
+
options = Array.prototype.slice.call(el.querySelectorAll(OPTION_SELECTOR));
|
|
106
|
+
if (!options.length) return;
|
|
107
|
+
// Initial/retained cursor: existing tabindex="0" wins, else the selected
|
|
108
|
+
// option, else first — idempotent over markup that already roves.
|
|
109
|
+
var keep = -1;
|
|
110
|
+
options.forEach(function (o, j) {
|
|
111
|
+
if (keep < 0 && o.getAttribute('tabindex') === '0') keep = j;
|
|
112
|
+
});
|
|
113
|
+
if (keep < 0) {
|
|
114
|
+
options.forEach(function (o, j) {
|
|
115
|
+
if (keep < 0 && o.getAttribute('aria-selected') === 'true') keep = j;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
current = keep < 0 ? 0 : keep;
|
|
119
|
+
render(current, false);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function render(i, focus) {
|
|
123
|
+
options.forEach(function (o, j) {
|
|
124
|
+
o.setAttribute('tabindex', j === i ? '0' : '-1');
|
|
125
|
+
});
|
|
126
|
+
current = i;
|
|
127
|
+
if (focus) options[i].focus();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function select(i) {
|
|
131
|
+
var opt = options[i];
|
|
132
|
+
if (!opt || isDisabled(opt)) return; // focusable but inert
|
|
133
|
+
if (!isMenu) {
|
|
134
|
+
// single-select listbox: aria-selected moves (mechanics only)
|
|
135
|
+
options.forEach(function (o) {
|
|
136
|
+
if (o === opt) o.setAttribute('aria-selected', 'true');
|
|
137
|
+
else o.removeAttribute('aria-selected');
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (typeof opts.onSelect === 'function') opts.onSelect(opt, i);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function onKeydown(e) {
|
|
144
|
+
var i = options.indexOf(e.target.closest(OPTION_SELECTOR));
|
|
145
|
+
if (i < 0) return;
|
|
146
|
+
var target = nextOption(e.key, i, options.length, { wrap: wrap });
|
|
147
|
+
if (target !== null) {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
render(target, true);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
153
|
+
e.preventDefault(); // also stops a native button click double-firing
|
|
154
|
+
select(i);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
// type-to-select — single printable chars accumulate for 500ms
|
|
158
|
+
if (e.key.length === 1 && e.key !== ' ' && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
159
|
+
buffer += e.key;
|
|
160
|
+
clearTimeout(bufferTimer);
|
|
161
|
+
bufferTimer = setTimeout(function () { buffer = ''; }, 500);
|
|
162
|
+
var labels = options.map(function (o) { return o.textContent; });
|
|
163
|
+
var match = matchOption(labels, buffer, i);
|
|
164
|
+
if (match !== null) render(match, true);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function onClick(e) {
|
|
169
|
+
var opt = e.target.closest(OPTION_SELECTOR);
|
|
170
|
+
if (!opt || !el.contains(opt)) return;
|
|
171
|
+
var i = options.indexOf(opt);
|
|
172
|
+
if (i < 0) return;
|
|
173
|
+
render(i, true); // click also moves the roving tabindex
|
|
174
|
+
select(i);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
el.addEventListener('keydown', onKeydown);
|
|
178
|
+
el.addEventListener('click', onClick);
|
|
179
|
+
refresh();
|
|
180
|
+
|
|
181
|
+
var handle = {
|
|
182
|
+
setActive: function (i) { render(i, true); },
|
|
183
|
+
select: select,
|
|
184
|
+
refresh: refresh,
|
|
185
|
+
destroy: function () {
|
|
186
|
+
el.removeEventListener('keydown', onKeydown);
|
|
187
|
+
el.removeEventListener('click', onClick);
|
|
188
|
+
clearTimeout(bufferTimer);
|
|
189
|
+
delete el.__artificerOptions;
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
el.__artificerOptions = handle;
|
|
193
|
+
return handle;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// --- DOM: activedescendant mode (combobox input + listbox popup) -----------
|
|
197
|
+
function combobox(input, list, opts) {
|
|
198
|
+
opts = opts || {};
|
|
199
|
+
if (!input || !list) return noop;
|
|
200
|
+
if (input.__artificerCombobox) return input.__artificerCombobox;
|
|
201
|
+
|
|
202
|
+
if (!list.id) list.id = 'artificer-combobox-list-' + ++uid;
|
|
203
|
+
// Combobox ARIA on the input — only where the markup hasn't already said it.
|
|
204
|
+
if (!input.getAttribute('role')) input.setAttribute('role', 'combobox');
|
|
205
|
+
if (!input.getAttribute('aria-controls')) input.setAttribute('aria-controls', list.id);
|
|
206
|
+
if (!input.getAttribute('aria-autocomplete')) input.setAttribute('aria-autocomplete', 'list');
|
|
207
|
+
// The module owns no open/close: the popup is perceivable whenever its
|
|
208
|
+
// dialog is, so a static expanded=true is correct.
|
|
209
|
+
if (!input.getAttribute('aria-expanded')) input.setAttribute('aria-expanded', 'true');
|
|
210
|
+
|
|
211
|
+
var visible = [];
|
|
212
|
+
var current = -1;
|
|
213
|
+
|
|
214
|
+
function visibleOptions() {
|
|
215
|
+
return Array.prototype.slice
|
|
216
|
+
.call(list.querySelectorAll('[role="option"]'))
|
|
217
|
+
.filter(function (o) { return !isHidden(o); });
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function setActive(i) {
|
|
221
|
+
visible.forEach(function (o, j) { o.classList.toggle('is-active', j === i); });
|
|
222
|
+
current = i;
|
|
223
|
+
var opt = visible[i];
|
|
224
|
+
if (opt) {
|
|
225
|
+
// mint a STABLE unique id, never the visible index — after filtering,
|
|
226
|
+
// a different option at the same index would collide with an id
|
|
227
|
+
// minted earlier (duplicate DOM ids → ambiguous activedescendant)
|
|
228
|
+
if (!opt.id) opt.id = list.id + '-opt-' + ++uid;
|
|
229
|
+
input.setAttribute('aria-activedescendant', opt.id);
|
|
230
|
+
} else {
|
|
231
|
+
input.removeAttribute('aria-activedescendant');
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// refresh() — the consumer just filtered (toggled [hidden]): recompute the
|
|
236
|
+
// visible set, keep the cursor's option if it survived, else re-clamp; an
|
|
237
|
+
// empty set clears the cursor + aria-activedescendant.
|
|
238
|
+
function refresh() {
|
|
239
|
+
var keep = visible[current] || null;
|
|
240
|
+
visible = visibleOptions();
|
|
241
|
+
if (!visible.length) { setActive(-1); return; }
|
|
242
|
+
var kept = keep ? visible.indexOf(keep) : -1;
|
|
243
|
+
if (kept < 0) {
|
|
244
|
+
// adopt a pre-marked cursor (idempotent over PR-1-style markup)…
|
|
245
|
+
kept = -1;
|
|
246
|
+
visible.forEach(function (o, j) {
|
|
247
|
+
if (kept < 0 && o.classList.contains('is-active')) kept = j;
|
|
248
|
+
});
|
|
249
|
+
// …else clamp the old index into the new range
|
|
250
|
+
if (kept < 0) kept = Math.max(0, Math.min(current, visible.length - 1));
|
|
251
|
+
}
|
|
252
|
+
setActive(kept);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function select(i) {
|
|
256
|
+
var opt = visible[i];
|
|
257
|
+
if (!opt || isDisabled(opt)) return;
|
|
258
|
+
if (typeof opts.onSelect === 'function') opts.onSelect(opt, i);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
// Hard scope line: arrows/Home/End/Enter only. Printable keys are NEVER
|
|
262
|
+
// consumed (typing = the consumer's filter); Escape is NEVER handled
|
|
263
|
+
// (ArtificerFocus.trap owns it).
|
|
264
|
+
function onKeydown(e) {
|
|
265
|
+
var target = nextOption(e.key, current, visible.length, { wrap: false });
|
|
266
|
+
if (target !== null) {
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
setActive(target);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
if (e.key === 'Enter') {
|
|
272
|
+
if (current < 0) return;
|
|
273
|
+
e.preventDefault();
|
|
274
|
+
select(current);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function onClick(e) {
|
|
279
|
+
var opt = e.target.closest('[role="option"]');
|
|
280
|
+
if (!opt || !list.contains(opt)) return;
|
|
281
|
+
var i = visible.indexOf(opt);
|
|
282
|
+
if (i < 0) return;
|
|
283
|
+
setActive(i); // click parity with the keyboard cursor
|
|
284
|
+
select(i);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
input.addEventListener('keydown', onKeydown);
|
|
288
|
+
list.addEventListener('click', onClick);
|
|
289
|
+
refresh();
|
|
290
|
+
|
|
291
|
+
var handle = {
|
|
292
|
+
setActive: setActive,
|
|
293
|
+
select: select,
|
|
294
|
+
refresh: refresh,
|
|
295
|
+
destroy: function () {
|
|
296
|
+
input.removeEventListener('keydown', onKeydown);
|
|
297
|
+
list.removeEventListener('click', onClick);
|
|
298
|
+
delete input.__artificerCombobox;
|
|
299
|
+
},
|
|
300
|
+
};
|
|
301
|
+
input.__artificerCombobox = handle;
|
|
302
|
+
return handle;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// Auto-enhance [data-options] (roving) and input[data-combobox="listId"]
|
|
306
|
+
// (activedescendant) now and on insert (SPA lifecycle, matching
|
|
307
|
+
// ArtificerTabs.observe). Returns a disconnect fn.
|
|
308
|
+
function observe(root) {
|
|
309
|
+
root = root || (typeof document !== 'undefined' ? document : null);
|
|
310
|
+
if (!root) return function () {};
|
|
311
|
+
function hydrate(el) {
|
|
312
|
+
if (el.matches && el.matches('[data-options]')) enhance(el);
|
|
313
|
+
if (el.matches && el.matches('input[data-combobox]')) {
|
|
314
|
+
var list = document.getElementById(el.getAttribute('data-combobox'));
|
|
315
|
+
if (list) combobox(el, list);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
function enhanceIn(scope) {
|
|
319
|
+
hydrate(scope);
|
|
320
|
+
if (scope.querySelectorAll) {
|
|
321
|
+
Array.prototype.forEach.call(
|
|
322
|
+
scope.querySelectorAll('[data-options], input[data-combobox]'),
|
|
323
|
+
hydrate
|
|
324
|
+
);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
enhanceIn(root);
|
|
328
|
+
if (typeof MutationObserver === 'undefined') return function () {};
|
|
329
|
+
var mo = new MutationObserver(function (muts) {
|
|
330
|
+
muts.forEach(function (m) {
|
|
331
|
+
Array.prototype.forEach.call(m.addedNodes || [], function (n) {
|
|
332
|
+
if (n.nodeType === 1) enhanceIn(n);
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
mo.observe(root === document ? document.body : root, { childList: true, subtree: true });
|
|
337
|
+
return function () {
|
|
338
|
+
mo.disconnect();
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
var api = {
|
|
343
|
+
enhance: enhance,
|
|
344
|
+
combobox: combobox,
|
|
345
|
+
observe: observe,
|
|
346
|
+
nextOption: nextOption,
|
|
347
|
+
matchOption: matchOption,
|
|
348
|
+
};
|
|
349
|
+
// globalThis === window in a browser (so window.ArtificerOptions works);
|
|
350
|
+
// in Node it lets the unit test import this file and exercise the pure fns.
|
|
351
|
+
if (typeof window !== 'undefined') window.ArtificerOptions = api;
|
|
352
|
+
else if (typeof globalThis !== 'undefined') globalThis.ArtificerOptions = api;
|
|
353
|
+
})();
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/* ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
ARTIFICER · Texture · v0.12.0 (the third — and ceiling — sanctioned carve)
|
|
3
|
+
─────────────────────────────────────────────────────────────────────────
|
|
4
|
+
Artificer's surfaces are flat solid fills by doctrine. This file is the
|
|
5
|
+
bounded place that relaxes that — material honesty, not decoration. Read
|
|
6
|
+
CLAUDE.md § Texture
|
|
7
|
+
before reaching for it.
|
|
8
|
+
|
|
9
|
+
The rule the system kept saying but never drew: the dark floor is "ink", the
|
|
10
|
+
light floor is "paper", the language is apothecary / deco / speakeasy. These
|
|
11
|
+
tokens make that literal — WITHOUT adding hue (grain is desaturated; lines
|
|
12
|
+
are drawn from --border/--fg only) and WITHOUT motion (texture is static;
|
|
13
|
+
page-grain travels with the page, it does not animate).
|
|
14
|
+
|
|
15
|
+
Opt-in only. The class IS the switch — a surface is flat until you reach for
|
|
16
|
+
a texture. HARD BOUNDS (enforced by taste, documented here):
|
|
17
|
+
• Never on data, status, or errors — same load-bearing exclusion as Whimsy.
|
|
18
|
+
• One texture per surface. Don't stack grain + line + depth.
|
|
19
|
+
• Heroes stay flat + type-led. The flowing wordmark IS the hero's texture;
|
|
20
|
+
a grain/plate field behind a full-bleed hero fights it. (Page-grain is
|
|
21
|
+
the one exception — a whole-page substrate, opt-in, capped at "whisper".)
|
|
22
|
+
• Web layer only. The editor themes are generated from the palette and
|
|
23
|
+
cannot carry CSS texture — themes/_build.mjs never sees this file.
|
|
24
|
+
|
|
25
|
+
Depends on artificer.css (--border, --fg, --accent, --bg-raised, --radius-*,
|
|
26
|
+
--dur-max, --ease, --shadow-overlay).
|
|
27
|
+
═══════════════════════════════════════════════════════════════════════════ */
|
|
28
|
+
|
|
29
|
+
:root {
|
|
30
|
+
/* ── knobs ─────────────────────────────────────────────────────────────── */
|
|
31
|
+
--tex-dot-gap: 14px; /* dot-matrix lattice pitch. Sweet spot 14; 12–16. */
|
|
32
|
+
--tex-fiber-strength: 0.5; /* document-fiber intensity (0–1). */
|
|
33
|
+
--tex-paper-grain: 0.22; /* page-grain level. 0.22 = Faint · 0.45 = Whisper. */
|
|
34
|
+
--tex-line-ink: var(--border); /* deco lines are token ink, never raw color. */
|
|
35
|
+
--tex-line-a: 70%; /* line ink alpha (dark). */
|
|
36
|
+
|
|
37
|
+
/* Desaturated fiber noise — the paper/ink tooth. No hue, blended into surface. */
|
|
38
|
+
--tex-noise-fiber: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E");
|
|
39
|
+
/* Page-grain speckle — noise baked as ALPHA so it shows with normal
|
|
40
|
+
compositing (blend-mode independent, renders reliably). Light grains on
|
|
41
|
+
ink; the light-theme block below swaps to ink grains on paper. */
|
|
42
|
+
--tex-speckle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='1.1' intercept='-0.45'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Light (paper) retunes — the lines read too strong on cream with the dark
|
|
46
|
+
--border at full alpha and pick up a bluish cast; ride the border ink softer.
|
|
47
|
+
The page-grain speckle inverts to ink grains so it shows on paper. */
|
|
48
|
+
:root[data-theme="light"] {
|
|
49
|
+
--tex-line-a: 68%;
|
|
50
|
+
--tex-speckle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='s'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='matrix' values='0 0 0 0 0.12 0 0 0 0 0.11 0 0 0 0 0.20 1 0 0 0 0'/%3E%3CfeComponentTransfer%3E%3CfeFuncA type='linear' slope='1.1' intercept='-0.45'/%3E%3C/feComponentTransfer%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23s)'/%3E%3C/svg%3E");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* ═══ 1 · GRAIN ═══════════════════════════════════════════════════════════
|
|
54
|
+
Two grains for two surfaces. Dots = engineered lattice for TOOL surfaces.
|
|
55
|
+
Fiber = irregular paper tooth for DOCUMENT surfaces. Both desaturated. */
|
|
56
|
+
|
|
57
|
+
/* dot-matrix — regular lattice, never mottles type. Pitch on --tex-dot-gap. */
|
|
58
|
+
.tex-dots { position: relative; isolation: isolate; }
|
|
59
|
+
.tex-dots::after {
|
|
60
|
+
content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
|
|
61
|
+
background-image: radial-gradient(circle at center,
|
|
62
|
+
color-mix(in oklab, var(--fg) 52%, transparent) 0.5px, transparent 1.1px);
|
|
63
|
+
background-size: var(--tex-dot-gap) var(--tex-dot-gap);
|
|
64
|
+
opacity: 0.5;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* fiber — desaturated noise blended into the surface (overlay on ink, soft-
|
|
68
|
+
light on paper) so it modulates value without adding hue. */
|
|
69
|
+
.tex-grain { position: relative; isolation: isolate; }
|
|
70
|
+
.tex-grain::after {
|
|
71
|
+
content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
|
|
72
|
+
background-image: var(--tex-noise-fiber); background-size: 160px 160px;
|
|
73
|
+
mix-blend-mode: overlay;
|
|
74
|
+
opacity: calc(var(--tex-fiber-strength) * 0.5);
|
|
75
|
+
}
|
|
76
|
+
:root[data-theme="light"] .tex-grain::after { mix-blend-mode: soft-light; opacity: calc(var(--tex-fiber-strength) * 0.85); }
|
|
77
|
+
|
|
78
|
+
/* ═══ 2 · PAGE-GRAIN (optional · whole-page substrate) ════════════════════
|
|
79
|
+
A faint "printed on something" layer under the WHOLE page. Put .tex-paper on
|
|
80
|
+
the page wrapper (a positioned ancestor of your content); it lays a speckle
|
|
81
|
+
pseudo-element behind everything that SCROLLS WITH the page (absolute, not
|
|
82
|
+
fixed — a fixed grain reads as dirt on glass when content slides past it).
|
|
83
|
+
Two levels only: Faint (default) and .tex-paper--whisper. Nothing louder
|
|
84
|
+
ships — Subtle/Medium were explicitly rejected. Content must establish its
|
|
85
|
+
own stacking context above the grain. */
|
|
86
|
+
.tex-paper { position: relative; }
|
|
87
|
+
.tex-paper > * { position: relative; z-index: 1; }
|
|
88
|
+
.tex-paper::before {
|
|
89
|
+
content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
|
|
90
|
+
background-image: var(--tex-speckle); background-size: 150px 150px;
|
|
91
|
+
opacity: var(--tex-paper-grain);
|
|
92
|
+
}
|
|
93
|
+
.tex-paper--whisper { --tex-paper-grain: 0.45; }
|
|
94
|
+
|
|
95
|
+
/* ═══ 3 · DECO LINE-TEXTURE (ink, not material) ═══════════════════════════
|
|
96
|
+
Hatch / cross / flute / pinstripe — drawn ONLY from token ink, so they add
|
|
97
|
+
no color and sidestep the no-raw-color rule entirely. Editorial, not
|
|
98
|
+
material. Best on empty states, section bands, card/aside spines. */
|
|
99
|
+
.tex-line { position: relative; isolation: isolate; }
|
|
100
|
+
.tex-line::after {
|
|
101
|
+
content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
|
|
102
|
+
}
|
|
103
|
+
:root[data-theme="light"] .tex-line::after { opacity: 0.55; } /* paper reads softer */
|
|
104
|
+
|
|
105
|
+
/* hatch — fine diagonal apothecary tooth */
|
|
106
|
+
.tex-line--hatch::after {
|
|
107
|
+
background-image: repeating-linear-gradient(45deg,
|
|
108
|
+
transparent 0 7px,
|
|
109
|
+
color-mix(in oklab, var(--tex-line-ink) var(--tex-line-a), transparent) 7px 8px);
|
|
110
|
+
}
|
|
111
|
+
/* cross — hatch on both diagonals */
|
|
112
|
+
.tex-line--cross::after {
|
|
113
|
+
background-image:
|
|
114
|
+
repeating-linear-gradient(45deg, transparent 0 7px, color-mix(in oklab, var(--tex-line-ink) var(--tex-line-a), transparent) 7px 8px),
|
|
115
|
+
repeating-linear-gradient(-45deg, transparent 0 7px, color-mix(in oklab, var(--tex-line-ink) var(--tex-line-a), transparent) 7px 8px);
|
|
116
|
+
}
|
|
117
|
+
/* flute — paired vertical hairlines, the speakeasy column */
|
|
118
|
+
.tex-line--flute::after {
|
|
119
|
+
background-image: repeating-linear-gradient(90deg,
|
|
120
|
+
transparent 0 13px,
|
|
121
|
+
color-mix(in oklab, var(--fg) 9%, transparent) 13px 14px,
|
|
122
|
+
transparent 14px 16px,
|
|
123
|
+
color-mix(in oklab, var(--fg) 9%, transparent) 16px 17px);
|
|
124
|
+
}
|
|
125
|
+
:root[data-theme="light"] .tex-line--flute::after {
|
|
126
|
+
background-image: repeating-linear-gradient(90deg,
|
|
127
|
+
transparent 0 13px,
|
|
128
|
+
color-mix(in oklab, var(--tex-line-ink) var(--tex-line-a), transparent) 13px 14px,
|
|
129
|
+
transparent 14px 16px,
|
|
130
|
+
color-mix(in oklab, var(--tex-line-ink) var(--tex-line-a), transparent) 16px 17px);
|
|
131
|
+
}
|
|
132
|
+
/* pinstripe — even single hairlines, tailoring not architecture */
|
|
133
|
+
.tex-line--pinstripe::after {
|
|
134
|
+
background-image: repeating-linear-gradient(90deg,
|
|
135
|
+
transparent 0 15px,
|
|
136
|
+
color-mix(in oklab, var(--tex-line-ink) var(--tex-line-a), transparent) 15px 16px);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/* ═══ 4 · RAISED (outer-glow depth) ═══════════════════════════════════════
|
|
140
|
+
The one sanctioned elevation beyond the functional --shadow-overlay. The
|
|
141
|
+
card FACE stays flat (no interior gradient — that "uniform glow" look is a
|
|
142
|
+
canonical no); depth is a soft halo bleeding to the bottom-right, entirely
|
|
143
|
+
outside the border. A raised tile lit from outside. */
|
|
144
|
+
.tex-raised {
|
|
145
|
+
box-shadow: 4px 6px 14px 1px rgba(0,0,0,.20), 9px 12px 30px 2px rgba(0,0,0,.14);
|
|
146
|
+
}
|
|
147
|
+
:root[data-theme="light"] .tex-raised {
|
|
148
|
+
box-shadow: 4px 6px 14px 1px rgba(32,32,62,.13), 9px 12px 30px 2px rgba(32,32,62,.09);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* ═══ Reduced-motion ══════════════════════════════════════════════════════
|
|
152
|
+
Texture is static by design, so there is nothing to stop. Page-grain travels
|
|
153
|
+
with native scroll only — it has no animation. Documented for completeness. */
|
package/src/artificer-theme.js
CHANGED
|
@@ -43,11 +43,14 @@
|
|
|
43
43
|
root = root || document.body;
|
|
44
44
|
bind();
|
|
45
45
|
if (typeof MutationObserver === 'undefined') return function () {};
|
|
46
|
+
var schedule = window.requestAnimationFrame
|
|
47
|
+
? function (cb) { window.requestAnimationFrame(cb); }
|
|
48
|
+
: function (cb) { window.setTimeout(cb, 0); };
|
|
46
49
|
var scheduled = false;
|
|
47
50
|
var mo = new MutationObserver(function () {
|
|
48
51
|
if (scheduled) return;
|
|
49
52
|
scheduled = true;
|
|
50
|
-
(
|
|
53
|
+
schedule(function () { scheduled = false; bind(); });
|
|
51
54
|
});
|
|
52
55
|
mo.observe(root, { childList: true, subtree: true });
|
|
53
56
|
return function () { mo.disconnect(); };
|