oficina / docs Public

Docs: light that follows the pointer, and a toolbar that floats over the page

Paul, on the preview: rastrillo-style lighting on hover, following the
pointer across an item; and the dock read as lower than the page.

- rastrillo's own light.js is served and linked (ui.LightJS): its
  buttons catch a sheen where the pointer is, and the list card's rim
  brightens near it. brand/light.css gives Docs the values its day
  theme declares and Calma does not yet.
- brand/pointer.js does the same for Docs' own controls, in light.js's
  vocabulary (--rst-mx/--rst-my, plus --docs-tx/--docs-ty): the
  toolbar's buttons, the list's rows and menu items light under the
  pointer; a shelf page leans a few degrees toward it with the light
  on its paper. Mouse and pen only; off under reduced motion and
  forced colours; every property has a still default.
- The paper's shadow is shorter and the dock's longer, so the dock
  reads as floating over the page that scrolls under it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by paul@keymail.dev cffc6922255375f4dce4da3d1935b5a84e42fc88 parent 8505448
7 files changed, +147 −11
  • internal/docs/brand/light.css +21 −0
  • internal/docs/brand/pointer.js +71 −0
  • internal/docs/render.go +6 −1
  • internal/docs/views/head.html +1 −0
  • internal/docs/views/layout.html +2 −0
  • internal/docs/views/list.html +30 −2
  • internal/docs/views/show.html +16 −8

CI passed — run details

diff --git a/internal/docs/brand/light.css b/internal/docs/brand/light.css
new file mode 100644
index 0000000..9554c77
--- /dev/null
+++ b/internal/docs/brand/light.css
@@ -0,0 +1,21 @@
+/* The light, for Docs: the values rastrillo's depth styles read (its
+ day theme's names, ui/themes/day.css), which estilo's Calma does not
+ declare yet, and the same light on Docs' own controls. Positions come
+ from rastrillo's light.js (its buttons and cards) and from
+ pointer.js (everything here); with neither, every rule below falls
+ back to the still design. Hover-only, and under (hover: hover), so a
+ touch screen never holds a light where a finger lifted. */
+:root {
+ --rst-sheen-fill: light-dark(rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.07));
+ --rst-sheen-plain: light-dark(color-mix(in srgb, var(--rst-accent) 10%, transparent), rgba(255, 255, 255, 0.05));
+ --rst-light-rim: light-dark(color-mix(in srgb, var(--rst-accent) 38%, var(--rst-line)), color-mix(in srgb, var(--rst-accent) 40%, #505050));
+ --rst-light-wash: light-dark(color-mix(in srgb, var(--rst-accent) 4%, transparent), rgba(255, 255, 255, 0.025));
+ /* The pool of light a pointer casts on the control it is over. */
+ --docs-light-tint: light-dark(color-mix(in srgb, var(--rst-accent) 10%, transparent), color-mix(in srgb, var(--rst-accent) 16%, transparent));
+}
+@media (hover: hover) {
+ /* A menu's rows: the hover fill estilo draws, with the light on it. */
+ [estilo-menu-item]:hover:not(:disabled) {
+ background-image: radial-gradient(120px circle at var(--rst-mx, 50%) var(--rst-my, 50%), var(--docs-light-tint), transparent 70%);
+ }
+}
diff --git a/internal/docs/brand/pointer.js b/internal/docs/brand/pointer.js
new file mode 100644
index 0000000..e89cd4c
--- /dev/null
+++ b/internal/docs/brand/pointer.js
@@ -0,0 +1,71 @@
+/* pointer.js: Docs' half of the light. rastrillo's light.js (served
+ beside this as static/light.js) lights rastrillo's own buttons and
+ cards; this does the same for Docs' own controls, which it does not
+ know: the toolbar's buttons, the shelf's pages, the list's rows and
+ the menus' items.
+
+ What it writes, on the one element under the pointer, and nothing
+ else: --rst-mx and --rst-my, the pointer in the element's own pixels
+ (light.js's names and units, so one stylesheet vocabulary lights
+ both), and --docs-tx and --docs-ty, the same position from -1 to 1
+ across the element, for the shelf's tilt. It clears them when the
+ pointer leaves, and every property has a default in the stylesheet,
+ so deleting this file and its tag leaves the still design.
+
+ 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) return;
+ var LIT = "[docs-tool],[docs-tile],[docs-list] [rst-row],[estilo-menu-item]";
+ 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;
+
+ 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 = e.target && e.target.closest ? e.target.closest(LIT) : null;
+ 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("--docs-tx", Math.max(-1, Math.min(1, (x / r.width) * 2 - 1)).toFixed(3));
+ el.style.setProperty("--docs-ty", Math.max(-1, Math.min(1, (y / r.height) * 2 - 1)).toFixed(3));
+ }
+ function move(e) {
+ if (e.pointerType && e.pointerType !== "mouse" && e.pointerType !== "pen") return;
+ pending = e;
+ if (!raf) raf = requestAnimationFrame(step);
+ }
+ function out(e) {
+ if (!e.relatedTarget) clear();
+ }
+ 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 });
+ } else {
+ document.removeEventListener("pointermove", move);
+ document.removeEventListener("pointerout", out);
+ clear();
+ }
+ }
+ [hover, quiet[0], quiet[1]].forEach(function (m) { m.addEventListener("change", sync); });
+ sync();
+})();
diff --git a/internal/docs/render.go b/internal/docs/render.go
index 9a4677a..c08abc7 100644
--- a/internal/docs/render.go
+++ b/internal/docs/render.go
@@ -714,6 +714,11 @@ func vendoredStaticFS() (fs.FS, error) {
"static/estilo/busy.css": {Data: busy.CSS()},
"static/select.js": {Data: ui.SelectJS()},
"static/datetime.js": {Data: ui.DatetimeJS()},
+ // rastrillo's light: the pointer's sheen on its buttons and a
+ // list card's rim brightening near the pointer (brand/light.css
+ // gives Docs the values; brand/pointer.js does Docs' own
+ // controls the same way).
+ "static/light.js": {Data: ui.LightJS()},
// estilo's shared chrome, fingerprinted like the theme.
"static/estilo/base.css": {Data: base.CSS()},
"static/estilo/menu.css": {Data: estilomenu.CSS()},
@@ -724,7 +729,7 @@ func vendoredStaticFS() (fs.FS, error) {
"static/estilo/sky.css": {Data: sky.CSS()},
"static/estilo/chrome.js": {Data: chrome.JS()},
}
- for _, name := range []string{"icon-32.png", "apple-touch-icon.png", "brand.css", "LICENSE.lucide"} {
+ for _, name := range []string{"icon-32.png", "apple-touch-icon.png", "brand.css", "LICENSE.lucide", "light.css", "pointer.js"} {
body, err := brandFS.ReadFile("brand/" + name)
if err != nil {
return nil, err
diff --git a/internal/docs/views/head.html b/internal/docs/views/head.html
index a2faa03..ed2622b 100644
--- a/internal/docs/views/head.html
+++ b/internal/docs/views/head.html
@@ -5,4 +5,5 @@
<link rel="icon" type="image/svg+xml" href="/static/icon.svg">
<link rel="apple-touch-icon" sizes="180x180" href="{{asset "static/brand/apple-touch-icon.png"}}">
<link rel="stylesheet" href="{{asset "static/brand/brand.css"}}">
+<link rel="stylesheet" href="{{asset "static/brand/light.css"}}">
{{end}}
diff --git a/internal/docs/views/layout.html b/internal/docs/views/layout.html
index 0e33722..8c288f4 100644
--- a/internal/docs/views/layout.html
+++ b/internal/docs/views/layout.html
@@ -32,6 +32,8 @@
<script defer src="{{asset "static/select.js"}}"></script>
<script defer src="{{asset "static/datetime.js"}}"></script>
<script defer src="{{asset "static/estilo/chrome.js"}}"></script>
+<script defer src="{{asset "static/light.js"}}"></script>
+<script defer src="{{asset "static/brand/pointer.js"}}"></script>
</head>
<body>
<div estilo-shell>
diff --git a/internal/docs/views/list.html b/internal/docs/views/list.html
index ef6779d..f9bdda9 100644
--- a/internal/docs/views/list.html
+++ b/internal/docs/views/list.html
@@ -322,12 +322,33 @@
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. The
+ /* Picking a page up: it lifts 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
+ transition is what makes the lean follow rather than jump). The
motion answers the pointer, and is dropped for reduced motion,
where the edge alone says the same thing. */
+ [docs-tile] [docs-thumb] {
+ position: relative;
+ }
+ [docs-tile] [docs-thumb]::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ background: radial-gradient(180px circle at var(--rst-mx, 50%) var(--rst-my, 0%), var(--docs-light-tint), transparent 70%);
+ opacity: 0;
+ transition: opacity 200ms ease;
+ pointer-events: none;
+ }
+ [docs-tile]:hover [docs-thumb]::after {
+ opacity: 1;
+ }
[docs-tile]:hover [docs-thumb],
[docs-tile]:focus-visible [docs-thumb] {
- transform: translateY(-4px);
+ transform: translateY(-4px) perspective(800px)
+ rotateX(calc(var(--docs-ty, 0) * -4deg))
+ rotateY(calc(var(--docs-tx, 0) * 5deg));
box-shadow:
0 0 0 1.5px var(--rst-accent),
0 2px 4px rgb(23 32 60 / 0.08),
@@ -358,6 +379,13 @@
[docs-list] [rst-row] {
gap: var(--rst-sp-4);
}
+ /* The row under the pointer: rastrillo's hover tint, with a pool of
+ the accent's light following the pointer along it. */
+ @media (hover: hover) {
+ [docs-list] [rst-row]:hover {
+ background-image: radial-gradient(280px circle at var(--rst-mx, 50%) var(--rst-my, 50%), var(--docs-light-tint), transparent 70%);
+ }
+ }
/* Big enough to read the page's shape, its headings and paragraphs,
at a glance: 44px is a sheet a person can tell from its
neighbours, where 26px was a bordered box. */
diff --git a/internal/docs/views/show.html b/internal/docs/views/show.html
index 721a536..1858861 100644
--- a/internal/docs/views/show.html
+++ b/internal/docs/views/show.html
@@ -161,13 +161,14 @@
background: #ffffff;
color: #1a1a1a;
border-radius: 2px;
- /* Paper lying on the desk: a hairline edge, a contact shadow, and
- a long soft one from a light above. */
+ /* Paper lying flat on the desk: a hairline edge, a contact shadow
+ and a short soft one. Lower than the toolbar's dock, which floats
+ over it and casts the longer shadow, so the two depth cues agree
+ with the page scrolling under the dock. */
box-shadow:
0 0 0 1px rgb(23 32 60 / 0.06),
- 0 1px 2px rgb(23 32 60 / 0.10),
- 0 4px 8px -2px rgb(23 32 60 / 0.06),
- 0 24px 48px -18px rgb(23 32 60 / 0.30);
+ 0 1px 2px rgb(23 32 60 / 0.08),
+ 0 8px 20px -12px rgb(23 32 60 / 0.20);
}
/* Narrow screens stop simulating paper, because at phone widths the
simulation costs more than it says.
@@ -957,8 +958,12 @@
line-height: 1;
cursor: pointer;
}
+ /* Hovered, a button lights where the pointer is on it (brand/
+ pointer.js writes --rst-mx/--rst-my; centred without it). */
[docs-tool]:hover:not(:disabled) {
- background: var(--rst-surface-2);
+ background:
+ radial-gradient(40px circle at var(--rst-mx, 50%) var(--rst-my, 50%), color-mix(in srgb, var(--rst-accent) 18%, transparent), transparent 75%),
+ var(--rst-surface-2);
}
/* aria-pressed is the state, and colour is not allowed to be the only
thing that shows it (§10.3, and AGENTS.md's "no exemptions").
@@ -1248,10 +1253,13 @@
background: light-dark(rgb(255 255 255 / 0.86), rgb(32 35 43 / 0.86));
-webkit-backdrop-filter: saturate(1.4) blur(14px);
backdrop-filter: saturate(1.4) blur(14px);
+ /* The highest thing on the desk: a longer, softer shadow than
+ the paper's, so it reads as floating over the page. */
box-shadow:
0 0 0 1px light-dark(rgb(23 32 60 / 0.08), rgb(255 255 255 / 0.08)),
- 0 1px 2px rgb(23 32 60 / 0.08),
- 0 12px 28px -12px light-dark(rgb(23 32 60 / 0.30), rgb(0 0 0 / 0.7));
+ 0 2px 4px rgb(23 32 60 / 0.06),
+ 0 10px 20px -8px light-dark(rgb(23 32 60 / 0.18), rgb(0 0 0 / 0.5)),
+ 0 28px 56px -20px light-dark(rgb(23 32 60 / 0.28), rgb(0 0 0 / 0.7));
pointer-events: auto;
}
[docs-toolbar-group] + [docs-toolbar-group] {