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
Follow-up to !140: the Stats card and the screen read like the rest of Stats
Duarte Santosdf95d6172847
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 5a161d084..7d0eeda87 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -1321,7 +1321,7 @@ export default {'today {0}': 'heute {0}','reps from your last session': 'Wdh. aus deiner letzten Einheit',// --- structural balance ---- 'Structural Balance': 'Strukturelle Balance',+ 'Structural balance': 'Strukturelle Balance','See which lift is holding back the rest.': 'Sieh, welche Übung den Rest ausbremst.','Compare your lifts against a published ratio table to find the weak link.': 'Vergleiche deine Übungen mit einer veröffentlichten Verhältnistabelle, um das schwache Glied zu finden.','Open': 'Öffnen',diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex d3282c5b9..8490a9eb4 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -1301,7 +1301,7 @@ export default {'today {0}': 'hoy {0}','reps from your last session': 'reps de tu última sesión',// --- structural balance ---- 'Structural Balance': 'Balance estructural',+ 'Structural balance': 'Balance estructural','See which lift is holding back the rest.': 'Descubre qué ejercicio está frenando al resto.','Compare your lifts against a published ratio table to find the weak link.': 'Compara tus levantamientos con una tabla de ratios publicada para encontrar el eslabón débil.','Open': 'Abrir',diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 60b3a2cfb..a8c74b9d8 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -1301,7 +1301,7 @@ export default {'today {0}': 'aujourd’hui {0}','reps from your last session': 'reps de ta dernière séance',// --- structural balance ---- 'Structural Balance': 'Équilibre structurel',+ 'Structural balance': 'Équilibre structurel','See which lift is holding back the rest.': 'Découvrez quel mouvement freine les autres.','Compare your lifts against a published ratio table to find the weak link.': 'Comparez vos mouvements à un tableau de ratios publié pour trouver le maillon faible.','Open': 'Ouvrir',diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex ef9cae5b8..4c0b79429 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -1301,7 +1301,7 @@ export default {'today {0}': 'आज {0}','reps from your last session': 'रेप्स आपके पिछले सेशन से',// --- structural balance ---- 'Structural Balance': 'संरचनात्मक संतुलन',+ 'Structural balance': 'संरचनात्मक संतुलन','See which lift is holding back the rest.': 'देखें कौन-सी लिफ्ट बाकी को पीछे खींच रही है।','Compare your lifts against a published ratio table to find the weak link.': 'प्रकाशित अनुपात तालिका के आधार पर अपनी लिफ्ट्स की तुलना करें और कमज़ोर कड़ी पहचानें।','Open': 'खोलें',diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 13ac40173..a9d5f09f6 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -1304,7 +1304,7 @@ export default {'today {0}': 'ma {0}','reps from your last session': 'ismétlések az utolsó edzésedből',// --- structural balance ---- 'Structural Balance': 'Strukturális egyensúly',+ 'Structural balance': 'Strukturális egyensúly','See which lift is holding back the rest.': 'Nézd meg, melyik gyakorlat fogja vissza a többit.','Compare your lifts against a published ratio table to find the weak link.': 'Hasonlítsd össze gyakorlataidat egy közzétett arány-táblázattal, hogy megtaláld a leggyengébb láncszemet.','Open': 'Megnyitás',diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 09038bf36..28ba1b382 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -1301,7 +1301,7 @@ export default {'today {0}': 'oggi {0}','reps from your last session': 'rip. dalla tua ultima sessione',// --- structural balance ---- 'Structural Balance': 'Equilibrio strutturale',+ 'Structural balance': 'Equilibrio strutturale','See which lift is holding back the rest.': 'Scopri quale esercizio frena gli altri.','Compare your lifts against a published ratio table to find the weak link.': 'Confronta i tuoi sollevamenti con una tabella di rapporti pubblicata per trovare l\'anello debole.','Open': 'Apri',diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex 186cdd83b..2b9b4206e 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -1301,7 +1301,7 @@ export default {'today {0}': '오늘 {0}','reps from your last session': '지난 세션의 횟수',// --- structural balance ---- 'Structural Balance': '구조적 밸런스',+ 'Structural balance': '구조적 밸런스','See which lift is holding back the rest.': '어떤 운동이 나머지를 방해하는지 확인하세요.','Compare your lifts against a published ratio table to find the weak link.': '공개된 비율 표와 운동 기록을 비교해 약점을 찾아보세요.','Open': '열기',diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex a8da8c436..8571d9c84 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -1301,7 +1301,7 @@ export default {'today {0}': 'dziś {0}','reps from your last session': 'powt. z ostatniej sesji',// --- structural balance ---- 'Structural Balance': 'Balans strukturalny',+ 'Structural balance': 'Balans strukturalny','See which lift is holding back the rest.': 'Sprawdź, które ćwiczenie hamuje resztę.','Compare your lifts against a published ratio table to find the weak link.': 'Porównaj swoje wyniki z opublikowaną tabelą proporcji, aby znaleźć najsłabsze ogniwo.','Open': 'Otwórz',diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 3aaa6c64e..839838043 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -710,7 +710,7 @@ export const PT_BR_OVERRIDES = {'No weight logged last time — enter what you lift and progression takes it from there.': 'Nenhum peso registrado na última vez — informe quanto você levanta e a progressão segue a partir daí.','reps from your last session': 'reps da sua última sessão',// --- structural balance ---- 'Structural Balance': 'Balanço estrutural',+ 'Structural balance': 'Balanço estrutural','See which lift is holding back the rest.': 'Veja qual exercício está segurando os outros.','Compare your lifts against a published ratio table to find the weak link.': 'Compare seus levantamentos com uma tabela de proporções publicada para encontrar o elo fraco.','Open': 'Abrir',diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex 2227468cc..75df2efb8 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -1301,7 +1301,7 @@ export default {'today {0}': 'hoje {0}','reps from your last session': 'reps da tua última sessão',// --- structural balance ---- 'Structural Balance': 'Equilíbrio estrutural',+ 'Structural balance': 'Equilíbrio estrutural','See which lift is holding back the rest.': 'Vê qual exercício está a travar os outros.','Compare your lifts against a published ratio table to find the weak link.': 'Compara os teus levantamentos com uma tabela de rácios publicada para encontrar o elo mais fraco.','Open': 'Abrir',diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex 483c12744..5a2af84d2 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -1301,7 +1301,7 @@ export default {'today {0}': 'сегодня {0}','reps from your last session': 'повт. с прошлой тренировки',// --- structural balance ---- 'Structural Balance': 'Структурный баланс',+ 'Structural balance': 'Структурный баланс','See which lift is holding back the rest.': 'Узнайте, какое упражнение сдерживает остальные.','Compare your lifts against a published ratio table to find the weak link.': 'Сравните свои результаты с опубликованной таблицей соотношений, чтобы найти слабое звено.','Open': 'Открыть',diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 7ff5bcda3..6e733cb9c 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -1312,7 +1312,7 @@ export default {'today {0}': 'วันนี้ {0}','reps from your last session': 'จำนวนครั้งจากเซสชันล่าสุด',// --- structural balance ---- 'Structural Balance': 'สมดุลโครงสร้าง',+ 'Structural balance': 'สมดุลโครงสร้าง','See which lift is holding back the rest.': 'ดูว่าท่าไหนที่ฉุดท่าอื่นไว้','Compare your lifts against a published ratio table to find the weak link.': 'เปรียบเทียบท่าฝึกของคุณกับตารางอัตราส่วนที่เผยแพร่ เพื่อหาจุดอ่อน','Open': 'เปิด',diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex a0f33214b..8327924d6 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -1301,7 +1301,7 @@ export default {'today {0}': 'bugün {0}','reps from your last session': 'tekrarlar son seansından',// --- structural balance ---- 'Structural Balance': 'Yapısal denge',+ 'Structural balance': 'Yapısal denge','See which lift is holding back the rest.': 'Hangi hareketin diğerlerini geride bıraktığını gör.','Compare your lifts against a published ratio table to find the weak link.': 'Hareketlerini yayımlanmış bir oran tablosuyla karşılaştırarak zayıf halkayı bul.','Open': 'Aç',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex 7e7d97199..291128c21 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -1301,7 +1301,7 @@ export default {'today {0}': '今天 {0}','reps from your last session': '次数沿用上次训练',// --- structural balance ---- 'Structural Balance': '结构平衡',+ 'Structural balance': '结构平衡','See which lift is holding back the rest.': '看看哪个动作拖了其他动作的后腿。','Compare your lifts against a published ratio table to find the weak link.': '将你的动作成绩与已发布的比例表对比,找出最薄弱的环节。','Open': '打开',diff --git a/frontend/src/views/Stats.jsx b/frontend/src/views/Stats.jsxindex a0afb5a61..b71603680 100644--- a/frontend/src/views/Stats.jsx+++ b/frontend/src/views/Stats.jsx@@ -451,10 +451,10 @@ export default function Stats() {</div>{workouts.length > 0 && <MuscleBalance S={S} />}- {workouts.length > 0 && <div className="card row between" style={{ alignItems: 'center' }}>- <div><h2 style={{ margin: 0 }}>{t('Structural Balance')}</h2>- <div className="sub">{t('See which lift is holding back the rest.')}</div></div>- <Button size="sm" variant="tinted" icon="scale" onClick={() => nav('/structural-balance')}>{t('Open')}</Button>+ {workouts.length > 0 && <div className="card row between" style={{ alignItems: 'center', gap: 12 }}>+ <div style={{ minWidth: 0 }}><h2 style={{ margin: 0 }}>{t('Structural balance')}</h2>+ <div className="muted small" style={{ marginTop: 4 }}>{t('See which lift is holding back the rest.')}</div></div>+ <Button size="sm" variant="tinted" trailingIcon="chevronRight" style={{ flexShrink: 0 }} onClick={() => nav('/structural-balance')}>{t('Open')}</Button></div>}{hasEffort(S) && <EffortCard S={S} />}diff --git a/frontend/src/views/StructuralBalance.jsx b/frontend/src/views/StructuralBalance.jsxindex b47ec34ef..8f4381381 100644--- a/frontend/src/views/StructuralBalance.jsx+++ b/frontend/src/views/StructuralBalance.jsx@@ -1,7 +1,7 @@import { useMemo } from 'react'import { useNavigate } from 'react-router-dom'import { useStore } from '../store/useStore.js'-import { EXIDX } from '../lib/exercises.js'+import { exOr } from '../lib/exercises.js'import { t, exerciseNameFor } from '../lib/i18n.js'import Icon from '../components/Icon.jsx'import { Button, Segmented } from '../components/ui.jsx'@@ -17,7 +17,9 @@ const STATUS_COLOR = {'no-data': 'var(--label-3)',}-const exerciseName = id => (id && EXIDX[id] ? exerciseNameFor(EXIDX[id]) : null)+// A role pointed at a custom exercise since deleted (on this device or another) still names+// something rather than showing a blank line.+const exerciseName = id => (id ? exerciseNameFor(exOr(id)) : null)export default function StructuralBalance() {const nav = useNavigate()@@ -37,7 +39,7 @@ export default function StructuralBalance() {return <><div className="hdr"><button className="iconbtn" onClick={() => nav('/stats')} aria-label={t('Stats')}><Icon name="chevronLeft" /></button>- <div style={{ flex: 1, marginLeft: 12 }}><h1>{t('Structural Balance')}</h1>+ <div style={{ flex: 1, marginLeft: 12 }}><h1>{t('Structural balance')}</h1><div className="sub">{t('Compare your lifts against a published ratio table to find the weak link.')}</div></div></div><Segmented className="seg-range" value={templateId}diff --git a/frontend/src/views/StructuralBalance.test.jsx b/frontend/src/views/StructuralBalance.test.jsxindex 3c781a96b..662cc359a 100644--- a/frontend/src/views/StructuralBalance.test.jsx+++ b/frontend/src/views/StructuralBalance.test.jsx@@ -5,6 +5,9 @@ import { beforeEach, afterEach, describe, expect, it, vi } from 'vitest'import { DEF, useStore } from '../store/useStore.js'import { useUI } from '../store/useUI.js'import StructuralBalance from './StructuralBalance.jsx'+import Stats from './Stats.jsx'+import { buildDemoState } from '../lib/demoSeed.js'+import { TEMPLATE_LIST } from '../lib/structuralBalanceTemplates.js'const navSpy = vi.fn()vi.mock('react-router-dom', () => ({ useNavigate: () => navSpy }))@@ -13,12 +16,12 @@ const clone = value => JSON.parse(JSON.stringify(value))globalThis.IS_REACT_ACT_ENVIRONMENT = trueconst mounted = []-function render() {+function render(View = StructuralBalance) {const host = document.createElement('div')document.body.appendChild(host)const root = createRoot(host)mounted.push(root)- act(() => root.render(<StructuralBalance />))+ act(() => root.render(<View />))return host}@@ -104,3 +107,42 @@ describe('StructuralBalance view', () => {expect([...resetRow.querySelectorAll('button')].some(b => b.textContent.includes('Use default exercise'))).toBe(false)})})++describe('the way in from Stats', () => {+ it('is a card like the others that opens the screen, once there is a workout to read', () => {+ const host = render(Stats)+ const card = [...host.querySelectorAll('.card')].find(c => c.querySelector('h2')?.textContent === 'Structural balance')+ expect(card).toBeTruthy()+ expect(card.textContent).toContain('See which lift is holding back the rest.')+ const open = [...card.querySelectorAll('button')].find(b => b.textContent.includes('Open'))+ act(() => open.click())+ expect(navSpy).toHaveBeenCalledWith('/structural-balance')+ })++ it('is not offered before the first workout', () => {+ useStore.setState({ S: clone(DEF), user: null })+ const host = render(Stats)+ expect(host.textContent).not.toContain('Structural balance')+ })+})++// The demo build (VITE_DEMO=1) boots a guest on the seeded example profile and has no server:+// every template has to render against that profile, and score what it logs.+describe('on the demo profile', () => {+ it('renders every template and scores the lifts the example history has', () => {+ useStore.setState({ S: Object.assign(clone(DEF), buildDemoState()), user: null })+ const host = render()+ const scored = {}+ for (const tpl of TEMPLATE_LIST) {+ const button = [...host.querySelectorAll('.seg button')].find(b => b.textContent === tpl.label)+ act(() => button.click())+ const rows = [...host.querySelectorAll('[data-role-id]')]+ expect(rows.map(r => r.dataset.roleId)).toEqual(tpl.roles.map(r => r.id))+ scored[tpl.id] = rows.filter(r => r.dataset.status !== 'no-data').map(r => r.dataset.roleId)+ }+ expect(scored.thibaudeauPowerlifting).toEqual(expect.arrayContaining(['squat', 'bench']))+ expect(scored.atg).toEqual(expect.arrayContaining(['romanianDeadlift', 'atgDips']))+ expect(host.textContent).not.toContain('NaN')+ expect(host.textContent).not.toContain('undefined')+ })+})