Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.
JavaScript apple-watchbodyweightdockerfitnessfitness-trackergymhealthiosmcpnodejspasskeysprogressive-web-applicationspwareactself-hostedself-hostingvitewebauthnweightliftingworkout-tracker
Plan and Home: a small body map on every session, the muscles it hits lit up
Duarte Santos27042739d09c
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 58143ab40..3a9bcec75 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,10 @@ battery use on Unrestricted (Settings shows it as "Quick arrival check"). And ifworkout on your laptop that your phone hasn't synced yet, the phone asks your server first (3seconds at most) instead of nagging you anyway.+**See what a session hits before you start it.** Every routine on the Plan page (the week, the+rotation and the routine list) and today's session on Home now carry a tiny body, front and back,+with the muscles it works lit up. No more opening Leg Day to remember it is, in fact, legs.+**Security.** Follow-ups to v1.4.2's audit.- **Pairing the phone app asks you to confirm it's you** (passkey, or your password where thatcounts), like adding another device does. A copied browser session can no longer mint a phonediff --git a/frontend/src/components/MiniBodyMap.jsx b/frontend/src/components/MiniBodyMap.jsxnew file mode 100644index 000000000..3ae2355c6--- /dev/null+++ b/frontend/src/components/MiniBodyMap.jsx@@ -0,0 +1,12 @@+import { useMemo } from 'react'+import BodyMap from './BodyMap.jsx'+import { loadOfRoutine } from '../lib/muscles.js'++// A thumbnail of what one or more routines hit, for list rows (Plan's routines, Home's Today).+// Decoration beside the name: the row itself is the button, so the map is hidden from screen+// readers and takes no taps. Nothing at all for a routine that hits nothing yet.+export default function MiniBodyMap({ routines, body }) {+ const load = useMemo(() => loadOfRoutine({ ex: routines.flatMap(r => r?.ex || []) }), [routines])+ if (!Object.values(load).some(v => v > 0)) return null+ return <span className="bm-mini-wrap" aria-hidden="true"><BodyMap className="bm-mini" load={load} body={body} /></span>+}diff --git a/frontend/src/components/MiniBodyMap.test.jsx b/frontend/src/components/MiniBodyMap.test.jsxnew file mode 100644index 000000000..e94ac3ba6--- /dev/null+++ b/frontend/src/components/MiniBodyMap.test.jsx@@ -0,0 +1,30 @@+// @vitest-environment happy-dom+// The routine thumbnail: shaded like the big map, hidden from screen readers, nothing for an empty routine.+import React, { act } from 'react'+import { createRoot } from 'react-dom/client'+import { afterEach, beforeEach, describe, expect, it } from 'vitest'+import MiniBodyMap from './MiniBodyMap.jsx'++globalThis.IS_REACT_ACT_ENVIRONMENT = true+let host, root+beforeEach(() => { host = document.createElement('div'); document.body.appendChild(host); root = createRoot(host) })+afterEach(() => { act(() => root.unmount()); host.remove() })+const render = async el => { await act(async () => { root.render(el) }); for (let i = 0; i < 100 && host.querySelector('.bm-ph'); i++) await act(async () => { await new Promise(r => setTimeout(r, 20)) }) }++describe('MiniBodyMap', () => {+ it('shows the muscles a routine hits, out of the screen reader\'s way', async () => {+ await render(<MiniBodyMap routines={[{ ex: [{ id: 'bench', sets: 3, muscleWeights: { chest: 1, triceps: 0.4 } }] }]} body="male" />)+ const wrap = host.querySelector('.bm-mini-wrap')+ expect(wrap).not.toBeNull()+ expect(wrap.getAttribute('aria-hidden')).toBe('true')+ expect(host.querySelectorAll('.bm-m.l4').length).toBeGreaterThan(0)+ })+ it('adds up several routines of one day', async () => {+ await render(<MiniBodyMap routines={[{ ex: [{ id: 'bench', sets: 3, muscleWeights: { chest: 1, triceps: 0.4 } }] }, { ex: [{ id: 'squat', sets: 3, muscleWeights: { quadriceps: 1, gluteal: 0.5 } }] }]} body="male" />)+ expect(host.querySelectorAll('.bm-m.l4, .bm-m.l3').length).toBeGreaterThan(1)+ })+ it('renders nothing for a routine without exercises', async () => {+ await render(<MiniBodyMap routines={[{ ex: [] }]} body="male" />)+ expect(host.innerHTML).toBe('')+ })+})diff --git a/frontend/src/index.css b/frontend/src/index.cssindex 21e276db5..c74239cde 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -1682,6 +1682,13 @@ body.no-tabbar #timer.working{box-shadow:inset 0 var(--hair) 0 var(--acc),0 -10p}.bm-v{flex:1;min-width:0;height:auto;max-height:min(46vh,340px)}.bm-ph{height:200px} /* holds the space while the geometry loads */+/* The thumbnail beside a routine's name (components/MiniBodyMap.jsx): front and back, row height. */+.bm-mini-wrap{flex:none;display:flex}+.bodymap.bm-mini{gap:2px;--bm-base:color-mix(in srgb,var(--label) 26%,var(--surface))}+.bodymap.bm-mini .bm-v{flex:none;height:46px;width:auto;max-height:none}+.bodymap.bm-mini .bm-ph{height:46px;width:44px}+.bodymap.bm-mini .bm-sil{fill:color-mix(in srgb,var(--label) 34%,var(--surface))}+.bodymap.bm-mini .bm-v path{stroke-width:3}.bm-sil{fill:color-mix(in srgb,var(--label) 18%,var(--surface))}.bm-m{fill:var(--bm-base);transition:fill var(--med) var(--ease)}.bm-m.l1{fill:color-mix(in srgb,var(--acc) 32%,var(--bm-base))}diff --git a/frontend/src/views/Home.jsx b/frontend/src/views/Home.jsxindex d7713aae2..06ff12c22 100644--- a/frontend/src/views/Home.jsx+++ b/frontend/src/views/Home.jsx@@ -8,6 +8,7 @@ import { bwSheet, goalSheet, dayOverrideSheet, calendarSheet, startFlow, starterimport LineChart from '../components/LineChart.jsx'import Icon from '../components/Icon.jsx'import QueueRow from '../components/QueueRow.jsx'+import MiniBodyMap from '../components/MiniBodyMap.jsx'import { queueOf, queueView, weekTally, pinState } from '../lib/queue.js'import { scheduleModeOf } from '../lib/rotation.js'import { useConnectionTrouble } from '../components/SyncBanner.jsx'@@ -143,7 +144,7 @@ export default function Home() {</div>{S.active ? <span className="tag" style={{ color: 'var(--orange)', background: 'color-mix(in srgb,var(--orange) 16%,transparent)' }}>{editingSaved ? t('Edit') : t('Resume')}</span>: doneToday ? <span className="tag" style={{ color: 'var(--green)', background: 'color-mix(in srgb,var(--green) 16%,transparent)' }}>{t('Done')}</span>- : routine ? <span className="tag acc">{t('Start')}</span>+ : routine ? <span className="row" style={{ gap: 8 }}><MiniBodyMap routines={todayRoutines} body={S.body} /><span className="tag acc">{t('Start')}</span></span>: <Icon name="plus" className="chev" />}</div>{/* The row above starts today's plan in one tap, and so does the Start button in the tabdiff --git a/frontend/src/views/Plan.jsx b/frontend/src/views/Plan.jsxindex 4b7faf7a6..5a2d3a6ae 100644--- a/frontend/src/views/Plan.jsx+++ b/frontend/src/views/Plan.jsx@@ -12,6 +12,7 @@ import Icon from '../components/Icon.jsx'import { Button, Row, Section, Segmented } from '../components/ui.jsx'import SwipeRow from '../components/SwipeRow.jsx'import { copyRoutine, deleteRoutine, restoreRoutine, routineSnapshot } from '../lib/routines.js'+import MiniBodyMap from '../components/MiniBodyMap.jsx'import { workoutControls } from '../lib/workout-controls.js'import { tappable } from '../lib/use-sheet-keyboard.js'import { useListReorder, moved } from '../lib/use-list-reorder.js'@@ -278,6 +279,7 @@ function Schedule({ S, update, nav, mode }) {<div className="tt">{rs.length ? deriveSessionName(rs.map(r => r.name)) : t('Rest day')}</div><div className="ss">{rs.length === 1 ? exCount(rs[0].ex.length) : rs.length ? routineCount(rs.length) : t('Tap to plan something')}</div></div>+ {rs.length > 0 && <MiniBodyMap routines={rs} body={S.body} />}<Icon name="chevronRight" className="chev" /></div>}@@ -353,6 +355,7 @@ function Schedule({ S, update, nav, mode }) {<div className="tt">{name}</div><div className="ss">{item ? stateWord(item) : rest ? t('A day off before the next one') : r ? exCount(r.ex.length) : ''}</div></div>+ {r && !rest && !editing && <MiniBodyMap routines={[r]} body={S.body} />}{editing && seq.length > 1 && <button className="plan-handle" aria-label={t('Move {0}', name)} title={t('Drag to reorder')}{...loopReorder.handle(i)}><Icon name="chevronsUpDown" /></button>}</div>@@ -460,6 +463,7 @@ function Routines({ S, update, nav }) {const row = <div key={r.id} className="item plan-routine" {...tappable(() => nav('/plan/r/' + r.id))}><span className="lrow-i"><Icon name={glyphOf(r.emoji)} /></span><div className="grow"><div className="tt">{r.name}</div><div className="ss">{sub(r)}</div></div>+ <MiniBodyMap routines={[r]} body={S.body} /><Icon name="chevronRight" className="chev" /></div>// Swipe (v1.3.11, Settings → Swipe actions): toward the start deletes with an Undo,// toward the end duplicates. Edit's minus and the routine's own page stay the way in