oficina / slides Public

Slides: the light, as opt-in brand/light.css and brand/pointer.js

Docs' design/richer-ui light, ported at its final strengths ("a press is
press in and bloom, with no dark mark"; "every glow much fainter in dark
mode"), on Slides' accent (hue 56) and its own opt-in attributes so the
deck list and the editor can both use it:

  [slides-lit]    a pool of the accent's light follows the pointer, and
                  a press blooms where it landed
  [slides-press]  gives under a press and springs back
  [slides-lift]   a tile whose [slides-lift-face] lifts, leans toward the
                  pointer, takes the accent's edge and carries the light
  [rst-btn]       press in and bloom (white on a filled button); this
                  rastrillo has no --rst-press of its own, so it rides here

pointer.js writes --rst-mx/--rst-my, --slides-tx/--slides-ty and
--rst-px/--rst-py on the one lit element under a mouse or pen, never for
touch, reduced motion or forced colours. Every value has a default, so
without the script the page is the still design. Nothing links these yet.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev c9bbb2416bb7521e6d32ff7ea66142c0cc4f5b66 parent af4f47e
2 files changed, +249 −0
  • internal/slides/static/brand/light.css +154 −0
  • internal/slides/static/brand/pointer.js +95 −0
diff --git a/internal/slides/static/brand/light.css b/internal/slides/static/brand/light.css
new file mode 100644
index 0000000..84e5031
--- /dev/null
+++ b/internal/slides/static/brand/light.css
@@ -0,0 +1,154 @@
+/* light.css — the light, for Slides: Docs' brand/light.css (design/
+ richer-ui, at "a press is press in and bloom, with no dark mark" and
+ "every glow much fainter in dark mode"), on Slides' own attributes and
+ accent. A page opts in by linking this and brand/pointer.js; nothing
+ here does anything to a page that does not.
+
+ The vocabulary, all opt-in, all generic:
+
+ [slides-lit] a surface a pool of the accent's light follows the
+ pointer across (a list row, a menu item, a panel),
+ and a press blooms on.
+ [slides-press] a control that gives a little under a press and
+ springs back, overshooting slightly. Its scale is
+ --slides-press-scale (0.965 by default).
+ [slides-lift] a tile whose [slides-lift-face] (its picture) is
+ picked up: it lifts toward the reader a little
+ larger, takes the accent's edge, leans a few degrees
+ toward the pointer, carries the light, and gives
+ under a press.
+ [rst-btn] rastrillo's buttons on such a page press in and
+ bloom too: white on a filled button. This rastrillo
+ has no press value or face layer of its own (Docs'
+ newer one does), so the bloom rides here.
+
+ Positions come from pointer.js: --rst-mx/--rst-my (the pointer, in
+ the element's own pixels: rastrillo light.js's names, so one
+ vocabulary lights both), --slides-tx/--slides-ty (the same, -1 to 1
+ across the element, for the lean), and --rst-px/--rst-py (where a
+ press landed). Every one has a default here, so with no script the
+ page is the still design. Hover light only under (hover: hover), so a
+ touch screen never holds a light where a finger lifted; motion is
+ dropped under reduced motion, where the edge alone says the same
+ thing.
+
+ In dark every glow is far fainter: light on a dark surface reads much
+ brighter than on a light one (Paul, 2026-11-10). */
+:root {
+ /* The bloom's light, as an rgb triplet so its alpha can follow the
+ press: rgb(var() / calc()) works in every engine, where a
+ color-mix() whose percentage carried calc(var()) blanked Safari.
+ Slides' accent (estilo theme/apps.go, hue 56), light and dark. */
+ --slides-bloom: 146 75 0;
+ /* How strong every bloom is: 1 in light, much less in dark. */
+ --slides-bloom-k: 1;
+ /* The pool of light a pointer casts on what it is over. */
+ --slides-light-tint: light-dark(color-mix(in srgb, var(--rst-accent) 10%, transparent), color-mix(in srgb, var(--rst-accent) 6%, transparent));
+}
+/* Dark, a triplet, so a selector and a media query rather than
+ light-dark(), which takes only colours. */
+:root[data-theme="dark"] { --slides-bloom: 235 156 98; --slides-bloom-k: 0.4; }
+@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --slides-bloom: 235 156 98; --slides-bloom-k: 0.4; } }
+
+/* A press is press in and bloom: the control gives under the press and
+ springs back on release; the light flares where the press landed,
+ swelling while it is held and fading after release. --slides-press is
+ 1 while held, at once, and falls to 0 over 0.7s, which a registered
+ number can transition; the flare's size and alpha both ride it.
+ Inherited, so a lifted tile's face reads its tile's press. */
+@property --slides-press {
+ syntax: "<number>";
+ inherits: true;
+ initial-value: 0;
+}
+:root {
+ --slides-flare: radial-gradient(calc(24px + var(--slides-press, 0) * 76px) circle at var(--rst-px, 50%) var(--rst-py, 50%), rgb(var(--slides-bloom) / calc(var(--slides-press, 0) * 0.16 * var(--slides-bloom-k))), transparent 72%);
+ --slides-flare-on-fill: radial-gradient(calc(24px + var(--slides-press, 0) * 96px) circle at var(--rst-px, 50%) var(--rst-py, 50%), rgb(255 255 255 / calc(var(--slides-press, 0) * 0.22 * var(--slides-bloom-k))), transparent 72%);
+ --slides-release: --slides-press 0.7s cubic-bezier(0.2, 0.6, 0.3, 1), scale 0.42s cubic-bezier(0.3, 1.6, 0.5, 1);
+}
+
+[slides-lit],
+[slides-press],
+[slides-lift],
+[rst-btn] {
+ transition: var(--slides-release), background-color 150ms ease, border-color 150ms ease, color 150ms ease;
+}
+[slides-lit]:active,
+[slides-press]:active:not(:disabled):not([aria-disabled="true"]),
+[slides-lift]:active,
+[rst-btn]:active:not(:disabled):not([aria-busy="true"]) {
+ --slides-press: 1;
+ transition: scale 90ms ease-out;
+}
+[slides-press]:active:not(:disabled):not([aria-disabled="true"]) { scale: var(--slides-press-scale, 0.965); }
+[rst-btn]:active:not(:disabled):not([aria-busy="true"]) { scale: 0.965; }
+[slides-lit] { background-image: var(--slides-flare); }
+[slides-press]:not([slides-lit]),
+[rst-btn] { background-image: var(--slides-flare); }
+[rst-btn~="primary"],
+[rst-btn~="danger"] { background-image: var(--slides-flare-on-fill); }
+
+@media (hover: hover) {
+ /* The second selector is a rastrillo row: its own hover fill is a
+ background shorthand under a :has() that outweighs the first, and
+ would take the light away exactly while the pointer is on it. */
+ [slides-lit]:hover,
+ [rst-row][slides-lit]:has(> [rst-row-main] > a):hover {
+ background-image: var(--slides-flare), radial-gradient(var(--slides-light-size, 280px) circle at var(--rst-mx, 50%) var(--rst-my, 50%), var(--slides-light-tint), transparent 70%);
+ }
+}
+
+/* The lifted tile. The face is what moves: the tile itself (a link,
+ title and all) stays where it is, so its hit area never slides out
+ from under the pointer. The lean's transition is what makes it follow
+ the pointer rather than jump. */
+[slides-lift] [slides-lift-face] {
+ position: relative;
+ transition: transform 180ms cubic-bezier(.2, .7, .2, 1), box-shadow 180ms ease, scale 0.42s cubic-bezier(0.3, 1.6, 0.5, 1);
+}
+[slides-lift] [slides-lift-face]::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ border-radius: inherit;
+ background:
+ var(--slides-flare),
+ radial-gradient(180px circle at var(--rst-mx, 50%) var(--rst-my, 0%), var(--slides-light-tint), transparent 70%);
+ opacity: 0;
+ transition: opacity 200ms ease;
+ pointer-events: none;
+}
+[slides-lift]:active [slides-lift-face]::after {
+ opacity: 1;
+}
+[slides-lift]:hover [slides-lift-face],
+[slides-lift]:focus-visible [slides-lift-face] {
+ transform: translateY(-6px) perspective(800px)
+ rotateX(calc(var(--slides-ty, 0) * -4deg))
+ rotateY(calc(var(--slides-tx, 0) * 5deg))
+ scale(1.04);
+ box-shadow:
+ 0 0 0 1.5px var(--rst-accent),
+ 0 2px 4px rgb(23 32 60 / 0.08),
+ 0 18px 32px -14px light-dark(rgb(23 32 60 / 0.35), rgb(0 0 0 / 0.8));
+}
+[slides-lift]:active [slides-lift-face] {
+ scale: 0.97;
+ transition: transform 180ms cubic-bezier(.2, .7, .2, 1), box-shadow 180ms ease, scale 90ms ease-out;
+}
+@media (hover: hover) {
+ [slides-lift]:hover [slides-lift-face]::after {
+ opacity: 1;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ [slides-press]:active, [rst-btn]:active, [slides-lift]:active [slides-lift-face] { scale: none; }
+ [slides-lift] [slides-lift-face] { transition: none; }
+ [slides-lift]:hover [slides-lift-face],
+ [slides-lift]:focus-visible [slides-lift-face] { transform: none; }
+}
+@media (forced-colors: active) {
+ [slides-lit], [slides-press], [rst-btn] { background-image: none; }
+ [slides-lift] [slides-lift-face]::after { content: none; }
+}
diff --git a/internal/slides/static/brand/pointer.js b/internal/slides/static/brand/pointer.js
new file mode 100644
index 0000000..d8404b3
--- /dev/null
+++ b/internal/slides/static/brand/pointer.js
@@ -0,0 +1,95 @@
+/* pointer.js — Slides' half of the light: Docs' brand/pointer.js
+ (design/richer-ui), on Slides' opt-in attributes. brand/light.css
+ says what each attribute does; this only tells it where the pointer
+ is.
+
+ What it writes, on the one lit element under the pointer, and
+ nothing else: --rst-mx and --rst-my, the pointer in the element's own
+ pixels (rastrillo light.js's names and units, so one stylesheet
+ vocabulary lights both), and --slides-tx and --slides-ty, the same
+ position from -1 to 1 across the element, for a lifted tile's lean.
+ It clears them when the pointer leaves. A press writes where it
+ landed as --rst-px and --rst-py on the control, light.js's names
+ again, which the bloom is centred on. Every property has a default in
+ the stylesheet, so deleting this file and its tag leaves the still
+ design.
+
+ Lit is [slides-lit], [slides-lift], [slides-press] and [rst-btn],
+ and any element that is lit through a parent is lit as that parent:
+ it takes the nearest. It never runs for touch, under reduced motion
+ or forced colours, or without a hovering pointer; one animation
+ frame per move at most. */
+(function () {
+ "use strict";
+ if (!window.matchMedia || !window.requestAnimationFrame) return;
+ var LIT = "[slides-lit],[slides-lift],[slides-press],[rst-btn]";
+ var PROPS = ["--rst-mx", "--rst-my", "--slides-tx", "--slides-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;
+
+ function mouse(e) {
+ return !e.pointerType || e.pointerType === "mouse" || e.pointerType === "pen";
+ }
+ function litFrom(target) {
+ return target && target.closest ? target.closest(LIT) : null;
+ }
+ function clear() {
+ if (!lit) return;
+ for (var i = 0; i < PROPS.length; i++) lit.style.removeProperty(PROPS[i]);
+ lit = null;
+ }
+ function step() {
+ raf = 0;
+ var e = pending;
+ pending = null;
+ if (!e) return;
+ var el = litFrom(e.target);
+ if (el !== lit) clear();
+ if (!el) return;
+ lit = el;
+ var r = el.getBoundingClientRect();
+ if (!r.width || !r.height) return;
+ var x = e.clientX - r.left, y = e.clientY - r.top;
+ el.style.setProperty("--rst-mx", x.toFixed(0) + "px");
+ el.style.setProperty("--rst-my", y.toFixed(0) + "px");
+ el.style.setProperty("--slides-tx", Math.max(-1, Math.min(1, (x / r.width) * 2 - 1)).toFixed(3));
+ el.style.setProperty("--slides-ty", Math.max(-1, Math.min(1, (y / r.height) * 2 - 1)).toFixed(3));
+ }
+ function move(e) {
+ if (!mouse(e)) return;
+ pending = e;
+ if (!raf) raf = requestAnimationFrame(step);
+ }
+ function out(e) {
+ if (!e.relatedTarget) clear();
+ }
+ function press(e) {
+ if (e.button !== 0 || !mouse(e)) return;
+ var el = litFrom(e.target);
+ if (!el || el.disabled) return;
+ var r = el.getBoundingClientRect();
+ el.style.setProperty("--rst-px", (e.clientX - r.left).toFixed(0) + "px");
+ el.style.setProperty("--rst-py", (e.clientY - r.top).toFixed(0) + "px");
+ }
+ function sync() {
+ var want = hover.matches && !quiet[0].matches && !quiet[1].matches;
+ if (want === listening) return;
+ listening = want;
+ if (want) {
+ document.addEventListener("pointermove", move, { passive: true });
+ document.addEventListener("pointerout", out, { passive: true });
+ document.addEventListener("pointerdown", press, { passive: true });
+ } else {
+ document.removeEventListener("pointermove", move);
+ document.removeEventListener("pointerout", out);
+ document.removeEventListener("pointerdown", press);
+ clear();
+ }
+ }
+ [hover, quiet[0], quiet[1]].forEach(function (m) {
+ if (m.addEventListener) m.addEventListener("change", sync);
+ else if (m.addListener) m.addListener(sync);
+ });
+ sync();
+})();