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): show selected muscle fatigue as a zone bar
Сергей Горбатенко562a907bb141
diff --git a/frontend/src/index.css b/frontend/src/index.cssindex c74239cde..36837d8d1 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -1722,6 +1722,17 @@ 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)}+.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%}/* 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 20e252f07..f80534d50 100644--- a/frontend/src/views/Stats.jsx+++ b/frontend/src/views/Stats.jsx@@ -110,6 +110,20 @@ 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. */+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: pct + '%' }} />+ </div>+}+function StrengthLegend() {return <div className="hm-legend hm-strength" aria-label={t('Strength')}><span>1 <span className="dim">{t('full')}</span></span><div className="hm-c l4" /><div className="hm-c l3" /><div className="hm-c l2" />@@ -274,9 +288,8 @@ function MuscleBalance({ S }) {{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>- <span className="v" aria-label={`${t('Fatigue')}: ${Math.round(selFatigue * 100)}% · ${fatigueLabel(selFatigue)}`}>- {t('Fatigue')} {Math.round(selFatigue * 100)}% · {fatigueLabel(selFatigue)}- </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>}{selRecovery.toReadyMs != null && <div className="small dim">{t('Ready {0}', fmtRecoveryIn(selRecovery.toReadyMs))}</div>}diff --git a/frontend/src/views/Stats.recovery.test.jsx b/frontend/src/views/Stats.recovery.test.jsxindex 8bb15f55a..e1670e8cd 100644--- a/frontend/src/views/Stats.recovery.test.jsx+++ b/frontend/src/views/Stats.recovery.test.jsx@@ -279,17 +279,21 @@ describe('Stats muscle recovery view runtime', () => {expect(lastMap().load.chest).toBe(6)})- it('shows the selected muscle fatigue as a percentage with recovery forecast', async () => {+ it('shows the selected muscle fatigue as a zone bar, percent and forecast', async () => {await mountStats()await click(viewButton('Fatigue'))await click(muscleCard().querySelector('[data-muscle="chest"]'))const value = lastMap().load.chestexpect(value).toBeGreaterThan(0.5)- expect(muscleCard().textContent).toContain(`${Math.round(value * 100)}%`)- // The percentage reads as fatigue, not as completion or recovery: the label- // names what is measured and the verdict interprets the band.- expect(muscleCard().textContent).toContain('Fatigue ' + Math.round(value * 100) + '%')- // Fatigued chest drops through both bands, so both forecasts render.+ const pct = Math.round(value * 100)+ const bar = muscleCard().querySelector('.fbar')+ expect(bar).toBeTruthy()+ // The bar carries the band as a marker at the value and reads the same state the map does.+ expect(bar.getAttribute('aria-label')).toBe(`Fatigue: ${pct}% · Fatigued`)+ expect(bar.querySelector('.knob').getAttribute('style')).toContain(`inset-inline-start: ${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')})