Skip to content

fix(motion): accept minified duration tokens; fail open on setup errors - #212

Merged
afeezorobsco-cyber merged 1 commit into
mainfrom
fix/motion-minified-duration-tokens
Oct 29, 2026
Merged

afeezorobsco-cyber merged 1 commit into
mainfrom
fix/motion-minified-duration-tokens

Conversation

@afeezorobsco-cyber

Copy link
Copy Markdown
Contributor

Problem

The home page hero on https://docforum.github.io/docforum-web/#/ is blank: the headline, subtitle and the "Get started" / "Log in" buttons render at opacity 0. The console shows:

Unable to load the motion runtime Error: Invalid motion duration token: --motion-duration-fast
Unable to load the motion runtime Error: Invalid motion duration token: --motion-duration-hero-reveal
...

Cause

src/styles/global.css defines tokens like --motion-duration-hero-reveal: 500ms. The production build's CSS minifier rewrites them to the shorter .5s (.1s, .3s, …). motionDuration() parsed with /^(\d+(?:\.\d+)?)(ms|s)$/, which needs a leading digit, so it threw.

The hero animation calls gsap.set(targets, { opacity: 0 }) before reading the durations, so the throw left the hero hidden. The logo and care-thread animations failed the same way. Dev builds aren't minified, so nobody saw it locally or in PR checks. It started with #189 (2026-10-22).

Fix

  • motionDuration() accepts a leading dot: /^(\d*\.?\d+)(ms|s)$/.
  • useMotion() fails open: if a setup throws, it reverts the GSAP context, which undoes its gsap.set() calls, so the content shows without animation instead of staying hidden. It logs Motion setup failed; showing content without animation.
  • Tests: every token value in both source and minified forms (100ms, .1s, .5s, 0.3s, 1.4s, 50ms, 1s), rejection of invalid values, and the fail-open path.

Verified

  • vitest run src/hooks/useMotion.test.tsx: 15/15 pass. npm run typecheck is clean. (npm run lint crashes locally on Node 20.10 for unmodified main too, so it's a local Node version issue. CI runs it.)
  • Built with npm run build:pages (same env as deploy-pages.yml), served locally, and loaded in Chrome via Playwright. Hero [data-reveal] elements went from opacity 0 on the live site to opacity 1, and the motion console errors went from 4 to 0.

Not in this PR

  • The header shows a "Log out" button while logged out. That's a separate bug.
  • The live site's CSP blocks an inline script and some Trusted Types assignments (console noise, not the cause here).

🤖 Generated with Claude Code

The production CSS minifier rewrites '100ms' as '.1s'. motionDuration()
required a leading digit, so on GitHub Pages the hero animation threw after
gsap.set() had hidden its targets, leaving the home page hero (headline,
subtitle, CTAs) at opacity 0 since #189. The logo and care-thread
animations failed the same way.

- motionDuration() accepts a leading dot (/^(\d*\.?\d+)(ms|s)$/).
- useMotion() fails open: a setup that throws reverts the GSAP context,
  undoing its gsap.set() calls, so content shows without animation.
- Tests for both forms of every token value and for the fail-open path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🔎 Preview build (downloadable artifact)

Download the preview artifact · build log

  • Built from 6341c22; GitHub sign-in is required to download.
  • This build is not published to GitHub Pages or any other shared origin.
  • Runs against the mock API only — fake seed data, no real backend, no real credentials.
  • To view it locally: unzip the artifact, then serve the folder (for example
    npx serve <folder>) and open the URL it prints.
  • The artifact expires after 14 days and is replaced on every push to this PR.

@afeezorobsco-cyber
afeezorobsco-cyber merged commit 0923305 into main Oct 29, 2026
4 checks passed
@afeezorobsco-cyber
afeezorobsco-cyber deleted the fix/motion-minified-duration-tokens branch October 29, 2026 17:20
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