Skip to content

Fix benchmark bar chart scale on mobile - #555

Open
worldsoup wants to merge 1 commit into
mainfrom
mobile-benchmark-chart-fix
Open

Fix benchmark bar chart scale on mobile#555
worldsoup wants to merge 1 commit into
mainfrom
mobile-benchmark-chart-fix

Conversation

@worldsoup

Copy link
Copy Markdown
Contributor

Summary

  • The Benchmark component's bar rows used fixed 90px/170px side columns, which on narrow viewports left the actual bar track only ~51px wide — the chart looked broken/squished on mobile.
  • Below 480px: shrink those columns to 64px/76px, stack the ops-value and relative-speed labels vertically instead of side-by-side, and scale down a few font sizes to fit without wrapping or overflowing.
  • Shortened the axis caption from "operations / second" to "ops/second".

Test plan

  • Verified at 375px width (iPhone-class) on GET and DEL (widest throughput numbers, e.g. 10,250,000) — no text overflow/wrapping, bar track grew from 51px to ~187px.
  • Verified desktop layout is unchanged.
  • tsc --noEmit and yarn docusaurus build both pass clean against latest main.

🤖 Generated with Claude Code

The fixed 90px/170px side columns left almost no room for the actual
bar track on narrow viewports (down to ~51px). Below 480px, shrink
those columns, stack the value/relative labels vertically to reclaim
horizontal space, and reduce a few font sizes accordingly.

Also shortens "operations / second" to "ops/second" under the axis.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
documentation Ready Ready Preview Aug 6, 2026 4:52pm

Request Review

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix Benchmark bar chart scale on mobile

🐞 Bug fix ✨ Enhancement 🕐 10-20 Minutes

Grey Divider

AI Description

• Make Benchmark bar rows responsive so the bar track isn’t squished on narrow screens.
• Stack ops/relative labels and reduce font sizes below 480px to prevent overflow.
• Shorten the x-axis caption to “ops/second” for tighter layouts.
Diagram

graph TD
  A["Benchmark component"] --> B["styles.module.css"] --> C{"Viewport < 480px?"}
  C --> D["Desktop: 90/170 cols"]
  C --> E["Mobile: 64/76 cols"] --> F["Stack ops + rel"] --> G["Smaller fonts/caption"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Use fluid column widths via clamp()/min()
  • ➕ Avoids a hard breakpoint; adapts more smoothly across device widths
  • ➕ Potentially fewer future tweaks as content widths change
  • ➖ Harder to reason about and tune than a single breakpoint
  • ➖ Still may require stacking rules for extreme narrow widths
2. Container queries (instead of viewport media query)
  • ➕ More robust if Benchmark is embedded in narrow sidebars/cards on desktop
  • ➕ Decouples layout from global viewport width
  • ➖ May require additional build/compat considerations depending on target browsers/tooling
  • ➖ Adds conceptual complexity vs a simple @media rule

Recommendation: The current approach (a single 480px breakpoint + stacking) is the best fit for a docs UI: it’s predictable, low-risk, and directly addresses the squished bar-track issue. If the component is later reused in variable-width containers, consider migrating the breakpoint to a container query or using clamp()-based column sizing.

Files changed (2) +39 / -2

Bug fix (2) +39 / -2
index.tsxAdd ops value styling hook and tighten axis caption +4/-2

Add ops value styling hook and tighten axis caption

• Adds a dedicated .opsValue class on the ops number span so mobile-specific typography can target it cleanly. Shortens the axis caption text from “operations / second” to “ops/second” to reduce horizontal/vertical pressure on small screens.

src/components/Benchmark/index.tsx

styles.module.cssResponsive grid/typography adjustments for mobile benchmark chart +35/-0

Responsive grid/typography adjustments for mobile benchmark chart

• Introduces a max-width 480px breakpoint that reduces the row/axis side columns and gap to reclaim bar-track width. Switches the value block to vertical stacking and scales down several font sizes (name, ops value, relative label, axis labels/caption) to prevent wrapping/overflow on narrow viewports.

src/components/Benchmark/styles.module.css

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

To customize comments, go to the Qodo configuration screen, or learn more in the docs.

Qodo Logo

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