Skip to content

fix(routes/index): scale the adapter graph to the available width - #1108

Open
sukvvon wants to merge 8 commits into
mainfrom
fix/adapter-graph-mobile-scale
Open

fix(routes/index): scale the adapter graph to the available width#1108
sukvvon wants to merge 8 commits into
mainfrom
fix/adapter-graph-mobile-scale

Conversation

@sukvvon

@sukvvon sukvvon commented Aug 4, 2026

Copy link
Copy Markdown
Member

The Framework Agnostic diagram on the landing page overflows its card on phones — the React and Solid nodes sit flush against the edges and read as clipped.

Cause

The node coordinates are hard-coded against a 320×128 grid, so the whole graph is scaled as a unit. scale-[1.35] exists to fill the 460px slot that only appears at lg (PrinciplePanel is w-full lg:w-[460px]), but the scale applied at every width.

At 375px the graph renders 432px wide inside a 295px slot — 137px of overflow.

Fix

Derive the scale from the wrapper's own width via a container query:

<div className="@container flex w-full justify-center">
  <div
    ref={rootRef}
    style={{ transform: 'scale(clamp(0.75, calc(100cqw / 320px), 1.35))' }}
    className="relative h-32 w-[320px] shrink-0 origin-center …"
  >

100cqw / 320px is the slot width ÷ the graph's authored width. The 1.35 cap is main's existing value, so anything at or above lg is untouched.

Measuring the slot directly avoids restating the ancestors' padding — an intermediate revision computed 100vw - 64px and was wrong, because px-4 contributes 32px (16 per side), not 16. Anything that re-derives the slot arithmetically has to be kept in sync with two separate padding declarations; cqw cannot drift.

Measured

Viewport Slot main This PR Scale
320px 240px 432px (overflows) 240px 0.75 (floor)
360px 280px 432px (overflows) 280px 0.875
375px 295px 432px (overflows) 295px 0.922
≥1024px 460px 432px 432px 1.35 (cap)

Slot widths are read from the DOM. Below lg the graph fills its slot exactly; the 0.75 floor is reached right at 320px, so nothing narrower is left unhandled.

Notes

  • style over a Tailwind classscale-[clamp(…)] does not compile; the element rendered with transform: none. The same component already sets transform inline for the flow dots, and adapterGraphStyle() / adapterGraphPointStyle() are inline-style helpers, so this fits the file.
  • / 320px, not / 320 — dividing a length by a unitless number is rejected by the CSS parser; it has to be length ÷ length to yield a scalar.
  • ref={rootRef} stays on the scaled element, not the new wrapper, so Pause offscreen homepage adapter motion #1093's in-view observer keeps watching the same box it did before.

Verification

At each width above: scale, rendered width, and node bounds measured against the slot; flow-dot positions sampled via getBoundingClientRect() to confirm #1093's motion still runs and still pauses offscreen.

Summary by CodeRabbit

  • Improvements
    • The framework adapter graph now scales responsively to fit different viewport sizes.
    • The graph is centered within the available width for a more consistent viewing experience.
    • Existing animations, connections, nodes, and ports remain unchanged.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

FrameworkAdapterGraph now uses a centered, full-width container with container-width-based scaling capped between 0.75 and 1.35. Existing graph nodes, flows, ports, animation, and visibility behavior remain unchanged.

Changes

Responsive graph layout

Layer / File(s) Summary
Responsive graph container and scaling
src/routes/index.tsx
FrameworkAdapterGraph replaces the fixed 1.35 scale with clamped container-width scaling. The graph uses a centered full-width wrapper while retaining its existing rendering and motion behavior.

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

Possibly related PRs

  • TanStack/tanstack.com#1093: Both changes modify FrameworkAdapterGraph; this PR changes responsive layout, while the related PR changes its animation loops.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes scaling the adapter graph to the available width, which is the main change.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/adapter-graph-mobile-scale

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

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 4, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
tanstack-com 4d4fd51 Commit Preview URL

Branch Preview URL
Aug 05 2026, 02:11 AM

@sukvvon sukvvon self-assigned this Aug 5, 2026
@sukvvon sukvvon changed the title fix(routes/index): scale down the adapter graph on small screens fix(routes/index): scale the adapter graph to its container Aug 5, 2026
@sukvvon sukvvon changed the title fix(routes/index): scale the adapter graph to its container fix(routes/index): scale the adapter graph to the available width Aug 5, 2026
@sukvvon
sukvvon marked this pull request as ready for review August 5, 2026 01:55
@sukvvon
sukvvon requested a review from a team August 5, 2026 01:56

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/routes/index.tsx`:
- Line 621: Update the graph transform scale calculation at the visible
transform declaration to use an 80px viewport offset instead of 64px, and lower
the clamp minimum from 0.8 to 0.75. Preserve the existing maximum scale and
overall responsive scaling behavior.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: a53e3b1f-2d54-4771-af42-e651af62fa50

📥 Commits

Reviewing files that changed from the base of the PR and between 3321b67 and 9adc175.

📒 Files selected for processing (1)
  • src/routes/index.tsx

Comment thread src/routes/index.tsx Outdated
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