Repository navigation
perf: animate the menu toggle with CSS and drop motion-v - #98
Conversation
The mobile menu toggle was the only direct user of motion-v. Its two bars now rotate into a cross with CSS transitions, which takes motion-v out of the JavaScript the homepage runs. Amp-Thread-ID: https://ampcode.com/threads/T-01a1e94e-f329-74fa-982a-f6d799c40e05
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Architecture Data flow No data-flow sequence changed in this PR. Review ✨ Nothing flagged · reviewed Tip After a push, tick Redraw to draw the latest commit 🪧 More tips
Thanks for using PR Lens! It's free for OSS. If it helped, a star helps other teams find it. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
commit: |
Bundle sizeClient 860.3 kB
Largest changes in the client
Largest changes in the server
Brotli sizes. Changes under 100 B are left out of the tables. Initial page load counts the JavaScript and CSS a route loads before it renders. Prerendered URLs count the JavaScript and CSS their HTML preloads (module scripts, modulepreload and stylesheets, not prefetch), and the HTML document. Components are the lazy-loaded components the page rendered: its HTML preloads them, but its route's static imports don't reach them. Measured by nuxt-bundle-analyzer for |
Problem
The mobile menu toggle (
IconMenuToggle) was the only direct user ofmotion-vin the layer, and it put motion-v in a 496 KB shared chunk that every page ran, including the homepage, which shows no image zoom or other motion-v UI.What changed
IconMenuToggle.vuedraws plain<line>s. Each bar turns around its own center and moves 4px with a CSS transition (duration-200 ease-out, the same timing as the old spring withbounce: 0), so the two bars meet in a cross. Reduced motion turns the transition off.UHeadermounts a second toggle, already open, in its menu overlay. That one is drawn closed for its first frame so it animates into the cross instead of appearing as one, the same fix as perf(home): shrink the DOM and drop unused JavaScript nuxt/nuxt.com#2656.motion-vis removed fromdependencies.Evidence
Production builds (
pnpm build) ofmainand this branch, one build each on the same orb. For each page I took the scripts andmodulepreloadlinks in the server-rendered HTML plus their static imports, which is the JS the page runs to hydrate. Therel="prefetch"chunks for later navigation aren't counted. Sizes are of the build output, so they don't vary between runs.main//getting-started/introductionmotion-v still ships, because
@nuxt/uidepends on it forProseImg(click to zoom). On the homepage it is now only prefetched. Docs pages still run it, because[...slug].vueimports all of@nuxt/ui/components/prose, includingProseImg.The toggle at a 390px viewport, closed and open. The look matches
main: same line positions, and the cross is centered.Opening and closing the menu:
toggle.webm
In the browser, both toggles report
translate: 0px 4px; rotate: 45degand0px -4px; -45degwhen open andnoneafter Escape.eslintpasses on the component.Details
mainpreview (fix(vue): register Nuxt components from their own entries comark#600, which splits the auto-importedMarkdownDocument). It made no difference here: both pages already pass their owncomponents, and the homepage needs the parser for theLandingHeroDemolive demo.aria-label, before and after. Left as is.ELI5
The menu button's opening animation used a big animation library. It now uses a few lines of CSS that do the same thing, so the homepage downloads and runs about 45 KB less JavaScript.
Summary by CodeRabbit