Skip to content

fix(web): repair transition durations dropped as invalid CSS - #810

Merged
Quick104 merged 2 commits into
mainfrom
fix/tailwind-v4-duration-tokens
Aug 28, 2026
Merged

Quick104 merged 2 commits into
mainfrom
fix/tailwind-v4-duration-tokens

Conversation

@Quick104

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A — narrow fix found while reviewing #805.

Tailwind v3 spelled a custom property inside an arbitrary value as [--token]. Under
v4 that is read as a bare token, so duration-[--duration-fast] compiles to:

transition-duration: --duration-fast

That is not valid CSS. Browsers drop the declaration and the utility falls back to
0s, so eighteen transitions on main today are not animating at all — the
carousel arrows, the home hero crossfade and play pills, the audiobook group view,
NowListeningHero, and the setup wizard step indicator. The v4 spelling
duration-(--duration-fast) emits var(--token).

The second commit is the same failure one step further along. HeroBanner built its
animation token name from a template literal:

animation: `var(--animate-ken-burns-${i % 2 === 0 ? "a" : "b"})`

Tailwind only keeps a theme variable whose name it can find in the scanned source, so
neither --animate-ken-burns-a nor -b ever appeared as literal text. Both were
tree-shaken out of the bundle, var() resolved to nothing, and the animation
shorthand was invalid — the home hero has never actually panned. The only values that
reached the bundle were the none overrides from the prefers-reduced-motion block.

Approach

Convert the utilities to the v4 spelling and name the animation tokens literally.

Both failures are invisible in review and in the browser — a missing transition reads
as a design choice — so this adds a contract test over the source rather than trusting
the next reader to catch it. That test immediately found a third instance the
mechanical sweep had missed (ease-[--ease-smooth] in the design-system docs), which
is a fair argument for it existing.

Validation

Verified against the production bundle rather than by eye:

before after
transition-duration:--duration-fast|normal|slow present absent
--animate-ken-burns-a only :none ken-burns-a 14s linear infinite + the :none reduced-motion override

Confirmed live that a real hero reports animationName: ken-burns-a, 14s.

  • pnpm run build — passed
  • pnpm exec vitest run — 2610 passed
  • pnpm run lint — 0 errors (165 pre-existing warnings, unchanged baseline)
  • pnpm run format:check — passed

Reduced motion is unaffected: app.css still overrides both animation tokens to
none, so the restored hero motion stays accessible.

Risks

Eighteen transitions that were instant now animate, and the home hero now pans. That
is the intended repair, but it is a visible change to surfaces nobody has seen
animate, so it is worth a look rather than a rubber stamp.

Provenance

Ports the Tailwind syntax fix from #805 by @blurbery, rebuilt against current main.
That branch bundled this with a navigation rewrite and app-wide presentation changes;
this PR is the token fixes alone.

AI Disclosure

  • Tool(s): Claude Code
  • Model(s): claude-opus-5[1m]
  • Involvement: Fully AI-generated, human verified — @Quick104 set the direction, made
    the product calls, and reviewed the result against a live deployment.
  • Adversarial review: found during a defect-first review of perf(web): smooth detail layout, resizing, and navigation #805. The invalid-CSS
    claim was not taken on trust from the source diff; it was confirmed by grepping the
    compiled bundle before and after, and the Ken Burns claim was confirmed the same way
    after an initial review finding about it turned out to be wrong (it was reported as
    a removed working feature; it had in fact never worked). Both regressions are now
    pinned by tests.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

🤖 Generated with Claude Code

Quick104 and others added 2 commits August 28, 2026 11:29
Tailwind v3 spelled a custom property inside an arbitrary value as
`[--token]`. Under v4 that is read as a bare token, so
`duration-[--duration-fast]` compiled to

    transition-duration: --duration-fast

which is not valid CSS. Browsers drop the declaration and the utility
falls back to `0s`, so eighteen transitions across the carousels, the home
hero, the audiobook group view and the setup wizard were not animating at
all. The v4 spelling `duration-(--duration-fast)` emits `var(--token)`.

Verified against the production bundle: it previously contained
`transition-duration:--duration-fast`, `:--duration-normal` and
`:--duration-slow`, and now contains no bare-token duration at all.

A missing transition looks like a design choice rather than a bug, in
review and in the browser alike, so this adds a contract test over the
source rather than trusting the next reader to catch it. That test
immediately found a second instance the mechanical sweep had missed —
`ease-[--ease-smooth]` in the design-system docs, a different utility with
the same failure mode.

Ports the Tailwind syntax fix from #805 by @blurbery, rebuilt against main.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Same failure as the duration tokens, one step further along: Tailwind only
keeps a theme variable whose name it can find in the scanned source, and
this one was assembled from a template literal —

    animation: `var(--animate-ken-burns-${i % 2 === 0 ? "a" : "b"})`

so neither `--animate-ken-burns-a` nor `-b` ever appeared as literal text.
Both were tree-shaken out of the bundle, `var()` resolved to nothing, and
the `animation` shorthand was invalid, so the hero has never actually
panned. The only values that reached the bundle were the `none` overrides
from the `prefers-reduced-motion` block.

Naming both literally restores the effect; the reduced-motion overrides
still apply, so this stays accessible.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 56 minutes.

View limit details

Limit details: You’ve used the included review currently available. Your 100 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f6f6ed51-f608-4ee1-bf8f-2767bec5d52f

📥 Commits

Reviewing files that changed from the base of the PR and between fe7aaf1 and 8c2fd2f.

📒 Files selected for processing (9)
  • web/src/components/BrandCarousel.tsx
  • web/src/components/HeroBanner.test.tsx
  • web/src/components/HeroBanner.tsx
  • web/src/components/MediaCarousel.tsx
  • web/src/components/NowListeningHero.tsx
  • web/src/components/audiobooks/AudiobookGroupsView.tsx
  • web/src/lib/design-system.ts
  • web/src/pages/setup-wizard/StepIndicator.tsx
  • web/src/tailwindTokenSyntax.test.ts

Comment @coderabbitai help to get the list of available commands.

@Quick104
Quick104 merged commit 07b05ee into main Aug 28, 2026
6 checks passed
@Quick104
Quick104 deleted the fix/tailwind-v4-duration-tokens branch August 28, 2026 16:06
Quick104 pushed a commit that referenced this pull request Sep 22, 2026
Seven of the ten declarations in the `html[data-high-contrast="true"]`
block referenced themselves:

    --border: color-mix(in srgb, white 34%, var(--border));

Per CSS Custom Properties L1 §3 a custom property whose value references
itself is in a dependency cycle and is invalid at computed-value time, so
the declaration is discarded and the token computes to nothing. This holds
even though an inherited value exists — the inherited value is not
consulted — so the intended mix never resolved.

Measured on a live instance (midnight-cinema, Chrome), all seven
self-referencing tokens computed empty while the non-self-referencing
`--foreground` and `--ambient-glow-opacity` applied correctly.

Two things went wrong as a result, and both made high contrast *worse*
than standard mode:

  - `--surface` was invalid, so .surface-panel / .surface-panel-subtle /
    .surface-panel-raised computed `background-color: rgba(0,0,0,0)` and
    rendered transparent — settings panels, cards and popovers became
    flat holes on the page background.
  - `border-color` fell back to `currentColor`, and the same block sets
    `--foreground: #ffffff`, so borders rendered pure white instead of
    `rgb(40, 40, 46)`.

The fix gives the mix an input that is not the property being assigned.
Each theme now defines the literal under `--<token>-base`, the semantic
token is an alias, and high contrast mixes from the base. Verified
against the compiled output in a real document root: all seven tokens
resolve both with high contrast off and on.

Worth recording that the intuitive alternative does not work — moving the
block to a descendant so `var()` inherits is still cyclic and still
computes empty. Only a distinct input token resolves.

`git log -L` traces the block unchanged to c085b12, so this never
worked. It likely went unreported because any profile with a stored
`ui.custom_theme_vars` override never sees it: those are injected
unlayered and win over this block.

Same failure family as #810 — CSS that parses fine, is discarded at
computed-value time, and surfaces only as a subtly wrong UI. Added
highContrastCss.test.ts as a contract test over app.css, in the shape of
navigationTransitionCss.test.ts: it fails the whole stylesheet on any
self-referencing custom property, and checks the mix, the aliases, and
that every theme defines every base token. Confirmed it fails when the
old declaration is reintroduced.

Co-Authored-By: Claude Opus 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant