Skip to content

Fit array visualizers on phones - #64

Open
A7med7x7 wants to merge 1 commit into
mainfrom
autopilot/fit-array-visualizers
Open

A7med7x7 wants to merge 1 commit into
mainfrom
autopilot/fit-array-visualizers

Conversation

@A7med7x7

@A7med7x7 A7med7x7 commented Nov 5, 2026

Copy link
Copy Markdown
Member

Quality item 9 (from the visualizer audit in #54): array visualizers too wide on phones.

The problem

ArrayCells, the array stepper behind linear and binary search (Algorithm Design, and Advanced Algorithms ×2), min-max, randomized select and quicksort, gave each cell a fixed 34 px minimum. A 15-element array needed about 570 px, so on a 390 px phone it scrolled sideways by up to 266 px and you couldn't see the whole array at once.

The fix

  • Below the sm breakpoint only: cells shrink to fit their widest value (18 px for two-digit numbers, wider for longer ones), with 2 px gaps and 11 px text. A 15-cell array now fits in one row.
  • Desktop is unchanged (34 px cells, text-sm, 4 px gaps).
  • Pointer names (low, mid, high, i, j…) are now stacked one per line and never broken mid-word. In a narrow cell, "high" used to wrap into "hig / h".

A bug I caught along the way

My first version set the CSS variable on the inner grid but read it on the wrapper, so the column template was invalid and the grid collapsed into one vertical column. Overflow numbers alone said "fits", but the screenshot showed the collapse, so the measurement now also checks that all cells sit on one row. The version in this PR passes both checks.

Measured at 390 px (Playwright, production build)

Lesson Before After
Algorithm Design linear-and-binary-search +38 / +266 px fits
Advanced Algorithms counting-the-basic-operation +266 / +266 px fits
Advanced Algorithms solving-recurrences (binary search) +266 px fits
Advanced Algorithms lab-algorithm-analysis (min-max) +284 px fits

At 1280 px nothing scrolls, before or after.

Still open (other components, for a later run)

  • Skip lists, SkipListVisualizer: +184 px
  • Discrete Mathematics loop invariants, a separate binary-search component: +136 px
  • The recursion-tree tables (item 11) are unchanged.

Also noted

main commit 4c0af73 edited algorithm-design-and-analysis/m1-05-sorting-quiz.mdx, which #53 moves into the question bank. #53 will need a rebase and a re-check of that quiz's questions; the next exam run does that.

Checked

npm run lint (0 errors), tsc (app and node), npm run test (49 files, 2,427 tests), npm run build.


Generated by Claude Code

The visualizer audit found the array stepper (linear and binary search,
min-max, select, quicksort) up to 266 px wider than a phone. Cells had
a fixed 34 px minimum, so 15 elements needed about 570 px.

Below the sm breakpoint, cells now shrink to fit their widest value
(18 px for two digits) with tighter gaps and 11 px text, so a 15-cell
array fits a 390 px screen in one row. Desktop sizes are unchanged.
Pointer names (low, mid, high) are stacked one per line and never
broken mid-word, since a narrow cell used to wrap "high" into "hig h".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EC6Zzt5akQu7TEHdGquZzp

This branch has not been deployed

No deployments
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.

2 participants