Plan — Vitals UI sophistication roadmap (four tiers + mobile-first)
Version: 1.2.1
Last Updated: 2026-06-16 08:59:24
Status: Complete — Tiers 1, 1b, 2, and 4 shipped; Tier 3 (Rive droplet) deferred — SVG fallback is launch-ready
Parent specs: 2026-06-10-watch-closely-measurements-design.md · 03-DESIGN-SYSTEM.md
Scope: Vitals intake/output capture (urine + bowel), trend charts, and shared Calm Care elevation tokens that lift the whole app
1. Goal
Section titled “1. Goal”Move LynCareOS vitals capture from functional but visually basic to reference-grade sophistication — matching the depth, polish, and metaphor quality of the urine beaker work already shipped — while treating mobile as the primary surface (majority of carers log on phones).
Non-negotiables
| Rule | Why |
|---|---|
| Do not regress the urine beaker + fluid fill | Already signed off; geometry and blend are production-quality |
| Mobile-first layout and touch targets | ≥44×44 px; one-hand use; minimal vertical scroll in capture |
| No new GPL/AGPL dependencies | Project licensing rule |
| No third-party cloud embeds on PHI screens | Rive/SVG/Motion run client-side only |
| Presentation-only changes unless spec requires API work | Same IntakeOutputCreate payloads and bands |
| WCAG 2.1 AA | Colour + shape/label for clinical status; contrast on swatches |
2. Current state (June 2026)
Section titled “2. Current state (June 2026)”2.1 What is already strong
Section titled “2.1 What is already strong”| Area | Location | Notes |
|---|---|---|
| Photoreal beaker + SVG liquid | UrineVolumeBeaker.tsx, urineBeakerConstants.ts | Hybrid PNG shell + clipped liquid; do not replace |
| Urine trend stacked bars | UrineTrendChart.tsx, intakeOutputTrendModel.ts | mL axis, colour segments, rounded tops |
| Bristol PNG selector | BristolStoolSelector.tsx, public/assets/bristol/ | 7 types, tone rings |
| Daily entry visuals | UrineEntryStrip.tsx, BowelEntryVisual.tsx | Replace plain text in today’s list |
| Calm Care foundation | 03-DESIGN-SYSTEM.md, cc-* classes | Tokens exist; vitals not fully on elevation scale |
| Stack fit | package.json | Headless UI, Lucide, ECharts, Sharp — no shadcn migration needed |
2.2 Mobile pain points (why it “doesn’t look good” on phone)
Section titled “2.2 Mobile pain points (why it “doesn’t look good” on phone)”The desktop-oriented three-column urine panel (UrineCapturePanel.tsx: slider | beaker | colour) stacks on mobile into a very tall column (~900–1100 px before Save):
| Issue | Component | Impact on mobile |
|---|---|---|
| Three-column → stack | UrineCapturePanel | Excessive scroll; beaker loses “hero” focus |
| Fixed 252 px colour strip | UrineColourSelector | Too tall beside labels; horizontal space wasted |
| Vertical volume slider | index.css .urine-volume-slider | Awkward thumb reach; narrow hit area |
| Inline expand in section | IntakeOutputSection | Competes with “Urine today” + “Bowel today” + entries |
| 2×4 Bristol grid | BristolStoolSelector | Acceptable but long; type 7 off-screen without scroll |
| Small preset chips | URINE_VOLUME_PRESETS_ML buttons | Some chips <44 px height |
| Text-only “last recorded” | IntakeOutputSection | Misses visual parity with capture UI |
Design principle for mobile: one hero graphic per step, controls below or beside (never three heavy panels stacked), sticky primary action, optional stepped flow when height > ~70vh.
3. Four-tier roadmap (summary)
Section titled “3. Four-tier roadmap (summary)”| Tier | Name | Outcome | Effort | Priority |
|---|---|---|---|---|
| 1 | Design tokens & surfaces | Consistent elevation, radius, surface gradients app-wide | 3–5 days | P0 |
| 1b | Mobile-first vitals capture | Phone-native urine + bowel flows; beaker unchanged | 5–7 days | P0 |
| 2 | Motion | Fill, selection, panel enter/exit; prefers-reduced-motion | 3–5 days | P1 |
| 3 | Rive hero graphics | Designer-driven droplet/slider states; optional thermometer later | 7–10 days | P2 |
| 4 | ECharts polish | Softer grids, token colours, shared tooltip chrome | 3–4 days | P1 (can parallel Tier 1) |
Recommended delivery order: Tier 1 → Tier 1b (mobile) → Tier 2 + Tier 4 in parallel → Tier 3 when a Rive asset pipeline is ready.
4. Tier 1 — Design tokens & surfaces (detailed)
Section titled “4. Tier 1 — Design tokens & surfaces (detailed)”4.1 Intent
Section titled “4.1 Intent”~70% of “premium” feel is consistent depth and spacing, not new libraries. Extend Calm Care with a named elevation scale and vitals-specific surface utilities so urine/bowel cards match the reference mockup (soft multi-layer shadows, rounded-2xl, restrained borders).
4.2 Tasks
Section titled “4.2 Tasks”| ID | Task | Files | Done when |
|---|---|---|---|
| T1-1 | Add elevation tokens shadow-elev-1 … shadow-elev-3 (+ dark variants) | tailwind.config.js, index.css :root --cc-shadow-* | Documented in 03-DESIGN-SYSTEM.md §Components |
| T1-2 | Add surface utilities cc-surface, cc-surface-float (white + subtle top gradient + elev-1) | index.css | Used on vitals capture cards |
| T1-3 | Standardise radius: cards rounded-2xl, chips rounded-full, inner wells rounded-xl | Vitals components | No mixed rounded-lg on new vitals work |
| T1-4 | Vitals accent mapping: urine = brand, bowel = amber/healing, concern = coral | Constants or small vitalsTheme.ts | Single import for section headers |
| T1-5 | Replace ad-hoc border shadow-sm on urine panel with cc-surface-float | UrineCapturePanel, UrineColourSelector, IntakeOutputSection | Visual match on 390×844 viewport |
| T1-6 | Touch target audit script or checklist row in PR template | docs/plans/… or validate:architecture note | Presets & flag chips ≥44 px min-height |
4.3 Token sketch (implementation reference)
Section titled “4.3 Token sketch (implementation reference)”/* index.css — additive, do not remove shadow-soft */:root { --cc-shadow-elev-1: 0 1px 2px rgba(37, 48, 59, 0.06), 0 4px 12px rgba(37, 48, 59, 0.06); --cc-shadow-elev-2: 0 2px 4px rgba(37, 48, 59, 0.06), 0 8px 24px rgba(37, 48, 59, 0.08); --cc-shadow-elev-3: 0 4px 8px rgba(37, 48, 59, 0.08), 0 16px 40px rgba(37, 48, 59, 0.10);}4.4 Verification
Section titled “4.4 Verification”npm run build+npm run lint:strict- Manual: iPhone 14 / Pixel 7 widths in DevTools + one real device
npm run test:a11yon vitals route (no new violations)
5. Tier 1b — Mobile-first vitals capture (detailed)
Section titled “5. Tier 1b — Mobile-first vitals capture (detailed)”5.1 Target mobile layouts
Section titled “5.1 Target mobile layouts”Urine capture — mobile (<640 px)
Section titled “Urine capture — mobile (<640 px)”Layout rules
| Element | Mobile behaviour | Desktop (≥640 px) |
|---|---|---|
| Beaker | Center, max-w-[280px], top of flow | Center column, current size |
| Volume control | Horizontal slider under beaker (filled track) | Keep vertical slider left |
| Colour | Horizontal gradient strip + label below OR 2-step wizard | Vertical strip + labels right |
| Droplet | Inline 40 px beside selected label | Card below strip |
| Presets | Horizontal scroll, min-h-11 chips | Wrap row |
| Save/Cancel | Sticky bottom-0 safe-area padding | Inline in card |
Bowel capture — mobile
Section titled “Bowel capture — mobile”| Element | Mobile behaviour |
|---|---|
| Bristol grid | Single column large cards (full width) OR horizontal snap carousel for types 1–7 |
| Selected preview | Sticky mini-preview bar when type selected |
| Flags | Full-width wrap; min-h-11 |
| Save | Same sticky bar pattern as urine |
“Today” collapsed state
Section titled ““Today” collapsed state”| Section | Mobile behaviour |
|---|---|
| Last urine | UrineEntryStrip + time (not text band label only) |
| Last bowel | BowelEntryVisual thumbnail + one line |
| Record CTA | Full-width cc-btn-accent “Record urine” / “Record bowel” |
| Today’s entries | Compact rows; strip/visual max-height capped |
5.2 Implementation tasks
Section titled “5.2 Implementation tasks”| ID | Task | Files | Notes |
|---|---|---|---|
| M-1 | Add useMatchMedia('(max-width: 639px)') layout switch | UrineCapturePanel.tsx | Prop layout?: 'auto' default |
| M-2 | UrineVolumeSliderHorizontal — reuse --urine-fill CSS | New UrineVolumeSlider.tsx, index.css | Shared thumb styles with vertical |
| M-3 | UrineColourSelector mobile variant — horizontal strip, labels under or tooltip | UrineColourSelector.tsx | Strip height ~48–56 px; tap targets full band |
| M-4 | Optional 2-step stepper on mobile: Volume → Colour | UrineCapturePanel.tsx | Reduces single-page height ~40% |
| M-5 | VitalsCaptureSheet wrapper — full-bleed on mobile when recording | IntakeOutputSection.tsx or new component | fixed inset-0 z-40 + scroll body; desktop stays inline |
| M-6 | Sticky action bar component | components/ui/StickyActionBar.tsx | Cancel + primary; safe-area |
| M-7 | Bristol mobile carousel option (CSS scroll-snap) | BristolStoolSelector.tsx | grid-cols-1 fallback; carousel @media max-sm |
| M-8 | Visual “last recorded” for urine | IntakeOutputSection.tsx | Mirror bowel row pattern |
| M-9 | Playwright mobile screenshots | e2e/panel-screenshots.spec.ts or vitals spec | 390×844 baseline images |
5.3 Mobile acceptance criteria
Section titled “5.3 Mobile acceptance criteria”- Urine capture open: beaker visible without scrolling on 390×844 (iPhone 14)
- Primary save reachable with thumb (sticky bar or within 1 scroll)
- All interactive targets ≥44×44 px (WCAG 2.5.5 target size)
- Colour selection readable: label + shape (not colour alone)
- Bristol type selectable in ≤2 swipes if carousel; all types reachable
- No horizontal page scroll at 320 px width
- Dark mode parity on all above
5.4 Explicit out of scope (Tier 1b)
Section titled “5.4 Explicit out of scope (Tier 1b)”- Changing beaker interior geometry or shell PNG
- New API fields or mL column in Postgres
- Replacing ECharts with another chart library
6. Tier 2 — Motion (detailed)
Section titled “6. Tier 2 — Motion (detailed)”6.1 Dependency
Section titled “6.1 Dependency”cd frontend && npm install motionImport from motion/react (not legacy framer-motion).
6.2 Tasks
Section titled “6.2 Tasks”| ID | Task | Where | Motion pattern |
|---|---|---|---|
| MO-1 | Beaker fill level transition | UrineVolumeBeaker liquid rect/ellipse | motion animate y/height or keep CSS transition + spring on wrapper |
| MO-2 | Current volume count-up | UrineCapturePanel | useMotionValue + formatted mL (respect reduced motion → instant) |
| MO-3 | Colour knob + label | UrineColourSelector | layoutId on selection ring |
| MO-4 | Bristol card select | BristolStoolSelector | whileTap={{ scale: 0.98 }}, ring fade |
| MO-5 | Capture sheet enter/exit | VitalsCaptureSheet | AnimatePresence slide up |
| MO-6 | Global reduced-motion | useReducedMotion() hook wrapper | Skip springs when true; Tailwind motion-reduce: on CSS |
6.3 Verification
Section titled “6.3 Verification”- Lighthouse performance on vitals page (no major regression)
- Manual: iOS Safari — no jank during slider drag
prefers-reduced-motion: reduce— animations disabled or ≤200 ms fade only
7. Tier 3 — Rive hero graphics (detailed)
Section titled “7. Tier 3 — Rive hero graphics (detailed)”7.1 When to use Rive vs hand-built SVG
Section titled “7.1 When to use Rive vs hand-built SVG”| Asset | Recommendation | Rationale |
|---|---|---|
| Urine beaker + fluid | Keep current SVG + PNG | Signed off; Rive migration high risk for little gain |
| Colour droplet | Rive candidate | Gloss, highlight, subtle wobble on select |
| Volume slider thumb | Optional Rive | Only if designer delivers state machine |
| Bristol type highlight | CSS + PNG | Already good; Rive overkill |
| Thermometer (fever band) | Future Rive | Per watch-closely spec §2.1 |
7.2 Dependency
Section titled “7.2 Dependency”npm install @rive-app/react-canvasRuntime is client-only; bundle ~80–100 KB — lazy-load on vitals route.
7.3 Pipeline
Section titled “7.3 Pipeline”| ID | Task | Owner |
|---|---|---|
| R-1 | Create ColourDropletRive.tsx with fallback to SVG ColourDroplet | Dev |
| R-2 | Design droplet .riv (idle + selected states) | Design |
| R-3 | Wire colour enum → Rive input | Dev |
| R-4 | Document asset export settings in docs/02…/assets/vitals/README.md | Dev |
7.4 Guardrails
Section titled “7.4 Guardrails”- Fallback SVG always renders if Rive fails to load
- No Rive Cloud hosted URLs in production
- Test on mid-range Android (Carer phone profile)
8. Tier 4 — ECharts polish (detailed)
Section titled “8. Tier 4 — ECharts polish (detailed)”8.1 Tasks
Section titled “8.1 Tasks”| ID | Task | Files |
|---|---|---|
| E-1 | Centralise chart theme object from --cc-* tokens | frontend/src/lib/chartTheme.ts (extend if exists) |
| E-2 | Urine stacked bars: softer grid, token font, tooltip cc-surface styling | UrineTrendChart.tsx |
| E-3 | Bristol trend: shape markers + colour not sole signal | BristolStoolTrendChart.tsx |
| E-4 | Mobile chart height + axis label rotation | Trend panels in cancer module + vitals |
| E-5 | Weekly date strip already mobile — verify touch targets | DayDateStrip.tsx |
9. File map (primary touchpoints)
Section titled “9. File map (primary touchpoints)”| File | Tiers |
|---|---|
frontend/tailwind.config.js | 1 |
frontend/src/index.css | 1, 2 |
frontend/src/components/vitals/UrineCapturePanel.tsx | 1b, 2 |
frontend/src/components/vitals/UrineVolumeBeaker.tsx | 2 only (motion on liquid; no geometry changes) |
frontend/src/components/vitals/UrineColourSelector.tsx | 1, 1b, 2, 3 |
frontend/src/components/vitals/UrineVolumeSlider.tsx (new) | 1b |
frontend/src/components/vitals/BristolStoolSelector.tsx | 1, 1b, 2 |
frontend/src/components/vitals/IntakeOutputSection.tsx | 1b |
frontend/src/components/ui/StickyActionBar.tsx (new) | 1b |
frontend/src/lib/chartTheme.ts | 4 |
docs/02 - ARCHITECTURE_DESIGN/03-DESIGN-SYSTEM.md | 1 (§ update) |
10. Phased delivery checklist
Section titled “10. Phased delivery checklist”Phase A — Foundation + mobile urine (Week 1)
Section titled “Phase A — Foundation + mobile urine (Week 1)”- T1-1 … T1-5 elevation tokens applied to vitals cards
- M-1, M-2, M-3 horizontal slider + mobile colour strip
- M-6 sticky save bar
- M-8 visual last urine row
- Build + lint + mobile manual QA
Phase B — Mobile bowel + capture sheet (Week 2)
Section titled “Phase B — Mobile bowel + capture sheet (Week 2)”- M-5 vitals capture sheet on mobile
- M-7 Bristol carousel / single-column
- M-4 optional urine stepper (if Phase A still too tall) — not needed; single-page mobile layout fits
- M-9 Playwright mobile screenshots
- Update
03-DESIGN-SYSTEM.mdvitals pattern subsection
Phase C — Motion + charts (Week 2–3)
Section titled “Phase C — Motion + charts (Week 2–3)”- MO-1 … MO-6 Motion integration
- E-1 … E-5 chart theme
-
test:a11ygreen — requires Playwright auth env + running dev stack
Phase D — Rive (optional, Week 3–4)
Section titled “Phase D — Rive (optional, Week 3–4)”- R-1 … R-4 droplet Rive with SVG fallback — deferred;
ColourDropletSVG ships instead - Performance check on 3G Fast throttling
11. Quality gates (every PR)
Section titled “11. Quality gates (every PR)”cd frontendnpm run validate:architecturenpm run lint:strictnpm run testnpm run buildnpm run test:a11y # when vitals routes touchedManual mobile matrix
| Viewport | Device reference |
|---|---|
| 390×844 | iPhone 14 |
| 360×800 | Android common |
| 320×568 | iPhone SE (minimum) |
Do not ship if urine beaker fill alignment regresses or mobile capture requires >2 full screens of scroll before Save.
12. Risks and mitigations
Section titled “12. Risks and mitigations”| Risk | Mitigation |
|---|---|
| Mobile layout swap breaks desktop | useMatchMedia + shared subcomponents; screenshot both breakpoints |
| Motion jank on slider drag | Animate fill via CSS where possible; Motion only on discrete state |
| Rive bundle size | Lazy load; SVG fallback |
| Colour contrast on gradient strip | WCAG check each swatch label; border on selected band |
| Scope creep into backend mL storage | Keep urine_volume_band mapping; mL is UI-only |
13. Success metrics (qualitative)
Section titled “13. Success metrics (qualitative)”- Product owner sign-off on 390×844 urine + bowel capture screenshots
- Carers can record urine in under 30 seconds with ≤1 scroll on mobile
- Visual parity between reference mockup sophistication and live UI (droplet, slider, cards) without copying AI mockup literally
- Beaker + fluid unchanged and still rated “production quality”
14. Next action (first PR)
Section titled “14. Next action (first PR)”PR1 — Tier 1 tokens + mobile urine layout shell
- Add
--cc-shadow-elev-*andcc-surface-float - Create
UrineVolumeSlider.tsx(horizontal + vertical) - Refactor
UrineCapturePanelmobile branch: beaker hero → horizontal slider → compact colour → sticky bar - Do not modify
UrineVolumeBeakergeometry in this PR
Estimated size: ~400–600 lines changed across 4–6 files.
15. Related documents to update after Phase B
Section titled “15. Related documents to update after Phase B”| Document | Update |
|---|---|
03-DESIGN-SYSTEM.md | New § Vitals capture patterns (mobile + desktop) |
2026-06-10-watch-closely-measurements-design.md | Mark urine/bowel UI phases complete |
05-DEVELOPER-GUIDE.md | Short note on Motion + optional Rive lazy load |
14-FRONTEND-PRESENTATION-STACK.md (new) | Canonical UI tools, patterns, vitals component map |
01-ARCHITECTURE.md | Stack table + cross-link to §14 |
00-INDEX.md | Link presentation stack doc |
16. Documentation workstream (architecture, design, full stack)
Section titled “16. Documentation workstream (architecture, design, full stack)”Implementation and documentation ship together. Each PR includes a doc gate (see vitals UI implementation plan (DOC0 section in this roadmap) DOC0 section).
16.1 New canonical doc: Frontend presentation stack
Section titled “16.1 New canonical doc: Frontend presentation stack”Path: docs/02 - ARCHITECTURE_DESIGN/14-FRONTEND-PRESENTATION-STACK.md
Why a separate doc: 01-ARCHITECTURE.md covers the full platform (FastAPI, Postgres, Docker, billing). 03-DESIGN-SYSTEM.md covers Calm Care visual language. Neither fully captures how we build sophisticated clinical UI — hybrid graphics, motion policy, chart theming, asset pipeline, mobile capture patterns.
Contents:
| Section | What it records |
|---|---|
| Stack inventory | Current frontend/package.json dependencies with purpose |
| Planned stack | Motion (Tier 2), Rive optional (Tier 3) |
| Non-adoptions | No shadcn, no React Query, no Spline on PHI screens |
| Rich UI patterns | Hybrid PNG+SVG beaker, SVG droplet, Bristol PNGs, CSS fill sliders |
| Mobile-first | Breakpoints (639px capture, 767px charts), capture sheet, sticky bar |
| Accessibility | WCAG 2.1 AA, colour+label, reduced motion, axe |
| Asset pipeline | public/assets/, sharp, svgo |
| Vitals component map | File → responsibility table |
| Quality gates | build, lint, test, test:a11y, mobile viewports |
16.2 Documents to update (ownership)
Section titled “16.2 Documents to update (ownership)”| Document | Updates |
|---|---|
| 01-ARCHITECTURE.md | Extend §Software development stack: Calm Care elevation, Motion, optional Rive, vitals hybrid graphics; link §14 |
| 03-DESIGN-SYSTEM.md | elev-1/2/3, cc-surface-float; § Vitals capture mobile/desktop; Phase 6 charts status |
| 05-DEVELOPER-GUIDE.md | New § Vitals intake/output development (files, breakpoints, adding clinical graphics) |
| 03-SOLUTION-DESIGN.md | Solution posture: mobile-first vitals, four-tier sophistication |
| 2026-06-10-watch-closely-measurements-design.md | §2.2–2.3 implementation status + component links |
| 00-INDEX.md | Presentation stack in design/architecture links |
| This roadmap | Phase checkboxes + version bump per merge |
16.3 Per-PR doc gates
Section titled “16.3 Per-PR doc gates”| PR | Documentation |
|---|---|
| PR1 | Design system elevation §; §14 skeleton; architecture link |
| PR2 | §14 component map; developer guide urine mobile |
| PR3 | Design system vitals capture §; watch-closely partial complete |
| PR4 | Developer guide screenshots + touch targets |
| PR5 | §14 Motion; architecture Motion row |
| PR6 | Chart theme in §14; watch-closely implemented; Phase 6 status |
16.4 Full presentation stack (reference)
Section titled “16.4 Full presentation stack (reference)”Current: React 19 · Vite 8 · TS · Tailwind 3.4 · Headless UI 2 · ECharts 6 · Lucide · date-fns · fetch/api.ts · useMatchMedia · sharp/svgo · Vitest/Playwright/axe
Tier 1 adds: cc-surface-float, shadow-elev-*, vitalsTheme.ts
Tier 2 adds: motion (motion/react)
Tier 3 adds (optional): @rive-app/react-canvas lazy + SVG fallback
Tier 4 extends: chartTheme.ts intake/output helpers
Frozen (do not replace): UrineVolumeBeaker hybrid implementation