Docs: the press ripple stays inside the pressed control, and is much fainter
Paul: subtler, and within the clicked element's bounds. pointer.js lays a frame over the pressed control (its rect and border radius; a shelf page's paper) that clips one ring growing to the far corner over 560ms. Accent at 3-10% on light controls, white at 5-16% on filled buttons.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+47
−21
internal/docs/brand/light.css+19 −8internal/docs/brand/pointer.js+28 −13
CI cancelled — superseded by a newer push — run details
diff --git a/internal/docs/brand/light.css b/internal/docs/brand/light.css| index 63044c0..7aced4b 100644 |
| --- a/internal/docs/brand/light.css |
| +++ b/internal/docs/brand/light.css |
| @@ -21,9 +21,9 @@ |
| } |
| /* 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. */ |
| + that takes no pointer; in it, a frame laid over the pressed control |
| + that clips to its shape, and in that, one faint ring of the accent's |
| + light, soft at both edges. Sized and placed there, coloured here. */ |
| [docs-ripples] { |
| position: fixed; |
| inset: 0; |
| @@ -33,13 +33,24 @@ |
| } |
| [docs-ripples] > span { |
| position: absolute; |
| - inline-size: 260px; |
| - block-size: 260px; |
| + overflow: hidden; |
| +} |
| +[docs-ripples] > span > i { |
| + position: absolute; |
| border-radius: 50%; |
| 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%, |
| + color-mix(in srgb, var(--rst-accent) 3%, transparent) 0%, |
| + color-mix(in srgb, var(--rst-accent) 3%, transparent) 60%, |
| + color-mix(in srgb, var(--rst-accent) 10%, transparent) 85%, |
| transparent 100%); |
| will-change: transform, opacity; |
| } |
| +/* On a filled button the accent's own light would vanish into it: the |
| + ripple there is white, as faintly. */ |
| +[docs-ripples] > span[data-on="fill"] > i { |
| + background: radial-gradient(circle closest-side, |
| + rgb(255 255 255 / 0.05) 0%, |
| + rgb(255 255 255 / 0.05) 60%, |
| + rgb(255 255 255 / 0.16) 85%, |
| + transparent 100%); |
| +} |
diff --git a/internal/docs/brand/pointer.js b/internal/docs/brand/pointer.js| index fc8df26..8879e25 100644 |
| --- a/internal/docs/brand/pointer.js |
| +++ b/internal/docs/brand/pointer.js |
| @@ -12,11 +12,14 @@ |
| pointer leaves, and every property has a default in the stylesheet, |
| so deleting this file and its tag leaves the still design. |
| - 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. |
| + A press sends a faint ripple of the same light out from where it |
| + landed, kept inside the control: a frame laid exactly over it, with |
| + its rounded corners, clips a ring that grows to the control's far |
| + corner and fades. The frame sits in a layer of its own over the page, |
| + so the control's DOM and layout are never touched; it is animated |
| + once with the Web Animations API and removed when it ends. On a shelf |
| + page the ripple stays on the paper. 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 +31,6 @@ |
| var quiet = [matchMedia("(prefers-reduced-motion: reduce)"), matchMedia("(forced-colors: active)")]; |
| var hover = matchMedia("(hover: hover)"); |
| var PRESSED = LIT + ",[rst-btn]"; |
| - var RIPPLE = 260; // px across at its widest |
| var lit = null, pending = null, raf = 0, listening = false, layer = null; |
| function clear() { |
| @@ -65,21 +67,34 @@ |
| 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; |
| + var surface = el.hasAttribute("docs-tile") ? el.querySelector("[docs-thumb]") || el : el; |
| + var r = surface.getBoundingClientRect(); |
| + if (!r.width || !r.height) return; |
| if (!layer || !layer.isConnected) { |
| layer = document.createElement("div"); |
| layer.setAttribute("docs-ripples", ""); |
| layer.setAttribute("aria-hidden", "true"); |
| document.body.appendChild(layer); |
| } |
| - var ring = document.createElement("span"); |
| - ring.style.left = e.clientX - RIPPLE / 2 + "px"; |
| - ring.style.top = e.clientY - RIPPLE / 2 + "px"; |
| - layer.appendChild(ring); |
| + var frame = document.createElement("span"); |
| + frame.style.left = r.left + "px"; |
| + frame.style.top = r.top + "px"; |
| + frame.style.width = r.width + "px"; |
| + frame.style.height = r.height + "px"; |
| + frame.style.borderRadius = getComputedStyle(surface).borderRadius; |
| + if (el.matches('[rst-btn~="primary"],[rst-btn~="danger"]')) frame.setAttribute("data-on", "fill"); |
| + var x = e.clientX - r.left, y = e.clientY - r.top; |
| + var reach = Math.hypot(Math.max(x, r.width - x), Math.max(y, r.height - y)); |
| + var ring = document.createElement("i"); |
| + ring.style.left = x - reach + "px"; |
| + ring.style.top = y - reach + "px"; |
| + ring.style.width = ring.style.height = reach * 2 + "px"; |
| + frame.appendChild(ring); |
| + layer.appendChild(frame); |
| ring.animate([ |
| - { transform: "scale(0.08)", opacity: 0.9 }, |
| - { transform: "scale(0.6)", opacity: 0.55, offset: 0.4 }, |
| + { transform: "scale(0.1)", opacity: 1 }, |
| { transform: "scale(1)", opacity: 0 }, |
| - ], { duration: 680, easing: "cubic-bezier(.2, .6, .25, 1)" }).onfinish = remove(ring); |
| + ], { duration: 560, easing: "cubic-bezier(.2, .6, .3, 1)" }).onfinish = remove(frame); |
| } |
| function remove(dot) { |
| return function () { dot.remove(); }; |