oficina / docs Public

Docs: a press throws a few sparks from the light; a hovered page comes forward a little larger

Paul, on the preview. brand/pointer.js: a pointerdown on a lit control
or a rastrillo button throws seven specks from where it landed, in a
fixed layer over the page, each animated once and removed (mouse and
pen only; off under reduced motion and forced colours). The shelf's
hovered page lifts 6px and scales to 1.05 as it leans.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev e2c1039a4dff702b840b4287240d69d93b727994 parent cffc692
3 files changed, +65 −4
  • internal/docs/brand/light.css +21 −0
  • internal/docs/brand/pointer.js +39 −1
  • internal/docs/views/list.html +5 −3

CI passed — run details

diff --git a/internal/docs/brand/light.css b/internal/docs/brand/light.css
index 9554c77..bf1b633 100644
--- a/internal/docs/brand/light.css
+++ b/internal/docs/brand/light.css
@@ -19,3 +19,24 @@
background-image: radial-gradient(120px circle at var(--rst-mx, 50%) var(--rst-my, 50%), var(--docs-light-tint), transparent 70%);
}
}
+
+/* The sparks a press throws (pointer.js): a layer over everything that
+ takes no pointer, and specks of the accent's light with a white
+ core, glowing a little. Sized and coloured here, moved there. */
+[docs-sparks] {
+ position: fixed;
+ inset: 0;
+ z-index: 2147483647;
+ pointer-events: none;
+ overflow: hidden;
+}
+[docs-sparks] > span {
+ position: absolute;
+ inline-size: 5px;
+ block-size: 5px;
+ border-radius: 50%;
+ background: radial-gradient(circle, #ffffff 0 35%, color-mix(in srgb, var(--rst-accent) 55%, #ffffff) 70%);
+ box-shadow:
+ 0 0 4px 1px rgb(255 255 255 / 0.7),
+ 0 0 10px 2px color-mix(in srgb, var(--rst-accent) 55%, transparent);
+}
diff --git a/internal/docs/brand/pointer.js b/internal/docs/brand/pointer.js
index e89cd4c..e56308a 100644
--- a/internal/docs/brand/pointer.js
+++ b/internal/docs/brand/pointer.js
@@ -12,6 +12,12 @@
pointer leaves, and every property has a default in the stylesheet,
so deleting this file and its tag leaves the still design.
+ A press throws a few sparks from where it landed, out of the same
+ light: a handful of specks in a layer of their own over the page
+ (so no control's overflow clips them and no layout moves), each
+ animated once with the Web Animations API and removed when it ends.
+ Pressing a rastrillo button sparks too.
+
It never runs for touch, under reduced motion or forced colours, or
without a hovering pointer; one animation frame per move at most. */
(function () {
@@ -21,7 +27,9 @@
var PROPS = ["--rst-mx", "--rst-my", "--docs-tx", "--docs-ty"];
var quiet = [matchMedia("(prefers-reduced-motion: reduce)"), matchMedia("(forced-colors: active)")];
var hover = matchMedia("(hover: hover)");
- var lit = null, pending = null, raf = 0, listening = false;
+ var PRESSED = LIT + ",[rst-btn]";
+ var SPARKS = 7;
+ var lit = null, pending = null, raf = 0, listening = false, layer = null;
function clear() {
if (!lit) return;
@@ -53,6 +61,34 @@
function out(e) {
if (!e.relatedTarget) clear();
}
+ function spark(e) {
+ if (e.button !== 0 || (e.pointerType && e.pointerType !== "mouse" && e.pointerType !== "pen")) return;
+ var el = e.target && e.target.closest ? e.target.closest(PRESSED) : null;
+ if (!el || el.disabled || !document.body.animate) return;
+ if (!layer || !layer.isConnected) {
+ layer = document.createElement("div");
+ layer.setAttribute("docs-sparks", "");
+ layer.setAttribute("aria-hidden", "true");
+ document.body.appendChild(layer);
+ }
+ for (var i = 0; i < SPARKS; i++) {
+ var a = (i / SPARKS) * Math.PI * 2 + Math.random() * 0.7;
+ var d = 16 + Math.random() * 16;
+ var dot = document.createElement("span");
+ dot.style.left = e.clientX + "px";
+ dot.style.top = e.clientY + "px";
+ layer.appendChild(dot);
+ var dx = (Math.cos(a) * d).toFixed(1), dy = (Math.sin(a) * d).toFixed(1);
+ dot.animate([
+ { transform: "translate(-50%, -50%) scale(1)", opacity: 1 },
+ { transform: "translate(calc(-50% + " + dx * 0.55 + "px), calc(-50% + " + dy * 0.55 + "px)) scale(0.9)", opacity: 1, offset: 0.35 },
+ { transform: "translate(calc(-50% + " + dx + "px), calc(-50% + " + dy + "px)) scale(0.2)", opacity: 0 },
+ ], { duration: 480 + Math.random() * 220, easing: "cubic-bezier(.2, .65, .3, 1)" }).onfinish = remove(dot);
+ }
+ }
+ function remove(dot) {
+ return function () { dot.remove(); };
+ }
function sync() {
var want = hover.matches && !quiet[0].matches && !quiet[1].matches;
if (want === listening) return;
@@ -60,9 +96,11 @@
if (want) {
document.addEventListener("pointermove", move, { passive: true });
document.addEventListener("pointerout", out, { passive: true });
+ document.addEventListener("pointerdown", spark, { passive: true });
} else {
document.removeEventListener("pointermove", move);
document.removeEventListener("pointerout", out);
+ document.removeEventListener("pointerdown", spark);
clear();
}
}
diff --git a/internal/docs/views/list.html b/internal/docs/views/list.html
index f9bdda9..ec3972a 100644
--- a/internal/docs/views/list.html
+++ b/internal/docs/views/list.html
@@ -322,7 +322,8 @@
0 10px 24px -12px light-dark(rgb(23 32 60 / 0.28), rgb(0 0 0 / 0.7));
transition: transform 180ms cubic-bezier(.2, .7, .2, 1), box-shadow 180ms ease;
}
- /* Picking a page up: it lifts and takes the accent's edge, and while
+ /* Picking a page up: it lifts toward the reader, a little larger,
+ and takes the accent's edge, and while
the pointer is over it, it leans a few degrees toward it and a
pool of light follows it across the paper (brand/pointer.js writes
--docs-tx/--docs-ty and --rst-mx/--rst-my; the transform's
@@ -346,9 +347,10 @@
}
[docs-tile]:hover [docs-thumb],
[docs-tile]:focus-visible [docs-thumb] {
- transform: translateY(-4px) perspective(800px)
+ transform: translateY(-6px) perspective(800px)
rotateX(calc(var(--docs-ty, 0) * -4deg))
- rotateY(calc(var(--docs-tx, 0) * 5deg));
+ rotateY(calc(var(--docs-tx, 0) * 5deg))
+ scale(1.05);
box-shadow:
0 0 0 1.5px var(--rst-accent),
0 2px 4px rgb(23 32 60 / 0.08),