Skip to content

perf: animate the menu toggle with CSS and drop motion-v - #98

Merged
atinux merged 1 commit into
mainfrom
perf/remove-motion-v
Nov 18, 2026
Merged

atinux merged 1 commit into
mainfrom
perf/remove-motion-v

Conversation

@atinux

@atinux atinux commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Written by an AI agent on behalf of @atinux.

Problem

The mobile menu toggle (IconMenuToggle) was the only direct user of motion-v in 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.vue draws 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 with bounce: 0), so the two bars meet in a cross. Reduced motion turns the transition off.
  • UHeader mounts 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-v is removed from dependencies.

Evidence

Production builds (pnpm build) of main and this branch, one build each on the same orb. For each page I took the scripts and modulepreload links in the server-rendered HTML plus their static imports, which is the JS the page runs to hydrate. The rel="prefetch" chunks for later navigation aren't counted. Sizes are of the build output, so they don't vary between runs.

JS the page runs (raw / gzip) main This PR Diff
/ 1,391 / 454 KB 1,252 / 409 KB −139 / −45 KB
/getting-started/introduction 2,907 / 912 KB 2,874 / 901 KB −33 / −11 KB
All client JS emitted 3,862 / 1,205 KB 3,828 / 1,194 KB −34 / −11.5 KB

motion-v still ships, because @nuxt/ui depends on it for ProseImg (click to zoom). On the homepage it is now only prefetched. Docs pages still run it, because [...slug].vue imports all of @nuxt/ui/components/prose, including ProseImg.

The toggle at a 390px viewport, closed and open. The look matches main: same line positions, and the cross is centered.

Closed Open
Closed Open

Opening and closing the menu:

toggle.webm

In the browser, both toggles report translate: 0px 4px; rotate: 45deg and 0px -4px; -45deg when open and none after Escape. eslint passes on the component.

Details

  • I also tried the comark main preview (fix(vue): register Nuxt components from their own entries comark#600, which splits the auto-imported MarkdownDocument). It made no difference here: both pages already pass their own components, and the homepage needs the parser for the LandingHeroDemo live demo.
  • The toggle has no 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.


Read this PR faster

Summary by CodeRabbit

  • UI Improvements
    • The menu icon stays in its closed appearance during initial display and changes into a close icon when the menu opens.
    • The icon transitions smoothly between states. Animation is disabled when reduced-motion preferences are enabled.

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
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
comark-docs-layer Ready Ready Preview Nov 17, 2026 2:30pm UTC

@coldtea-pr-lens

coldtea-pr-lens Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Architecture

Walkthrough of Replace motion-v menu icon animation with CSS transitions, in three steps

Read this PR faster


Data flow

No data-flow sequence changed in this PR.


Review

✨ Nothing flagged · reviewed 088fa09


Tip

After a push, tick Redraw to draw the latest commit

🪧 More tips
  • Run npx skills add coldteadotai/pr-lens, then tell your coding agent: "Diagram the change you just made with PR Lens and attach it to the pull request."
  • Run npx @coldtea/pr-lens-cli analyze --base origin/main on a branch, then npx @coldtea/pr-lens-cli render .pr-lens/graph.json. Same lenses, your own model key, before the pull request exists
  • Click the link under each diagram to open it on a canvas you can zoom, pan and step through
  • The diagrams are links. Click one to open it on the canvas, then press W or click play to walk through the change
  • Open a diagram on the canvas, then press W or click play to walk through the change one step at a time
  • The CLI's render reads .github/pr-lens.yml and applies your renames, exclusions and lane pins at draw time
  • Set github.comment.collapsed: true in .github/pr-lens.yml to fold the comment behind one View architecture… row. Drawing still runs as before
  • Set github.draw: on-demand in .github/pr-lens.yml and PR Lens stops drawing pull requests on its own. Comment @pr-lens draw on a pull request when you want that one drawn
  • Add .github/workflows/pr-lens.yml with coldteadotai/pr-lens/packages/action@v0 and your model provider's key as its api-key to run PR Lens from your own CI. Any /chat/completions endpoint works
  • Switch GitHub to dark mode and the diagrams follow. The moving dots are this pull request's data in motion
  • Set github.description: false in .github/pr-lens.yml to stop PR Lens adding buttons to your PR descriptions

Thanks for using PR Lens! It's free for OSS. If it helped, a star helps other teams find it.  Star PR Lens on GitHub

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The menu toggle replaces Motion variants with CSS transitions. It transforms the two SVG lines into a cross when the component is open and ready. Reduced-motion preferences disable transitions. The package manifest removes the motion-v dependency.

Changes: Menu toggle animation

Layer / File(s) Summary
CSS toggle transitions
app/components/IconMenuToggle.vue, package.json
The component uses a mount-delayed ready flag and CSS classes to transform the SVG lines when open. Reduced-motion preferences disable transitions. The package manifest removes motion-v.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: Minimal · up to 088fa

The menu toggle now animates with CSS instead of a JavaScript animation library, which trims client JavaScript. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the two main changes: the menu toggle animation moves from motion-v to CSS, and motion-v is removed. The raw summary confirms IconMenuToggle.vue now uses CSS transitions and package.js…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main changes: the menu toggle animation moves from motion-v to CSS, and motion-v is removed. The raw summary confirms IconMenuToggle.vue now uses CSS transitions and package.json drops motion-v. The 'perf:' prefix matches the stated goal of reduced JS. The title is specific and concise.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install timed out. The project may have too many dependencies for the sandbox.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2d663d7d-5137-484a-88f4-8f9c7c5db645
Commits

Reviewing files that changed from the base of the PR and between a709a3e and 088fa09.

Files ignored due to path filters: 1

  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
Files selected for processing: 2

  • app/components/IconMenuToggle.vue
  • package.json
Files with no reviewable changes: 1

  • package.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@pkg-pr-new

pkg-pr-new Bot commented Nov 17, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/comarkdown/comark-docs@98

commit: 088fa09

@github-actions

Copy link
Copy Markdown

Bundle size

Explore the comparison →

Client 860.3 kB $\color{green}\textsf{(-8.56 kB, -1.0}\%\textsf{)}$ · Server 6.56 MB $\color{red}\textsf{(+44.8 kB, +0.7}\%\textsf{)}$

Initial page load PR Δ
/logos 239.7 kB −40.2 kB (−14.4%)
/ 320.4 kB −40.2 kB (−11.2%)
/docs 232.5 kB −40.2 kB (−14.8%)
/full 232.7 kB −40.2 kB (−14.7%)
/:slug(.+) 718.0 kB −8.74 kB (−1.2%)
Prerendered URL Initial load Δ HTML Δ
/ 393.0 kB
72.9 kB from components
−40.2 kB (−9.3%)
route −40.2 kB, components ±0 B
14.6 kB +27 B (+0.2%)
/page 790.9 kB
72.9 kB from components
−8.74 kB (−1.1%)
route −8.74 kB, components ±0 B
12.5 kB +62 B (+0.5%)
/getting-started/introduction 790.9 kB
72.9 kB from components
−8.74 kB (−1.1%)
route −8.74 kB, components ±0 B
16.1 kB +53 B (+0.3%)
Largest changes in the client
Package or file Base PR Δ
node_modules/motion-v 18.3 kB 9.22 kB −9.03 kB (−49.5%)
node_modules/motion-dom 30.4 kB 31.5 kB +1.14 kB (+3.8%)
[unassigned] 42.1 kB 41.8 kB −264 B (−0.6%)
node_modules/@nuxt/ui 56.2 kB 56.1 kB −136 B (−0.2%)
node_modules/hey-listen 12 B n/a −12 B (−100.0%)
Largest changes in the server
Package or file Base PR Δ
node_modules/motion-dom n/a 48.3 kB +48.3 kB
node_modules/motion-v 18.2 kB 13.6 kB −4.63 kB (−25.4%)
node_modules/motion-utils n/a 1.81 kB +1.81 kB
[unassigned] 5.29 MB 5.29 MB −722 B (−0.0%)
node_modules/framer-motion n/a 280 B +280 B
node_modules/@nuxt/ui 106.9 kB 106.7 kB −178 B (−0.2%)

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 088fa09.

@atinux
atinux merged commit a3ebf99 into main Nov 18, 2026
13 checks passed
@atinux
atinux deleted the perf/remove-motion-v branch November 18, 2026 09:29

This branch was successfully deployed

1 active deployment
Preview — 088fa099 Deployed Nov 17, 2026 by vercel[bot]
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