oficina / docs Public

Docs: a press sends out a ripple of light instead of sparks

Paul: more subtle and bigger, more ripple than sparks. One 260px ring
of the accent's light, faint fill inside, grows from the press and
fades over 680ms (brand/pointer.js, brand/light.css); same layer,
same conditions as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev 5c7422ce03476ad8a3fc9f1be28bf447eac1c666 parent 1b5113b
2 files changed, +33 −35
  • internal/docs/brand/light.css +14 −11
  • internal/docs/brand/pointer.js +19 −24

CI passed — run details

diff --git a/internal/docs/brand/light.css b/internal/docs/brand/light.css
index bf1b633..63044c0 100644
--- a/internal/docs/brand/light.css
+++ b/internal/docs/brand/light.css
@@ -20,23 +20,26 @@
}
}
-/* 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] {
+/* The ripple a press sends out (pointer.js): a layer over everything
+ that takes no pointer, and one ring of the accent's light with a
+ faint fill inside it, soft at both edges. Sized and coloured here,
+ grown and faded there. */
+[docs-ripples] {
position: fixed;
inset: 0;
z-index: 2147483647;
pointer-events: none;
overflow: hidden;
}
-[docs-sparks] > span {
+[docs-ripples] > span {
position: absolute;
- inline-size: 5px;
- block-size: 5px;
+ inline-size: 260px;
+ block-size: 260px;
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);
+ background: radial-gradient(circle closest-side,
+ color-mix(in srgb, var(--rst-accent) 7%, transparent) 0%,
+ color-mix(in srgb, var(--rst-accent) 5%, transparent) 55%,
+ color-mix(in srgb, var(--rst-accent) 22%, transparent) 82%,
+ transparent 100%);
+ will-change: transform, opacity;
}
diff --git a/internal/docs/brand/pointer.js b/internal/docs/brand/pointer.js
index e56308a..fc8df26 100644
--- a/internal/docs/brand/pointer.js
+++ b/internal/docs/brand/pointer.js
@@ -12,11 +12,11 @@
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.
+ A press sends a ripple of the same light out from where it landed:
+ one wide, faint ring that spreads past the control and fades, in a
+ layer of its own over the page (so no control's overflow clips it
+ and no layout moves), animated once with the Web Animations API and
+ removed when it ends. Pressing a rastrillo button ripples too.
It never runs for touch, under reduced motion or forced colours, or
without a hovering pointer; one animation frame per move at most. */
@@ -28,7 +28,7 @@
var quiet = [matchMedia("(prefers-reduced-motion: reduce)"), matchMedia("(forced-colors: active)")];
var hover = matchMedia("(hover: hover)");
var PRESSED = LIT + ",[rst-btn]";
- var SPARKS = 7;
+ var RIPPLE = 260; // px across at its widest
var lit = null, pending = null, raf = 0, listening = false, layer = null;
function clear() {
@@ -61,30 +61,25 @@
function out(e) {
if (!e.relatedTarget) clear();
}
- function spark(e) {
+ function ripple(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("docs-ripples", "");
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);
- }
+ var ring = document.createElement("span");
+ ring.style.left = e.clientX - RIPPLE / 2 + "px";
+ ring.style.top = e.clientY - RIPPLE / 2 + "px";
+ layer.appendChild(ring);
+ ring.animate([
+ { transform: "scale(0.08)", opacity: 0.9 },
+ { transform: "scale(0.6)", opacity: 0.55, offset: 0.4 },
+ { transform: "scale(1)", opacity: 0 },
+ ], { duration: 680, easing: "cubic-bezier(.2, .6, .25, 1)" }).onfinish = remove(ring);
}
function remove(dot) {
return function () { dot.remove(); };
@@ -96,11 +91,11 @@
if (want) {
document.addEventListener("pointermove", move, { passive: true });
document.addEventListener("pointerout", out, { passive: true });
- document.addEventListener("pointerdown", spark, { passive: true });
+ document.addEventListener("pointerdown", ripple, { passive: true });
} else {
document.removeEventListener("pointermove", move);
document.removeEventListener("pointerout", out);
- document.removeEventListener("pointerdown", spark);
+ document.removeEventListener("pointerdown", ripple);
clear();
}
}