@cameronsjo/artificer 0.12.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/LICENSE +202 -0
- package/README.md +260 -0
- package/package.json +46 -0
- package/src/artificer-editorial.css +136 -0
- package/src/artificer-focus.js +47 -0
- package/src/artificer-icons.js +163 -0
- package/src/artificer-tabs.js +169 -0
- package/src/artificer-theme.js +63 -0
- package/src/artificer-whimsy.css +317 -0
- package/src/artificer-whimsy.js +184 -0
- package/src/artificer.css +1478 -0
- package/src/assets/favicon.svg +9 -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/src/assets/fonts/ia-writer-quattro-s-400-italic.woff2 +0 -0
- package/src/assets/fonts/ia-writer-quattro-s-400.woff2 +0 -0
- package/src/assets/fonts/ia-writer-quattro-s-700-italic.woff2 +0 -0
- package/src/assets/fonts/ia-writer-quattro-s-700.woff2 +0 -0
- package/src/assets/fonts/ia-writer-quattro-v-400-italic.woff2 +0 -0
- package/src/assets/fonts/ia-writer-quattro-v-400.woff2 +0 -0
- package/src/assets/fonts/jetbrains-mono-400.woff2 +0 -0
- package/src/assets/fonts/jetbrains-mono-500.woff2 +0 -0
- package/src/assets/fonts/jetbrains-mono-700.woff2 +0 -0
- package/src/assets/og-image.png +0 -0
- package/src/assets/og-image.svg +54 -0
- package/src/print.css +167 -0
- package/src/theme-bootstrap.html +23 -0
- package/src/tokens.json +169 -0
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/* ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
ARTIFICER · Whimsy · v0.10.0 (the sanctioned exception)
|
|
3
|
+
─────────────────────────────────────────────────────────────────────────
|
|
4
|
+
This file is the ONE place in Artificer where the "no looping decoration"
|
|
5
|
+
and "no raw color" rules are deliberately relaxed. Read themes/CLAUDE.md
|
|
6
|
+
§ Whimsy before reaching for it.
|
|
7
|
+
|
|
8
|
+
What it is: a flowing sine-wave rainbow — the feeling of Claude Code's
|
|
9
|
+
"ultrathink" shimmer — for *user-defined fun elements* and whimsical
|
|
10
|
+
operations (celebrations, easter eggs, the brand wordmark, long "thinking"
|
|
11
|
+
states). Opt-in only. Never on chrome, never on anything load-bearing.
|
|
12
|
+
|
|
13
|
+
Two palettes ship:
|
|
14
|
+
• DEFAULT (spectrum) — a BURNISHED full-spectrum rainbow, generated in
|
|
15
|
+
oklch at the palette's own lightness + chroma. The "normal RGB" look,
|
|
16
|
+
kept in-family. Dial --whimsy-c up only when you mean it.
|
|
17
|
+
• .whimsy--brand — cycles through Artificer's REAL semantic tokens
|
|
18
|
+
(gold → rose → brand-purple → steel → green → gold). It reads the live
|
|
19
|
+
CSS vars, so it tracks light/dark for free and is unmistakably ours.
|
|
20
|
+
More tonal variation than the spectrum by design — the brand colors
|
|
21
|
+
aren't uniform lightness, so the brand cycle breathes.
|
|
22
|
+
|
|
23
|
+
Configure easily: --whimsy-gradient IS the knob. Override it on any scope to
|
|
24
|
+
bring your own palette, e.g.
|
|
25
|
+
style="--whimsy-gradient: linear-gradient(100deg, var(--success), var(--accent), var(--success))"
|
|
26
|
+
The two presets above are just two values of that one variable.
|
|
27
|
+
|
|
28
|
+
Reduced-motion: the flow stops, the burnished gradient stays. Still joyful,
|
|
29
|
+
still accessible. Whimsy text is display/bold only — never body copy.
|
|
30
|
+
Depends on artificer.css (--ease, --font-mono, brand tokens).
|
|
31
|
+
═══════════════════════════════════════════════════════════════════════════ */
|
|
32
|
+
|
|
33
|
+
:root {
|
|
34
|
+
/* The knobs. Override on a scope to retune locally. */
|
|
35
|
+
--whimsy-l: 0.80; /* lightness of the spectrum (dark mode) */
|
|
36
|
+
--whimsy-c: 0.115; /* chroma — palette-muted. ~0.20 = vivid. */
|
|
37
|
+
--whimsy-angle: 100deg; /* gradient direction across the text */
|
|
38
|
+
--whimsy-speed: 7s; /* one full hue cycle. Calm, not frantic. */
|
|
39
|
+
--whimsy-bob: 2.6s; /* sine-wave bob period (wave variant) */
|
|
40
|
+
--whimsy-rise: 0.16em; /* sine-wave bob amplitude */
|
|
41
|
+
--whimsy-settle-speed: 150s; /* glacial rest cycle — ~2.5min, sub-perceptual */
|
|
42
|
+
|
|
43
|
+
/* Burnished spectrum — hue stops walk Artificer's own brand hues and loop
|
|
44
|
+
(first == last so the flow is seamless). Built lazily from the knobs,
|
|
45
|
+
so a light-mode --whimsy-l/c override below just works. */
|
|
46
|
+
--whimsy-gradient: linear-gradient(
|
|
47
|
+
var(--whimsy-angle),
|
|
48
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 85), /* gold */
|
|
49
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 150), /* apothecary */
|
|
50
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 200), /* cyan */
|
|
51
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 235), /* steel */
|
|
52
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 290), /* brand purple*/
|
|
53
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 340), /* rose */
|
|
54
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 30), /* amber/brick */
|
|
55
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 85) /* → gold */
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
/* Brand palette — the system's real tokens in motion. Auto-tracks theme
|
|
59
|
+
because it references the live vars. First == last so the loop is seamless. */
|
|
60
|
+
--whimsy-gradient-brand: linear-gradient(
|
|
61
|
+
var(--whimsy-angle),
|
|
62
|
+
var(--accent, #dbbb6f), /* gold */
|
|
63
|
+
var(--attention, #c4808a), /* rose */
|
|
64
|
+
var(--brand-purple, #5a3a9a), /* purple */
|
|
65
|
+
var(--steel, #b8cad4), /* steel */
|
|
66
|
+
var(--success, #4a8a5e), /* apothecary */
|
|
67
|
+
var(--accent, #dbbb6f) /* → gold */
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
/* Sine-wave mask for the rainbow rule (one period = 64px). */
|
|
71
|
+
--whimsy-wave-mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='64' height='22' viewBox='0 0 64 22'><path d='M0 11 Q 8 2 16 11 T 32 11 T 48 11 T 64 11' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'/></svg>");
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Light mode (ivory paper) — the spectrum must darken to read on cream.
|
|
75
|
+
Same hues, lower lightness, a touch more chroma so it stays present. */
|
|
76
|
+
:root[data-theme="light"],
|
|
77
|
+
:root:not([data-theme]) {
|
|
78
|
+
--whimsy-l: 0.80;
|
|
79
|
+
}
|
|
80
|
+
:root[data-theme="light"] {
|
|
81
|
+
--whimsy-l: 0.52;
|
|
82
|
+
--whimsy-c: 0.135;
|
|
83
|
+
}
|
|
84
|
+
@media (prefers-color-scheme: light) {
|
|
85
|
+
:root:not([data-theme]) { --whimsy-l: 0.52; --whimsy-c: 0.135; }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/* Silver inverts on cream: warm graphite/ink so it reads on the paper bg,
|
|
89
|
+
with a faint bone undertone (hue ~75) instead of a cold grey. */
|
|
90
|
+
:root[data-theme="light"] .whimsy--silver {
|
|
91
|
+
--whimsy-gradient: linear-gradient(
|
|
92
|
+
var(--whimsy-angle),
|
|
93
|
+
oklch(0.42 0.012 75),
|
|
94
|
+
oklch(0.26 0.012 75),
|
|
95
|
+
oklch(0.46 0.012 75),
|
|
96
|
+
oklch(0.22 0.012 75),
|
|
97
|
+
oklch(0.42 0.012 75)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
@media (prefers-color-scheme: light) {
|
|
101
|
+
:root:not([data-theme]) .whimsy--silver {
|
|
102
|
+
--whimsy-gradient: linear-gradient(
|
|
103
|
+
var(--whimsy-angle),
|
|
104
|
+
oklch(0.42 0.012 75),
|
|
105
|
+
oklch(0.26 0.012 75),
|
|
106
|
+
oklch(0.46 0.012 75),
|
|
107
|
+
oklch(0.22 0.012 75),
|
|
108
|
+
oklch(0.42 0.012 75)
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/* ─── The signature: flowing burnished rainbow on text ─────────────────────
|
|
114
|
+
Apply to a word or short phrase set large + bold. The gradient is clipped
|
|
115
|
+
to the glyphs and flows. This is the "ultrathink" look. */
|
|
116
|
+
.whimsy,
|
|
117
|
+
.whimsy-char {
|
|
118
|
+
background-image: var(--whimsy-gradient);
|
|
119
|
+
background-size: 200% 100%;
|
|
120
|
+
background-repeat: repeat; /* TILE — so glyphs are always covered.
|
|
121
|
+
no-repeat let the gradient scroll off and
|
|
122
|
+
the (transparent) text vanish, then pop. */
|
|
123
|
+
-webkit-background-clip: text;
|
|
124
|
+
background-clip: text;
|
|
125
|
+
color: transparent;
|
|
126
|
+
-webkit-text-fill-color: transparent;
|
|
127
|
+
animation: whimsy-flow var(--whimsy-speed) linear infinite;
|
|
128
|
+
/* recommended, not enforced — gradients read best heavy + tight */
|
|
129
|
+
font-weight: 700;
|
|
130
|
+
}
|
|
131
|
+
@keyframes whimsy-flow {
|
|
132
|
+
from { background-position: 0% 50%; }
|
|
133
|
+
to { background-position: 200% 50%; } /* exactly one tile → seamless loop */
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* Vivid — for the rare moment you want full saturation. Dial consciously. */
|
|
137
|
+
.whimsy--vivid { --whimsy-c: 0.21; }
|
|
138
|
+
|
|
139
|
+
/* Brand cycle — swap the spectrum for Artificer's real semantic colors.
|
|
140
|
+
Works on .whimsy text, .whimsy--wave, and .whimsy-rule alike (they all read
|
|
141
|
+
--whimsy-gradient). Brand mode ignores --whimsy-c/l — it uses the tokens. */
|
|
142
|
+
.whimsy--brand { --whimsy-gradient: var(--whimsy-gradient-brand); }
|
|
143
|
+
|
|
144
|
+
/* ─── Silver: a near-neutral metal sheen — the most restrained whimsy ──────
|
|
145
|
+
Black/white/grey/silver on dark; warm graphite on cream (text must contrast
|
|
146
|
+
its surface, so light mode inverts to ink-with-a-bone-undertone, not bone).
|
|
147
|
+
Quiet enough to consider for section headers. Defaults SLOW — a dignified
|
|
148
|
+
sheen, not a sweep. For a still metallic fill (recommended header default,
|
|
149
|
+
no motion at all) add .whimsy--no-flow. Ignores --whimsy-c. */
|
|
150
|
+
.whimsy--silver {
|
|
151
|
+
--whimsy-speed: 16s;
|
|
152
|
+
--whimsy-gradient: linear-gradient(
|
|
153
|
+
var(--whimsy-angle),
|
|
154
|
+
oklch(0.66 0.006 255), /* grey */
|
|
155
|
+
oklch(0.88 0.005 255), /* silver */
|
|
156
|
+
oklch(0.74 0.006 255), /* steel-grey */
|
|
157
|
+
oklch(0.96 0.004 255), /* near-white sheen */
|
|
158
|
+
oklch(0.66 0.006 255) /* → grey (loop) */
|
|
159
|
+
);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* ─── Wave variant: per-character sine bob + travelling hue ────────────────
|
|
163
|
+
Needs Whimsy.hydrate() (artificer-whimsy.js) to split text into
|
|
164
|
+
.whimsy-char spans and stagger --d. Without JS it degrades to a flat
|
|
165
|
+
gradient on the original text — still fine. */
|
|
166
|
+
.whimsy--wave > .whimsy-char {
|
|
167
|
+
display: inline-block;
|
|
168
|
+
white-space: pre; /* preserve spaces between split chars */
|
|
169
|
+
animation-name: whimsy-flow, whimsy-bob;
|
|
170
|
+
animation-duration: var(--whimsy-speed), var(--whimsy-bob);
|
|
171
|
+
animation-timing-function: linear, var(--ease);
|
|
172
|
+
animation-iteration-count: infinite, infinite;
|
|
173
|
+
animation-delay: var(--d, 0s), var(--d, 0s);
|
|
174
|
+
will-change: transform;
|
|
175
|
+
}
|
|
176
|
+
@keyframes whimsy-bob {
|
|
177
|
+
0%, 100% { transform: translateY(0); }
|
|
178
|
+
50% { transform: translateY(calc(-1 * var(--whimsy-rise))); }
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* ─── Rainbow rule: a sine wave the spectrum flows through ─────────────────
|
|
182
|
+
A divider / flourish for section breaks and celebration moments. */
|
|
183
|
+
.whimsy-rule {
|
|
184
|
+
display: block;
|
|
185
|
+
width: 100%;
|
|
186
|
+
height: 22px;
|
|
187
|
+
border: 0;
|
|
188
|
+
margin: var(--s-lg) 0;
|
|
189
|
+
background-image: var(--whimsy-gradient);
|
|
190
|
+
background-size: 200% 100%;
|
|
191
|
+
background-repeat: repeat;
|
|
192
|
+
animation: whimsy-flow var(--whimsy-speed) linear infinite;
|
|
193
|
+
-webkit-mask-image: var(--whimsy-wave-mask);
|
|
194
|
+
mask-image: var(--whimsy-wave-mask);
|
|
195
|
+
-webkit-mask-repeat: repeat-x;
|
|
196
|
+
mask-repeat: repeat-x;
|
|
197
|
+
-webkit-mask-size: 64px 22px;
|
|
198
|
+
mask-size: 64px 22px;
|
|
199
|
+
-webkit-mask-position: center;
|
|
200
|
+
mask-position: center;
|
|
201
|
+
}
|
|
202
|
+
.whimsy-rule--sm { height: 16px; -webkit-mask-size: 48px 16px; mask-size: 48px 16px;
|
|
203
|
+
-webkit-mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='16' viewBox='0 0 48 16'><path d='M0 8 Q 6 1 12 8 T 24 8 T 36 8 T 48 8' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>");
|
|
204
|
+
mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='48' height='16' viewBox='0 0 48 16'><path d='M0 8 Q 6 1 12 8 T 24 8 T 36 8 T 48 8' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'/></svg>"); }
|
|
205
|
+
|
|
206
|
+
/* ─── Glow accent (optional) — a soft halo for hero whimsy moments ─────────
|
|
207
|
+
Use sparingly; pairs with .whimsy on a large wordmark. */
|
|
208
|
+
.whimsy--glow { filter: drop-shadow(0 0 10px oklch(var(--whimsy-l) var(--whimsy-c) 290 / 0.35)); }
|
|
209
|
+
|
|
210
|
+
/* ─── One-shot ignite state (Whimsy.watch / .celebrate toggle this) ────────
|
|
211
|
+
A trigger word matched, or a whimsical operation fired. */
|
|
212
|
+
.is-whimsical { /* host hook — JS adds .whimsy to the target itself */ }
|
|
213
|
+
|
|
214
|
+
/* ─── Per-effect toggles — flip any one layer off independently ────────────
|
|
215
|
+
Whimsy is layered: hue FLOW, the per-char BOB, and the optional GLOW halo.
|
|
216
|
+
Each switches off on its own; the others keep going. (Glow is itself opt-in
|
|
217
|
+
via .whimsy--glow, so "glow off" is just leaving the class off.) */
|
|
218
|
+
|
|
219
|
+
/* Flow off — freeze the hue on a held slice. Gradient stays, motion stops. */
|
|
220
|
+
.whimsy--no-flow.whimsy,
|
|
221
|
+
.whimsy--no-flow.whimsy-rule { animation: none; background-position: 30% 50%; }
|
|
222
|
+
.whimsy--no-flow.whimsy--wave > .whimsy-char {
|
|
223
|
+
animation-name: whimsy-bob; /* keep the bob, drop the flow */
|
|
224
|
+
animation-duration: var(--whimsy-bob);
|
|
225
|
+
animation-timing-function: var(--ease);
|
|
226
|
+
animation-iteration-count: infinite;
|
|
227
|
+
background-position: 30% 50%;
|
|
228
|
+
}
|
|
229
|
+
/* Bob off — wave chars hold still; the hue keeps flowing. */
|
|
230
|
+
.whimsy--no-bob.whimsy--wave > .whimsy-char {
|
|
231
|
+
animation-name: whimsy-flow; /* keep the flow, drop the bob */
|
|
232
|
+
animation-duration: var(--whimsy-speed);
|
|
233
|
+
animation-timing-function: linear;
|
|
234
|
+
animation-iteration-count: infinite;
|
|
235
|
+
transform: none;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/* ─── Settle — after a finite run, whimsy comes to rest ────────────────────
|
|
239
|
+
Whimsy.watch / .run / .scheduleSettle add one of these after N hue-cycles
|
|
240
|
+
so a moment doesn't loop forever. Two rests, both honoring the doctrine
|
|
241
|
+
that whimsy decorates and then gets out of the way:
|
|
242
|
+
|
|
243
|
+
.whimsy--settled Motion stops cold; a burnished gradient stays (static).
|
|
244
|
+
Same held slice as reduced-motion — a frozen rainbow.
|
|
245
|
+
.whimsy--glacial Motion "stops" perceptually: the hue drifts through one
|
|
246
|
+
full cycle over --whimsy-settle-speed (default 150s,
|
|
247
|
+
~2.5min), and ALL secondary motion (bob) is off. It
|
|
248
|
+
never quite stills, but you'd never catch it moving. */
|
|
249
|
+
|
|
250
|
+
.whimsy--settled.whimsy,
|
|
251
|
+
.whimsy--settled.whimsy-rule,
|
|
252
|
+
.whimsy--settled .whimsy-char {
|
|
253
|
+
animation: none !important;
|
|
254
|
+
background-position: 30% 50% !important;
|
|
255
|
+
}
|
|
256
|
+
.whimsy--settled .whimsy-char { transform: none !important; }
|
|
257
|
+
|
|
258
|
+
.whimsy--glacial.whimsy,
|
|
259
|
+
.whimsy--glacial.whimsy-rule,
|
|
260
|
+
.whimsy--glacial .whimsy-char {
|
|
261
|
+
animation-name: whimsy-flow !important;
|
|
262
|
+
animation-duration: var(--whimsy-settle-speed) !important;
|
|
263
|
+
animation-timing-function: linear !important;
|
|
264
|
+
animation-iteration-count: infinite !important;
|
|
265
|
+
}
|
|
266
|
+
.whimsy--glacial .whimsy-char { transform: none !important; }
|
|
267
|
+
|
|
268
|
+
/* ═══ Accessibility — flow stops, burnish stays ═══════════════════════════ */
|
|
269
|
+
@media (prefers-reduced-motion: reduce) {
|
|
270
|
+
.whimsy, .whimsy-char, .whimsy-rule {
|
|
271
|
+
animation: none !important;
|
|
272
|
+
background-position: 30% 50%; /* hold a pleasant slice of spectrum */
|
|
273
|
+
}
|
|
274
|
+
.whimsy--wave > .whimsy-char { transform: none !important; }
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
/* ─── Whimsy focus ring (opt-in · explicit request only) ───────────────────
|
|
279
|
+
A burnished ring that circles a focused control — delight layered OVER
|
|
280
|
+
the standard :focus-visible outline, never replacing it. The system
|
|
281
|
+
outline still guarantees WCAG focus visibility; this spins on top. It is
|
|
282
|
+
the ONE sanctioned whimsy use on an interactive control, and only when the
|
|
283
|
+
owner explicitly asks (see themes/CLAUDE.md § Whimsy). One per view.
|
|
284
|
+
Reduced-motion: the ring holds still (still visible); the outline still
|
|
285
|
+
does the a11y work. Reuses --whimsy-l/c/speed — no new tokens. */
|
|
286
|
+
@property --whimsy-spin { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
|
|
287
|
+
.whimsy-focus { position: relative; }
|
|
288
|
+
.whimsy-focus::after {
|
|
289
|
+
content: ""; position: absolute; inset: -5px; border-radius: inherit;
|
|
290
|
+
padding: 2px; pointer-events: none;
|
|
291
|
+
background: conic-gradient(from var(--whimsy-spin),
|
|
292
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 85),
|
|
293
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 200),
|
|
294
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 290),
|
|
295
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 340),
|
|
296
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 30),
|
|
297
|
+
oklch(var(--whimsy-l) var(--whimsy-c) 85));
|
|
298
|
+
-webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
|
|
299
|
+
mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
|
|
300
|
+
-webkit-mask-composite: xor; mask-composite: exclude;
|
|
301
|
+
opacity: 0; transition: opacity var(--dur-fast) var(--ease);
|
|
302
|
+
}
|
|
303
|
+
.whimsy-focus.whimsy--brand::after {
|
|
304
|
+
background: conic-gradient(from var(--whimsy-spin),
|
|
305
|
+
var(--accent), var(--attention), var(--brand-purple),
|
|
306
|
+
var(--steel), var(--success), var(--accent));
|
|
307
|
+
}
|
|
308
|
+
.whimsy-focus:focus-visible::after,
|
|
309
|
+
.whimsy-focus:hover::after {
|
|
310
|
+
opacity: 1;
|
|
311
|
+
animation: whimsy-spin var(--whimsy-speed) linear infinite;
|
|
312
|
+
}
|
|
313
|
+
@keyframes whimsy-spin { to { --whimsy-spin: 360deg; } }
|
|
314
|
+
@media (prefers-reduced-motion: reduce) {
|
|
315
|
+
.whimsy-focus:focus-visible::after,
|
|
316
|
+
.whimsy-focus:hover::after { animation: none; opacity: 1; }
|
|
317
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/* ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
+
ARTIFICER · Whimsy helper · v0.12.0
|
|
3
|
+
─────────────────────────────────────────────────────────────────────────
|
|
4
|
+
Tiny, dependency-free. Pairs with artificer-whimsy.css. Exposes window.Whimsy.
|
|
5
|
+
|
|
6
|
+
Whimsy.hydrate(root?) split [data-whimsy~="wave"] into bobbing
|
|
7
|
+
.whimsy-char spans (staggered sine wave).
|
|
8
|
+
Whimsy.watch(input, opts) ignite a target when a trigger word is
|
|
9
|
+
typed — the "ultrathink" gesture.
|
|
10
|
+
opts = { triggers:[…], target?, onIgnite?,
|
|
11
|
+
onClear?, loops?, settle? }
|
|
12
|
+
Whimsy.celebrate(el, ms?) one-shot: light el up for ms (default 2600)
|
|
13
|
+
then remove. For whimsical operations
|
|
14
|
+
(deploy succeeded, streak hit, etc).
|
|
15
|
+
Whimsy.run(el, opts) ignite el, then settle after opts.loops
|
|
16
|
+
hue-cycles. For long "thinking" states.
|
|
17
|
+
opts = { loops?, settle? }
|
|
18
|
+
Whimsy.scheduleSettle(el, n, mode) rest el after n loops; returns cancel().
|
|
19
|
+
Whimsy.settle(el, mode) / .unsettle(el) manual rest / wake.
|
|
20
|
+
mode: "static" (default) | "glacial".
|
|
21
|
+
Whimsy.ignite(el) / .clear(el) manual toggle.
|
|
22
|
+
|
|
23
|
+
Doctrine (see CLAUDE.md § Whimsy): opt-in, one whimsy moment per view,
|
|
24
|
+
never on errors / destructive actions / data. Reduced-motion is handled in
|
|
25
|
+
CSS — this file adds no motion the stylesheet can't switch off.
|
|
26
|
+
═══════════════════════════════════════════════════════════════════════════ */
|
|
27
|
+
(function () {
|
|
28
|
+
"use strict";
|
|
29
|
+
|
|
30
|
+
function igniteEl(el) { if (el) el.classList.add("whimsy"); }
|
|
31
|
+
function clearEl(el) { if (el) el.classList.remove("whimsy"); }
|
|
32
|
+
|
|
33
|
+
/* ── Settle ── flow for N hue-cycles, then come to rest ────────────────── */
|
|
34
|
+
|
|
35
|
+
/* One flow cycle, in seconds, read from the element's live --whimsy-speed. */
|
|
36
|
+
function flowSeconds(el) {
|
|
37
|
+
var s = (getComputedStyle(el).getPropertyValue("--whimsy-speed") || "7s").trim();
|
|
38
|
+
var n = parseFloat(s) || 7;
|
|
39
|
+
return /ms\s*$/.test(s) ? n / 1000 : n;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function unsettle(el) {
|
|
43
|
+
if (el) el.classList.remove("whimsy--settled", "whimsy--glacial");
|
|
44
|
+
}
|
|
45
|
+
function settle(el, mode) {
|
|
46
|
+
if (!el) return;
|
|
47
|
+
unsettle(el);
|
|
48
|
+
el.classList.add(mode === "glacial" ? "whimsy--glacial" : "whimsy--settled");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Rest `el` after `loops` hue-cycles. loops <= 0 / Infinity = never settle.
|
|
52
|
+
mode: "static" (default) | "glacial". Returns a cancel() fn. */
|
|
53
|
+
function scheduleSettle(el, loops, mode) {
|
|
54
|
+
if (!el || !loops || loops === Infinity || loops <= 0) return function () {};
|
|
55
|
+
var id = window.setTimeout(function () {
|
|
56
|
+
settle(el, mode);
|
|
57
|
+
}, flowSeconds(el) * loops * 1000);
|
|
58
|
+
return function cancel() { window.clearTimeout(id); };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/* Ignite `el` and (optionally) settle it after a finite run. For whimsical
|
|
62
|
+
operations and long "thinking" states without an input to watch.
|
|
63
|
+
opts = { loops?, settle? }. Returns a cancel() fn for the settle timer. */
|
|
64
|
+
function run(el, opts) {
|
|
65
|
+
opts = opts || {};
|
|
66
|
+
unsettle(el);
|
|
67
|
+
igniteEl(el);
|
|
68
|
+
return scheduleSettle(el, opts.loops, opts.settle);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Split an element's text into staggered .whimsy-char spans so the sine
|
|
72
|
+
bob travels across the word. Idempotent — re-running skips done nodes. */
|
|
73
|
+
function splitWave(el) {
|
|
74
|
+
if (!el || el.dataset.whimsyHydrated === "1") return;
|
|
75
|
+
var text = el.textContent;
|
|
76
|
+
el.textContent = "";
|
|
77
|
+
var n = 0;
|
|
78
|
+
for (var i = 0; i < text.length; i++) {
|
|
79
|
+
var ch = text[i];
|
|
80
|
+
var span = document.createElement("span");
|
|
81
|
+
span.className = "whimsy-char";
|
|
82
|
+
span.textContent = ch;
|
|
83
|
+
// stagger the bob + hue so the wave reads as travelling, not pulsing
|
|
84
|
+
span.style.setProperty("--d", (n * -0.09).toFixed(2) + "s");
|
|
85
|
+
el.appendChild(span);
|
|
86
|
+
if (ch !== " ") n++;
|
|
87
|
+
}
|
|
88
|
+
el.dataset.whimsyHydrated = "1";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function hydrate(root) {
|
|
92
|
+
root = root || document;
|
|
93
|
+
var waves = root.querySelectorAll('[data-whimsy~="wave"]');
|
|
94
|
+
for (var i = 0; i < waves.length; i++) {
|
|
95
|
+
waves[i].classList.add("whimsy", "whimsy--wave");
|
|
96
|
+
splitWave(waves[i]);
|
|
97
|
+
}
|
|
98
|
+
// plain [data-whimsy] (no "wave") just gets the flowing gradient
|
|
99
|
+
var plain = root.querySelectorAll('[data-whimsy=""], [data-whimsy="whimsy"]');
|
|
100
|
+
for (var j = 0; j < plain.length; j++) plain[j].classList.add("whimsy");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/* The "ultrathink" gesture. Watch a text input; when its value contains any
|
|
104
|
+
trigger word, ignite the target (default: a sibling [data-whimsy-target],
|
|
105
|
+
else the input itself via .is-whimsical). Fires onIgnite/onClear once per
|
|
106
|
+
edge so callers can run a whimsical operation. */
|
|
107
|
+
function watch(input, opts) {
|
|
108
|
+
if (!input) return function () {};
|
|
109
|
+
opts = opts || {};
|
|
110
|
+
var triggers = (opts.triggers || ["ultrathink", "ultracode"])
|
|
111
|
+
.map(function (t) { return String(t).toLowerCase(); });
|
|
112
|
+
var target = opts.target ||
|
|
113
|
+
(input.closest ? (input.closest("[data-whimsy-scope]") || document)
|
|
114
|
+
.querySelector("[data-whimsy-target]") : null) ||
|
|
115
|
+
input;
|
|
116
|
+
var lit = false;
|
|
117
|
+
var cancelSettle = null;
|
|
118
|
+
|
|
119
|
+
function check() {
|
|
120
|
+
var v = (input.value || input.textContent || "").toLowerCase();
|
|
121
|
+
var hit = triggers.some(function (t) { return v.indexOf(t) !== -1; });
|
|
122
|
+
if (hit && !lit) {
|
|
123
|
+
lit = true;
|
|
124
|
+
igniteEl(target);
|
|
125
|
+
target.classList.add("is-whimsical");
|
|
126
|
+
if (opts.loops) cancelSettle = scheduleSettle(target, opts.loops, opts.settle);
|
|
127
|
+
if (opts.onIgnite) opts.onIgnite(target);
|
|
128
|
+
} else if (!hit && lit) {
|
|
129
|
+
lit = false;
|
|
130
|
+
if (cancelSettle) { cancelSettle(); cancelSettle = null; }
|
|
131
|
+
unsettle(target);
|
|
132
|
+
clearEl(target);
|
|
133
|
+
target.classList.remove("is-whimsical");
|
|
134
|
+
if (opts.onClear) opts.onClear(target);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
input.addEventListener("input", check);
|
|
138
|
+
check();
|
|
139
|
+
return function off() { input.removeEventListener("input", check); };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/* One-shot whimsy for an operation that just succeeded. Auto-clears. */
|
|
143
|
+
function celebrate(el, ms) {
|
|
144
|
+
if (!el) return;
|
|
145
|
+
igniteEl(el);
|
|
146
|
+
var dur = typeof ms === "number" ? ms : 2600;
|
|
147
|
+
window.setTimeout(function () { clearEl(el); }, dur);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// SPA lifecycle — auto-hydrate nodes inserted after first paint. Returns a
|
|
151
|
+
// disconnect fn. Idempotent guards make the re-scan cheap (done nodes skip).
|
|
152
|
+
function observe(root) {
|
|
153
|
+
root = root || document.body;
|
|
154
|
+
hydrate(root);
|
|
155
|
+
if (typeof MutationObserver === 'undefined') return function () {};
|
|
156
|
+
var scheduled = false;
|
|
157
|
+
var mo = new MutationObserver(function () {
|
|
158
|
+
if (scheduled) return;
|
|
159
|
+
scheduled = true;
|
|
160
|
+
(window.requestAnimationFrame || window.setTimeout)(function () { scheduled = false; hydrate(root); }, 0);
|
|
161
|
+
});
|
|
162
|
+
mo.observe(root, { childList: true, subtree: true });
|
|
163
|
+
return function () { mo.disconnect(); };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
window.Whimsy = {
|
|
167
|
+
hydrate: hydrate,
|
|
168
|
+
observe: observe,
|
|
169
|
+
watch: watch,
|
|
170
|
+
celebrate: celebrate,
|
|
171
|
+
run: run,
|
|
172
|
+
settle: settle,
|
|
173
|
+
unsettle: unsettle,
|
|
174
|
+
scheduleSettle: scheduleSettle,
|
|
175
|
+
ignite: igniteEl,
|
|
176
|
+
clear: clearEl
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
if (document.readyState === "loading") {
|
|
180
|
+
document.addEventListener("DOMContentLoaded", function () { hydrate(); });
|
|
181
|
+
} else {
|
|
182
|
+
hydrate();
|
|
183
|
+
}
|
|
184
|
+
})();
|