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
feat(stats): scale the fatigue bar with zone names and a value marker
Сергей Горбатенкоfa0fdb52d80a
diff --git a/frontend/src/index.css b/frontend/src/index.cssindex 36837d8d1..4cd44fc6c 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -1722,17 +1722,26 @@ body.no-tabbar #timer.working{box-shadow:inset 0 var(--hair) 0 var(--acc),0 -10p/* The Week view's "done/planned · %" (#573): wider than a set count, and as wide on every row, sothe bars line up the way they do in 30d, 90d and All. */.mrow .v.cmp{min-width:92px;font-variant-numeric:tabular-nums;white-space:nowrap}-/* Selected-muscle fatigue: the legend's three bands as one bar, wider than the set- bars around it, with a marker at the value. Ready is the map's unshaded base, so the- left zone stays neutral; the marker is the value, the zones are the thresholds. */-.mrow .fbar{position:relative;display:flex;flex:1;min-width:60px;height:8px;border-radius:4px;overflow:hidden;background:var(--surface-2)}+/* Selected-muscle fatigue detail: the legend's three bands as one bar, the value above+ its marker, the 0–100% endpoints under it and each zone named beneath itself. Ready is+ the map's unshaded base, so the left zone stays neutral; margins leave room for the+ value bubble above the bar. */+.fname{font-size:14px;padding:5px 0 0}+.fbarwrap{position:relative;height:8px;margin-top:20px}+.fbar{position:relative;display:flex;height:8px;border-radius:4px;overflow:hidden;background:var(--surface-2)}.fbar .zone{height:100%}.fbar .zone.ready{width:25%;background:color-mix(in srgb,var(--label) 14%,var(--surface-2))}.fbar .zone.recovering{width:25%;background:var(--yellow)}.fbar .zone.fatigued{width:50%;background:var(--red)}-.fbar .knob{position:absolute;top:-2px;bottom:-2px;width:3px;margin-inline-start:-1.5px;border-radius:2px;background:var(--label);box-shadow:0 0 0 1.5px var(--surface)}-/* The name yields to the bar here: the muscle label is short and the bar is the reading. */-.mrow:has(.fbar) .nm{flex:0 1 auto;max-width:38%}+.fbarwrap .knob{position:absolute;top:-3px;bottom:-3px;width:3px;border-radius:2px;background:var(--label);box-shadow:0 0 0 1.5px var(--surface);pointer-events:none}+.fbarwrap .fval{position:absolute;bottom:100%;margin-bottom:3px;transform:translateX(-50%);font-size:11px;font-weight:600;color:var(--label);white-space:nowrap;pointer-events:none}+[dir="rtl"] .fbarwrap .fval{transform:translateX(50%)}+.fends{display:flex;justify-content:space-between;font-size:10px;color:var(--label-3);margin-top:3px}+.fzones{display:flex;font-size:10px;color:var(--label-3);line-height:1.2}+.fzones .z{text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}+.fzones .z.ready{width:25%}+.fzones .z.recovering{width:25%}+.fzones .z.fatigued{width:50%}/* A headline number inside a card — tile weight without a tile around it, for the pair ofreadings at the top of the effort card. */.stat-v{font-size:26px;font-weight:600;letter-spacing:-.026em;line-height:1.1}diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsxindex 1d1492639..223e48a90 100644--- a/frontend/src/views/Stats.jsx+++ b/frontend/src/views/Stats.jsx@@ -110,18 +110,31 @@ function FatigueLegend() {</div>}-/* The three map bands as one zone bar, with the selected muscle's value marked. The- zones are the legend's own ramp (grey ready, yellow recovering, red fatigued), so the- bar reads without a caption; the percentage sits on the right as its numeric twin.- Boundaries match fatigueStateOf: 25% ready, 25% recovering, 50% fatigued. */+/* The three map bands as one zone bar: a marker at the selected muscle's value with the+ percentage above it, the 0–100% endpoints below, and each band's name under its own+ zone. Zones are the legend's own ramp (grey ready, yellow recovering, red fatigued) and+ their boundaries match fatigueStateOf, so the bar and the map shade never disagree. */function FatigueBar({ value }) {const pct = Math.round(Math.min(1, Math.max(0, value)) * 100)- return <div className="fbar" role="img" aria-label={`${t('Fatigue')}: ${pct}% · ${fatigueLabel(value)}`}>- <span className="zone ready" />- <span className="zone recovering" />- <span className="zone fatigued" />- <span className="knob" style={{ insetInlineStart: `clamp(0px, calc(${pct}% - 1.5px), calc(100% - 3px))` }} />- </div>+ const at = `clamp(0px, calc(${pct}% - 1.5px), calc(100% - 3px))`+ const atValue = `clamp(16px, ${pct}%, calc(100% - 16px))`+ return <>+ <div className="fbarwrap">+ <div className="fbar" role="img" aria-label={`${t('Fatigue')}: ${pct}% · ${fatigueLabel(value)}`}>+ <span className="zone ready" />+ <span className="zone recovering" />+ <span className="zone fatigued" />+ </div>+ <span className="knob" style={{ insetInlineStart: at }} />+ <span className="fval" style={{ insetInlineStart: atValue }}>{pct}%</span>+ </div>+ <div className="fends"><span>0%</span><span>100%</span></div>+ <div className="fzones">+ <span className="z ready">{t('Ready')}</span>+ <span className="z recovering">{t('Recovering')}</span>+ <span className="z fatigued">{t('Fatigued')}</span>+ </div>+ </>}function StrengthLegend() {@@ -285,13 +298,10 @@ function MuscleBalance({ S }) {<BodyMap className="tappable hm-fatigue" load={fatigue} thresholds={FATIGUE_LEVELS} body={S.body} selected={sel} onMuscle={toggleSel} /><FatigueLegend /><div className="muted small" style={{ marginTop: 10 }}>{t('Fatigue shows how recently each muscle was trained. High means rest.')}</div>- {sel && <div style={{ borderTop: 'var(--hair) solid var(--sep)', marginTop: 4, paddingTop: 10 }}>- <div className="mrow">- <span className="nm"><b>{t(MUSCLE_NAME[sel])}</b></span>- <FatigueBar value={selFatigue} />- <span className="v" style={{ minWidth: 44 }}>{Math.round(selFatigue * 100)}%</span>- </div>- {selRecovery.toRecoveringMs != null && <div className="small dim">{t('Recovering {0}', fmtRecoveryIn(selRecovery.toRecoveringMs))}</div>}+ {sel && <div className="fdetail" style={{ borderTop: 'var(--hair) solid var(--sep)', marginTop: 4, paddingTop: 10 }}>+ <div className="fname"><b>{t(MUSCLE_NAME[sel])}</b></div>+ <FatigueBar value={selFatigue} />+ {selRecovery.toRecoveringMs != null && <div className="small dim" style={{ marginTop: 6 }}>{t('Recovering {0}', fmtRecoveryIn(selRecovery.toRecoveringMs))}</div>}{selRecovery.toReadyMs != null && <div className="small dim">{t('Ready {0}', fmtRecoveryIn(selRecovery.toReadyMs))}</div>}</div>}</> : <>diff --git a/frontend/src/views/Stats.recovery.test.jsx b/frontend/src/views/Stats.recovery.test.jsxindex 25651b29d..4d2181c4f 100644--- a/frontend/src/views/Stats.recovery.test.jsx+++ b/frontend/src/views/Stats.recovery.test.jsx@@ -279,23 +279,28 @@ describe('Stats muscle recovery view runtime', () => {expect(lastMap().load.chest).toBe(6)})- it('shows the selected muscle fatigue as a zone bar, percent and forecast', async () => {+ it('shows the selected muscle fatigue as a labelled zone bar with a value marker', async () => {await mountStats()await click(viewButton('Fatigue'))await click(muscleCard().querySelector('[data-muscle="chest"]'))const value = lastMap().load.chestexpect(value).toBeGreaterThan(0.5)const pct = Math.round(value * 100)- const bar = muscleCard().querySelector('.fbar')+ const card = muscleCard()+ const bar = card.querySelector('.fbar')expect(bar).toBeTruthy()- // The bar carries the band as a marker at the value and reads the same state the map does.+ // The bar carries the band, reads the same state the map does, and marks the value.expect(bar.getAttribute('aria-label')).toBe(`Fatigue: ${pct}% · Fatigued`)- expect(bar.querySelector('.knob').getAttribute('style')).toContain(`${pct}%`)expect(bar.querySelector('.zone.fatigued')).toBeTruthy()- // The percentage stands alone on the right, as its numeric twin.- expect(muscleCard().textContent).toContain(`${pct}%`)- expect(muscleCard().textContent).toContain('Recovering in')- expect(muscleCard().textContent).toContain('Ready in')+ expect(card.querySelector('.knob').getAttribute('style')).toContain(`${pct}%`)+ // The value rides above the marker; the scale runs 0–100 with each zone named.+ expect(card.querySelector('.fval').textContent).toBe(`${pct}%`)+ const ends = [...card.querySelectorAll('.fends span')].map(el => el.textContent)+ expect(ends).toEqual(['0%', '100%'])+ const zones = [...card.querySelectorAll('.fzones .z')].map(el => el.textContent)+ expect(zones).toEqual(['Ready', 'Recovering', 'Fatigued'])+ expect(card.textContent).toContain('Recovering in')+ expect(card.textContent).toContain('Ready in')})it('derives a pound-profile bodyweight in kg and passes it into the rendered Fatigue map', async () => {