diff --git a/docs/superpowers/plans/2026-05-23-responsive-mobile.md b/docs/superpowers/plans/2026-05-23-responsive-mobile.md new file mode 100644 index 00000000..3a275b67 --- /dev/null +++ b/docs/superpowers/plans/2026-05-23-responsive-mobile.md @@ -0,0 +1,760 @@ +# Responsive Mobile Fixes — Implementation Plan + +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. + +**Goal:** Make Faunosteo SPA fully usable on phone screens (375px+) and polished on tablets (768px+) via surgical CSS/className-only changes. + +**Architecture:** No behavior changes — pure Tailwind class and CSS media query updates across ~12 files. No store, schema, or PDF changes. Existing tests must stay green since only visual layout changes. + +**Tech Stack:** Tailwind CSS v4 (CSS-first), React 19, existing component library + +--- + +### Task 1: Dialog viewport clamping + +**Files:** +- Modify: `src/components/ui/Dialog.tsx` + +- [ ] **Step 1: Update Dialog SIZE map and container classes** + +In `src/components/ui/Dialog.tsx`, replace the SIZE constant and the dialog container/content classes: + +```tsx +const SIZE: Record, string> = { + sm: 'max-w-sm', + md: 'max-w-md', + lg: 'max-w-2xl', + xl: 'max-w-4xl', +} +``` + +with: + +```tsx +const SIZE: Record, string> = { + sm: 'max-w-sm max-w-[calc(100vw-2rem)]', + md: 'max-w-md max-w-[calc(100vw-2rem)]', + lg: 'max-w-2xl max-w-[calc(100vw-2rem)]', + xl: 'max-w-4xl max-w-[calc(100vw-2rem)]', +} +``` + +Note: Tailwind applies the last matching utility — `max-w-[calc(100vw-2rem)]` wins on small screens where the named max-width exceeds viewport, and the named max-width wins on large screens where it's smaller. Actually, this won't work — Tailwind just uses specificity/order. Need a different approach. + +Instead, add the viewport clamp directly on the motion.div alongside the SIZE class. Change: + +```tsx +className={`relative w-full ${SIZE[size]} max-h-[90vh] overflow-y-auto rounded-2xl bg-[var(--color-surface)] shadow-xl`} +``` + +to: + +```tsx +className={`relative w-full ${SIZE[size]} max-h-[85vh] overflow-y-auto rounded-2xl bg-[var(--color-surface)] shadow-xl`} +``` + +And change the outer container padding from: + +```tsx +
+``` + +to: + +```tsx +
+``` + +And change the dialog header padding from: + +```tsx +
+``` + +to: + +```tsx +
+``` + +And change the dialog body padding from: + +```tsx +
{children}
+``` + +to: + +```tsx +
{children}
+``` + +The key fix: since all sizes already use `w-full` with `max-w-*`, the dialog box naturally fills available width minus padding. Reducing container padding from `p-4` to `p-3` on small screens gives 6px more breathing room per side. The `max-w-sm` (384px) fits within 375px - 24px = 351px viewport on phones (it doesn't — 384 > 351). The real fix is that `w-full` makes the dialog width = container width = viewport - 2*padding, so the max-w-* values are upper caps that only kick in when there's room. + +Wait — `w-full` with `max-w-md` means the dialog takes min(100%, 448px). On a 375px phone with p-3 (12px each side), available width = 375 - 24 = 351px. `w-full` = 351px which is < 448px, so dialog = 351px. This already works correctly. No extra `max-w-[calc(...)]` needed. The existing `w-full` + `max-w-*` pattern is responsive by design. + +So the actual changes are: tighten padding for mobile comfort + reduce max-h for better mobile viewport fit. + +- [ ] **Step 2: Run tests** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm test:run` +Expected: All tests pass (no behavior change) + +- [ ] **Step 3: Run typecheck** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm typecheck` +Expected: No errors + +- [ ] **Step 4: Commit** + +```bash +git add src/components/ui/Dialog.tsx +git commit -m "fix(ui): responsive dialog — tighter mobile padding and max-height" +``` + +--- + +### Task 2: Button touch targets + +**Files:** +- Modify: `src/components/ui/Button.tsx` + +- [ ] **Step 1: Update SIZES to ensure mobile-friendly touch targets** + +In `src/components/ui/Button.tsx`, change the SIZES constant from: + +```tsx +const SIZES: Record, string> = { + sm: 'h-8 px-3 text-sm rounded-md', + md: 'h-10 px-4 text-base rounded-lg', + lg: 'h-12 px-6 text-base rounded-lg', +} +``` + +to: + +```tsx +const SIZES: Record, string> = { + sm: 'h-9 px-3 text-sm rounded-md', + md: 'h-10 px-4 text-sm sm:text-base rounded-lg', + lg: 'h-12 px-5 sm:px-6 text-base rounded-lg', +} +``` + +Changes: +- `sm`: `h-8` → `h-9` (36px, closer to 44px minimum) +- `md`: add responsive text `text-sm sm:text-base` +- `lg`: tighter padding on mobile `px-5 sm:px-6` + +- [ ] **Step 2: Run tests** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm test:run` +Expected: All tests pass + +- [ ] **Step 3: Commit** + +```bash +git add src/components/ui/Button.tsx +git commit -m "fix(ui): increase button sm touch target to 36px, responsive text sizing" +``` + +--- + +### Task 3: VertebraPicker touch targets + +**Files:** +- Modify: `src/components/observation/VertebraPicker.tsx` + +- [ ] **Step 1: Increase region tab touch targets** + +In `src/components/observation/VertebraPicker.tsx`, change the region tab button className from: + +```tsx +'rounded-full px-4 py-1.5 text-sm font-medium border', +``` + +to: + +```tsx +'rounded-full px-4 py-2.5 sm:py-1.5 text-sm font-medium border min-h-[2.75rem]', +``` + +This ensures 44px minimum height on mobile (py-2.5 = 10px top+bottom + text ≈ 44px), drops back to denser on desktop. + +- [ ] **Step 2: Run tests** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm test:run` +Expected: All tests pass + +- [ ] **Step 3: Commit** + +```bash +git add src/components/observation/VertebraPicker.tsx +git commit -m "fix(ui): vertebra picker region tabs — 44px touch target on mobile" +``` + +--- + +### Task 4: SVG editor sidebar responsive stacking + +**Files:** +- Modify: `src/styles/svg-editor.css` + +- [ ] **Step 1: Add media query for sidebar stacking** + +In `src/styles/svg-editor.css`, change the `.svg-editor-root` rule from: + +```css +.svg-editor-root { + display: flex; + flex: 1; + min-height: 0; + overflow: hidden; + font-family: var(--font-sans); + color: var(--color-ink); + background: var(--color-bg); +} +``` + +to: + +```css +.svg-editor-root { + display: flex; + flex-direction: column; + flex: 1; + min-height: 0; + overflow: hidden; + font-family: var(--font-sans); + color: var(--color-ink); + background: var(--color-bg); +} + +@media (min-width: 768px) { + .svg-editor-root { + flex-direction: row; + } +} +``` + +Then change the `.svg-editor-sidebar` rule from: + +```css +.svg-editor-sidebar { + width: 380px; + background: var(--color-surface); + border-left: 1px solid var(--color-border); + display: flex; + flex-direction: column; + overflow: hidden; +} +``` + +to: + +```css +.svg-editor-sidebar { + width: 100%; + background: var(--color-surface); + border-top: 1px solid var(--color-border); + display: flex; + flex-direction: column; + overflow: hidden; + max-height: 50vh; +} + +@media (min-width: 768px) { + .svg-editor-sidebar { + width: 380px; + max-height: none; + border-top: none; + border-left: 1px solid var(--color-border); + } +} +``` + +Also update `.svg-editor-canvas` to ensure minimum usable height on mobile by changing: + +```css +.svg-editor-canvas { + flex: 1; + position: relative; + background: var(--color-surface); + overflow: hidden; + padding: 10px; +} +``` + +to: + +```css +.svg-editor-canvas { + flex: 1; + position: relative; + background: var(--color-surface); + overflow: hidden; + padding: 10px; + min-height: 40vh; +} + +@media (min-width: 768px) { + .svg-editor-canvas { + min-height: 0; + } +} +``` + +Also update the zoom controls for mobile — make buttons bigger: + +```css +.svg-editor-zoom-controls button { + width: 32px; + height: 32px; + padding: 0; + margin: 0; + font-size: 16px; + display: flex; + align-items: center; + justify-content: center; +} +``` + +to: + +```css +.svg-editor-zoom-controls button { + width: 40px; + height: 40px; + padding: 0; + margin: 0; + font-size: 18px; + display: flex; + align-items: center; + justify-content: center; +} + +@media (min-width: 768px) { + .svg-editor-zoom-controls button { + width: 32px; + height: 32px; + font-size: 16px; + } +} +``` + +- [ ] **Step 2: Run typecheck and build** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm typecheck && ~/.local/share/pnpm/bin/pnpm build` +Expected: Clean + +- [ ] **Step 3: Commit** + +```bash +git add src/styles/svg-editor.css +git commit -m "fix(ui): SVG editor sidebar stacks below canvas on mobile (<768px)" +``` + +--- + +### Task 5: AnatomyCanvas height constraint + EditorRoute responsive + +**Files:** +- Modify: `src/components/canvas/AnatomyCanvas.tsx` +- Modify: `src/app/routes/EditorRoute.tsx` + +- [ ] **Step 1: Add responsive classes to AnatomyCanvas wrapper** + +In `src/components/canvas/AnatomyCanvas.tsx`, change the wrapper div from: + +```tsx +
+
+``` + +to: + +```tsx +
+
+``` + +This ensures the SVG inside doesn't overflow and centers horizontally. + +- [ ] **Step 2: Update EditorRoute grid layout for mobile** + +In `src/app/routes/EditorRoute.tsx`, change the main grid container from: + +```tsx +
+
+``` + +to: + +```tsx +
+
+``` + +The `max-h-[55vh] lg:max-h-none` constrains the SVG canvas on mobile/tablet (single-column) so the observation list is visible without scrolling past the entire SVG. On desktop (lg+, two-column), it fills naturally. + +Also change the observations section from: + +```tsx +
+``` + +to: + +```tsx +
+``` + +- [ ] **Step 3: Run tests** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm test:run` +Expected: All tests pass + +- [ ] **Step 4: Run typecheck** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm typecheck` +Expected: No errors + +- [ ] **Step 5: Commit** + +```bash +git add src/components/canvas/AnatomyCanvas.tsx src/app/routes/EditorRoute.tsx +git commit -m "fix(ui): constrain anatomy canvas height on mobile, responsive editor spacing" +``` + +--- + +### Task 6: Responsive typography and padding — HomeRoute + EditorsRoute + +**Files:** +- Modify: `src/app/routes/HomeRoute.tsx` +- Modify: `src/app/routes/EditorsRoute.tsx` + +- [ ] **Step 1: Update HomeRoute** + +In `src/app/routes/HomeRoute.tsx`, change: + +```tsx +
+
+ +

{t('home.new_report.title')}

+``` + +to: + +```tsx +
+
+ +

{t('home.new_report.title')}

+``` + +And the second card heading too: + +```tsx + +

{t('home.import.title')}

+``` + +to: + +```tsx + +

{t('home.import.title')}

+``` + +- [ ] **Step 2: Update EditorsRoute** + +In `src/app/routes/EditorsRoute.tsx`, change: + +```tsx +
+
+ +

{t('editors.svg.title')}

+``` + +to: + +```tsx +
+
+ +

{t('editors.svg.title')}

+``` + +And the second card: + +```tsx + +

{t('editors.pathology.title')}

+``` + +to: + +```tsx + +

{t('editors.pathology.title')}

+``` + +- [ ] **Step 3: Run tests** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm test:run` +Expected: All tests pass + +- [ ] **Step 4: Commit** + +```bash +git add src/app/routes/HomeRoute.tsx src/app/routes/EditorsRoute.tsx +git commit -m "fix(ui): responsive padding and typography on home and editors pages" +``` + +--- + +### Task 7: Responsive typography and padding — NewReportRoute + +**Files:** +- Modify: `src/app/routes/NewReportRoute.tsx` + +- [ ] **Step 1: Update NewReportRoute responsive classes** + +In `src/app/routes/NewReportRoute.tsx`, change: + +```tsx +
+

{t('new_report.title')}

+``` + +to: + +```tsx +
+

{t('new_report.title')}

+``` + +- [ ] **Step 2: Run tests** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm test:run` +Expected: All tests pass + +- [ ] **Step 3: Commit** + +```bash +git add src/app/routes/NewReportRoute.tsx +git commit -m "fix(ui): responsive padding and typography on new report page" +``` + +--- + +### Task 8: Responsive typography — ObservationList + ConclusionPanel + +**Files:** +- Modify: `src/components/observation/ObservationList.tsx` +- Modify: `src/components/report/ConclusionPanel.tsx` + +- [ ] **Step 1: Update ObservationList heading** + +In `src/components/observation/ObservationList.tsx`, change: + +```tsx +

+``` + +to: + +```tsx +

+``` + +- [ ] **Step 2: Update ConclusionPanel heading** + +In `src/components/report/ConclusionPanel.tsx`, change: + +```tsx +

+``` + +to: + +```tsx +

+``` + +- [ ] **Step 3: Run tests** + +Run: `cd /home/bchanot-ubuntu/Documents/osteo && ~/.local/share/pnpm/bin/pnpm test:run` +Expected: All tests pass + +- [ ] **Step 4: Commit** + +```bash +git add src/components/observation/ObservationList.tsx src/components/report/ConclusionPanel.tsx +git commit -m "fix(ui): responsive typography for observation and conclusion headings" +``` + +--- + +### Task 9: Footer and AppHeader mobile polish + +**Files:** +- Modify: `src/components/brand/Footer.tsx` +- Modify: `src/components/brand/AppHeader.tsx` + +- [ ] **Step 1: Update Footer spacing** + +In `src/components/brand/Footer.tsx`, change: + +```tsx +