Repository navigation
fix(motion): accept minified duration tokens; fail open on setup errors - #212
Merged
Merged
Conversation
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>
🔎 Preview build (downloadable artifact)Download the preview artifact · build log
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Cause
src/styles/global.cssdefines 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 itsgsap.set()calls, so the content shows without animation instead of staying hidden. It logsMotion setup failed; showing content without animation.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 typecheckis clean. (npm run lintcrashes locally on Node 20.10 for unmodifiedmaintoo, so it's a local Node version issue. CI runs it.)npm run build:pages(same env asdeploy-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
🤖 Generated with Claude Code