diff --git a/frontend/packages/swarm-ui/src/lib/motion-apply.ts b/frontend/packages/swarm-ui/src/lib/motion-apply.ts index 49717c7f..42c19f7e 100644 --- a/frontend/packages/swarm-ui/src/lib/motion-apply.ts +++ b/frontend/packages/swarm-ui/src/lib/motion-apply.ts @@ -3,14 +3,15 @@ // when the override is "system" (letting `prefers-reduced-motion` // alone decide, same as today). // -// Built ahead of swarm-ui having any CSS animation to gate — the -// settings surface itself was scoped to cover theme *and* motion -// together (both named in the same go-ahead), and the marginal cost of -// the storage/attribute plumbing was near zero riding alongside the -// theme override's real wiring. `Shell`'s page-switch animation (the -// nav indicator's slide + the page-body pop) is the first real -// consumer — see `shell/Shell.css`'s file-top comment for the -// three-rule gate shape every animation here follows: +// Currently inert: swarm-ui has zero CSS animations as of this file's +// writing (the design guide's "playful whimsy" motion — the matrix-rain +// home background — lives in the dashboard package, not swarm-ui). This +// hook exists because the settings surface itself was scoped to cover +// theme *and* motion together (both named in the same go-ahead), and the +// marginal cost of the storage/attribute plumbing is near zero riding +// alongside the theme override's real wiring — but there is genuinely +// nothing in swarm-ui for `data-motion` to gate yet. The first swarm-ui +// animation's own CSS is what makes this do anything, e.g.: // @media (prefers-reduced-motion: reduce) { ... } // :root[data-motion='reduce'] { ... same rule ... } // :root[data-motion='allow'] { /* opt back in despite OS-level reduce */ } diff --git a/frontend/packages/swarm-ui/src/shell/Shell.css b/frontend/packages/swarm-ui/src/shell/Shell.css index 77e59c13..615e40f7 100644 --- a/frontend/packages/swarm-ui/src/shell/Shell.css +++ b/frontend/packages/swarm-ui/src/shell/Shell.css @@ -8,17 +8,7 @@ menu: a narrow viewport (phone or a tiled desktop window) wraps onto a second line instead of overflowing — "don't break, don't over-invest" is the explicit scope here, not full mobile navigation - redesign. - - Page-switch animation (see Shell.tsx's file-top comment for the JS - half): both the nav indicator's slide and the page-body pop follow - the same three-rule motion-guard shape `lib/motion-apply.ts`'s own - doc comment specifies — a base rule, - `@media (prefers-reduced-motion: reduce)` to respect the OS default, - `:root[data-motion='reduce']` as the explicit override (same - specificity as the media rule, so source order after it wins), then - `:root[data-motion='allow']` last to re-enable despite an OS-level - reduce preference. */ + redesign. */ .shell-header { display: flex; align-items: center; @@ -30,34 +20,13 @@ } .shell-brand { font-weight: 600; - /* Base colour only — Shell.tsx overrides it inline to the same - currently-active-tab accent `.shell-nav-indicator` uses (falling - back to this `--purple` before the first measurement lands, which - is also the "hives" default route's own accent, so there's no - visible mismatch at first paint). Transition lives here, same - 140ms hop cadence + the same three-rule motion guard as the - indicator, so this and the indicator read as one thing changing, - not two independently-synced ones. */ color: var(--purple); letter-spacing: 0.02em; - transition: color 140ms ease; -} -@media (prefers-reduced-motion: reduce) { - .shell-brand { - transition: none; - } -} -:root[data-motion='reduce'] .shell-brand { - transition: none; -} -:root[data-motion='allow'] .shell-brand { - transition: color 140ms ease; } .shell-nav { display: flex; flex-wrap: wrap; gap: 1em; - position: relative; /* anchor for .shell-nav-indicator */ } /* Holds `SettingsMenu` + `LinksMenu` — one `margin-left: auto` on the wrapper, not one on each child (see Shell.tsx's comment for why two @@ -91,79 +60,15 @@ color: var(--fg); } .shell-nav-link-text { - padding-bottom: 0.25em; /* gap between the text and .shell-nav-indicator below it */ + padding-bottom: 0.25em; + border-bottom: 2px solid transparent; } .shell-nav-link-active { color: var(--fg); -} -/* Shared underline, one element instead of one border-bottom per link - — see Shell.tsx's file-top comment. `left`/`top`/`width` are set - inline per-render from a real measurement; only the *transition* - between those values lives here. 140ms matches Shell.tsx's `HOP_MS` - exactly, so one hop's CSS transition finishes right as the next - hop's JS-driven style update lands, instead of the two blending into - an averaged easing curve. */ -.shell-nav-indicator { - position: absolute; - height: 2px; - border-radius: 1px; - transition: - left 140ms ease, - top 140ms ease, - width 140ms ease, - background-color 140ms ease; -} -@media (prefers-reduced-motion: reduce) { - .shell-nav-indicator { - transition: none; - } -} -:root[data-motion='reduce'] .shell-nav-indicator { - transition: none; -} -:root[data-motion='allow'] .shell-nav-indicator { - transition: - left 140ms ease, - top 140ms ease, - width 140ms ease, - background-color 140ms ease; -} -/* Suppresses the transition for exactly one render — the indicator's - very first real position, so it snaps into place instead of visibly - growing from the unmounted `left:0/width:0/transparent` fallback (see - Shell.tsx's `indicatorSettledOnce`). Two-class selector so it wins - over the plain `.shell-nav-indicator` rule above without `!important`, - same reasoning `:root[data-motion='reduce']`'s extra attribute - selector already relies on. */ -.shell-nav-indicator.shell-nav-indicator-instant { - transition: none; + border-bottom-color: var(--purple); } .shell-body { max-width: 60em; margin: 0 auto; padding: 1.5em 1.25em; - /* Plain fade, deliberately — mara's call on review: a scale+overshoot - "pop" (this rule's first cut) read as too much for a first pass. - Keeping it simple leaves room to make this fancier later without - having shipped something to walk back first. */ - animation: shell-page-enter 160ms ease; -} -@keyframes shell-page-enter { - from { - opacity: 0; - } - to { - opacity: 1; - } -} -@media (prefers-reduced-motion: reduce) { - .shell-body { - animation: none; - } -} -:root[data-motion='reduce'] .shell-body { - animation: none; -} -:root[data-motion='allow'] .shell-body { - animation: shell-page-enter 160ms ease; } diff --git a/frontend/packages/swarm-ui/src/shell/Shell.tsx b/frontend/packages/swarm-ui/src/shell/Shell.tsx index eb6ac85a..cdd5d22d 100644 --- a/frontend/packages/swarm-ui/src/shell/Shell.tsx +++ b/frontend/packages/swarm-ui/src/shell/Shell.tsx @@ -12,34 +12,20 @@ // has exactly one place that needs to know its own nav, and this is // it. Grows additively as real routes land (a swarm-wide agent roster // is next); no speculative entries. -// -// Page-switch animation, two pieces (motion-guard rules live in -// Shell.css): `.shell-body` remounts on every navigation -// (`key={location}`) to replay a plain fade-in, and a single shared -// underline (`.shell-nav-indicator`, replacing what used to be a -// per-link border) hops through every nav item it passes over on its -// way to the new active one, not just a straight two-point tween — a -// nav hives→components jump visibly touches "new agent" and "jobs" in -// between, position and colour together. Accent is a discrete cycle -// through the existing base16 chromatic slots (`NAV_ITEMS`' `accent` -// field), not a continuous hue rotation — everything here still -// derives from base16, same rule the rest of the palette follows. -// `.shell-brand` rides the identical accent value (`navAccent` below), -// so the header reads as one accent changing, not the underline alone. -import { useEffect, useRef, useState } from 'preact/hooks'; +import { useEffect, useState } from 'preact/hooks'; import type { ComponentChildren } from 'preact'; -import { Link, useLocation } from 'wouter-preact'; +import { Link, useRoute } from 'wouter-preact'; import { LinksMenu } from './LinksMenu.js'; import { SettingsMenu } from './SettingsMenu.js'; import { useApplyThemeOverride } from '../lib/theme-apply.js'; import { useApplyMotionOverride } from '../lib/motion-apply.js'; import './Shell.css'; -const NAV_ITEMS: { href: string; label: string; accent: string }[] = [ - { href: '/', label: 'hives', accent: 'var(--purple)' }, - { href: '/create-agent', label: 'new agent', accent: 'var(--cyan)' }, - { href: '/jobs', label: 'jobs', accent: 'var(--pink)' }, - { href: '/components', label: 'components', accent: 'var(--blue)' }, +const NAV_ITEMS: { href: string; label: string }[] = [ + { href: '/', label: 'hives' }, + { href: '/create-agent', label: 'new agent' }, + { href: '/jobs', label: 'jobs' }, + { href: '/components', label: 'components' }, ]; // Static fallback — matches `index.html`'s `