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
Library: count your own exercises in the header
Duarte Santose24a91fae5aa
diff --git a/frontend/src/index.css b/frontend/src/index.cssindex 00cc405ca..2e4710506 100644--- a/frontend/src/index.css+++ b/frontend/src/index.css@@ -230,6 +230,12 @@ button.conn:active{filter:brightness(1.12)}.hdr h1{font-size:34px;line-height:1.06;font-weight:700;letter-spacing:-.028em;overflow-wrap:break-word}@media (max-width:420px){.hdr h1{font-size:30px}}.hdr .sub{color:var(--label-2);font-size:15px;letter-spacing:-.006em;margin-top:4px}+/* Library: the count line runs under the title row at full width instead of beside the "By muscle"+ button, which left it ~200px on a phone: the catalogue count plus your own exercises stays one+ line in every language. The ellipsis is only the safety net (the strings are kept short), and+ text-overflow follows the text direction, so Arabic clips on its own end. */+.hdr.lib-hdr{flex-wrap:wrap;align-items:center;row-gap:0}+.hdr.lib-hdr>.sub.lib-count{flex:1 0 100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.iconbtn{width:36px;height:36px;border-radius:50%;flex:none;diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.jsindex aec276244..a99f1e652 100644--- a/frontend/src/locales/ar.js+++ b/frontend/src/locales/ar.js@@ -257,6 +257,8 @@ export default {'“{0}” and its exercises will be removed.': 'سيُحذف «{0}» مع تمارينه.','Delete routine': 'حذف الروتين','{0} exercises with animations': '{0} تمارين مع رسوم متحركة',+ '{1} animated exercises + 1 of your own': '{1} تمرين متحرك + 1 خاص بك',+ '{1} animated exercises + {0} of your own': { zero: '{1} تمرين متحرك + {0} خاص بك', one: '{1} تمرين متحرك + {0} خاص بك', two: '{1} تمرين متحرك + {0} خاصان بك', few: '{1} تمرين متحرك + {0} تمارين خاصة', many: '{1} تمرين متحرك + {0} تمرينًا خاصًا', other: '{1} تمرين متحرك + {0} تمرين خاص' },'Search…': 'بحث…','No workouts yet. Your first one will land here.': 'لا توجد تمارين بعد. أول تمرين لك سيحطّ هنا.','Enter a name': 'أدخل اسماً',diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.jsindex 0b4009d66..70956f0e6 100644--- a/frontend/src/locales/de.js+++ b/frontend/src/locales/de.js@@ -286,6 +286,8 @@ export default {'Copy': 'Kopie',// --- library / history ---'{0} exercises with animations': '{0} Übungen mit Animationen',+ '{1} animated exercises + 1 of your own': '{1} Übungen mit Animation + 1 eigene',+ '{1} animated exercises + {0} of your own': '{1} Übungen mit Animation + {0} eigene','Search…': 'Suchen…','No workouts yet. Your first one will land here.': 'Noch keine Trainings. Dein erstes landet hier.',// --- login / account ---diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.jsindex c7332a9da..346260b71 100644--- a/frontend/src/locales/es.js+++ b/frontend/src/locales/es.js@@ -273,6 +273,8 @@ export default {'Copy routine': 'Copiar rutina','Copy': 'Copia','{0} exercises with animations': '{0} ejercicios con animaciones',+ '{1} animated exercises + 1 of your own': '{1} ejercicios animados + 1 tuyo',+ '{1} animated exercises + {0} of your own': '{1} ejercicios animados + {0} tuyos','Search…': 'Buscar…','No workouts yet. Your first one will land here.': 'Aún no hay entrenamientos. El primero aparecerá aquí.','Enter a name': 'Introduce un nombre',diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.jsindex 76ddd4886..c89976027 100644--- a/frontend/src/locales/fr.js+++ b/frontend/src/locales/fr.js@@ -273,6 +273,8 @@ export default {'Copy routine': 'Copier la routine','Copy': 'Copie','{0} exercises with animations': '{0} exercices avec animations',+ '{1} animated exercises + 1 of your own': '{1} exercices animés + 1 perso',+ '{1} animated exercises + {0} of your own': '{1} exercices animés + {0} perso','Search…': 'Rechercher…','No workouts yet. Your first one will land here.': 'Aucune séance pour l’instant. Ta première atterrira ici.','Enter a name': 'Entre un nom',diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.jsindex 86956b466..b936af0f1 100644--- a/frontend/src/locales/hi.js+++ b/frontend/src/locales/hi.js@@ -273,6 +273,8 @@ export default {'Copy routine': 'रूटीन कॉपी करें','Copy': 'कॉपी','{0} exercises with animations': 'एनिमेशन के साथ {0} व्यायाम',+ '{1} animated exercises + 1 of your own': '{1} एनिमेटेड व्यायाम + 1 आपका अपना',+ '{1} animated exercises + {0} of your own': '{1} एनिमेटेड व्यायाम + {0} आपके अपने','Search…': 'खोजें…','No workouts yet. Your first one will land here.': 'अभी कोई वर्कआउट नहीं। आपका पहला यहीं दिखेगा।','Enter a name': 'नाम दर्ज करें',diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.jsindex 976d1daef..038a4a4eb 100644--- a/frontend/src/locales/hu.js+++ b/frontend/src/locales/hu.js@@ -277,6 +277,8 @@ export default {'Copy': 'Másolat',// --- library / history ---'{0} exercises with animations': '{0} gyakorlat animációval',+ '{1} animated exercises + 1 of your own': '{1} animált gyakorlat + 1 saját',+ '{1} animated exercises + {0} of your own': '{1} animált gyakorlat + {0} saját','Search…': 'Keresés…','No workouts yet. Your first one will land here.': 'Még nincs edzés. Az első ide fog landolni.',// --- login / account ---diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.jsindex 7e928dafe..c70382f11 100644--- a/frontend/src/locales/it.js+++ b/frontend/src/locales/it.js@@ -273,6 +273,8 @@ export default {'Copy routine': 'Copia routine','Copy': 'Copia','{0} exercises with animations': '{0} esercizi con animazioni',+ '{1} animated exercises + 1 of your own': '{1} esercizi animati + 1 tuo',+ '{1} animated exercises + {0} of your own': '{1} esercizi animati + {0} tuoi','Search…': 'Cerca…','No workouts yet. Your first one will land here.': 'Ancora nessun allenamento. Il primo atterrerà qui.','Enter a name': 'Inserisci un nome',diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.jsindex f293a841f..5c8897627 100644--- a/frontend/src/locales/ko.js+++ b/frontend/src/locales/ko.js@@ -273,6 +273,8 @@ export default {'Copy routine': '루틴 복사','Copy': '복사본','{0} exercises with animations': '애니메이션이 있는 운동 {0}개',+ '{1} animated exercises + 1 of your own': '애니메이션 운동 {1}개 + 내 운동 1개',+ '{1} animated exercises + {0} of your own': '애니메이션 운동 {1}개 + 내 운동 {0}개','Search…': '검색…','No workouts yet. Your first one will land here.': '아직 운동 기록이 없어요. 첫 운동이 여기에 쌓일 거예요.','Enter a name': '이름을 입력하세요',diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.jsindex b32e8ef55..d95b55da8 100644--- a/frontend/src/locales/pl.js+++ b/frontend/src/locales/pl.js@@ -273,6 +273,8 @@ export default {'Copy routine': 'Kopiuj plan','Copy': 'Kopia','{0} exercises with animations': '{0} ćwiczeń z animacjami',+ '{1} animated exercises + 1 of your own': '{1} ćwiczeń z animacją + 1 własne',+ '{1} animated exercises + {0} of your own': { one: '{1} ćwiczeń z animacją + {0} własne', few: '{1} ćwiczeń z animacją + {0} własne', many: '{1} ćwiczeń z animacją + {0} własnych', other: '{1} ćwiczeń z animacją + {0} własnego' },'Search…': 'Szukaj…','No workouts yet. Your first one will land here.': 'Brak treningów. Twój pierwszy wyląduje tutaj.','Enter a name': 'Podaj imię',diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.jsindex 5183b749c..5fdc52880 100644--- a/frontend/src/locales/pt-BR.js+++ b/frontend/src/locales/pt-BR.js@@ -1110,6 +1110,8 @@ export const PT_BR_OVERRIDES = {'Test sent! Should pop up any second': 'Teste enviado! Deve aparecer a qualquer momento','That\'s not a QR code. Only QR cards can be shown here': 'Isso não é um código QR. Aqui só dá para mostrar cartões QR','A clean printout, one page per plan. No exercise ever gets split across pages.': 'Uma impressão limpa, uma página por plano. Nenhum exercício fica dividido entre páginas.',+ '{1} animated exercises + 1 of your own': '{1} exercícios animados + 1 seu',+ '{1} animated exercises + {0} of your own': '{1} exercícios animados + {0} seus',}export default { ...pt, ...PT_BR_OVERRIDES }diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.jsindex e8614c927..217e34d2f 100644--- a/frontend/src/locales/pt.js+++ b/frontend/src/locales/pt.js@@ -273,6 +273,8 @@ export default {'Copy routine': 'Copiar rotina','Copy': 'Cópia','{0} exercises with animations': '{0} exercícios com animações',+ '{1} animated exercises + 1 of your own': '{1} exercícios animados + 1 teu',+ '{1} animated exercises + {0} of your own': '{1} exercícios animados + {0} teus','Search…': 'Pesquisar…','No workouts yet. Your first one will land here.': 'Ainda sem treinos. O primeiro vai aparecer aqui.','Enter a name': 'Introduz um nome',diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.jsindex e8bffbed9..87954bf7e 100644--- a/frontend/src/locales/ru.js+++ b/frontend/src/locales/ru.js@@ -265,6 +265,8 @@ export default {'Copy routine': 'Копировать программу','Copy': 'Копия','{0} exercises with animations': '{0} упражнений с анимациями',+ '{1} animated exercises + 1 of your own': '{1} упр. с анимацией + 1 своё',+ '{1} animated exercises + {0} of your own': { one: '{1} упр. с анимацией + {0} своё', few: '{1} упр. с анимацией + {0} своих', many: '{1} упр. с анимацией + {0} своих', other: '{1} упр. с анимацией + {0} своего' },'Search…': 'Поиск…','No workouts yet. Your first one will land here.': 'Тренировок пока нет. Первая появится здесь.','Enter a name': 'Введите имя',diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.jsindex 2b8e933b7..656e0b3c2 100644--- a/frontend/src/locales/th.js+++ b/frontend/src/locales/th.js@@ -277,6 +277,8 @@ export default {'Copy': 'สำเนา',// --- library / history ---'{0} exercises with animations': '{0} ท่าพร้อมภาพเคลื่อนไหว',+ '{1} animated exercises + 1 of your own': '{1} ท่าพร้อมภาพเคลื่อนไหว + ของคุณ 1 ท่า',+ '{1} animated exercises + {0} of your own': '{1} ท่าพร้อมภาพเคลื่อนไหว + ของคุณ {0} ท่า','Search…': 'ค้นหา…','No workouts yet. Your first one will land here.': 'ยังไม่มีการออกกำลังกาย ครั้งแรกของคุณจะมาโผล่ตรงนี้',// --- login / account ---diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.jsindex 361740a95..2e6bb601b 100644--- a/frontend/src/locales/tr.js+++ b/frontend/src/locales/tr.js@@ -273,6 +273,8 @@ export default {'Copy routine': 'Rutini kopyala','Copy': 'Kopya','{0} exercises with animations': 'animasyonlu {0} egzersiz',+ '{1} animated exercises + 1 of your own': '{1} animasyonlu egzersiz + 1 özel',+ '{1} animated exercises + {0} of your own': '{1} animasyonlu egzersiz + {0} özel','Search…': 'Ara…','No workouts yet. Your first one will land here.': 'Henüz antrenman yok. İlkin buraya düşecek.','Enter a name': 'Bir isim gir',diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.jsindex 6f1cdc928..6a648dfc2 100644--- a/frontend/src/locales/uk.js+++ b/frontend/src/locales/uk.js@@ -238,6 +238,8 @@ export default {'“{0}” and its exercises will be removed.': '«{0}» та її вправи буде видалено.','Delete routine': 'Видалити програму','{0} exercises with animations': '{0} вправ з анімаціями',+ '{1} animated exercises + 1 of your own': '{1} вправ з анімаціями + 1 власна',+ '{1} animated exercises + {0} of your own': { one: '{1} вправ з анімаціями + {0} власна', few: '{1} вправ з анімаціями + {0} власні', many: '{1} вправ з анімаціями + {0} власних', other: '{1} вправ з анімаціями + {0} власної' },'Search…': 'Пошук…','No workouts yet. Your first one will land here.': 'Тренувань поки немає. Перше з’явиться саме тут.','{0} loaded': '{0} завантажено',diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.jsindex 17a1e3365..abd32246c 100644--- a/frontend/src/locales/zh-TW.js+++ b/frontend/src/locales/zh-TW.js@@ -269,6 +269,8 @@ export default {'Copy routine': '複製課表','Copy': '副本','{0} exercises with animations': '{0} 個附帶動畫說明的動作',+ '{1} animated exercises + 1 of your own': '{1} 個動畫動作 + 1 個自訂',+ '{1} animated exercises + {0} of your own': '{1} 個動畫動作 + {0} 個自訂','Search…': '搜尋…','No workouts yet. Your first one will land here.': '還沒有訓練紀錄。你的第一次訓練會出現在這裡。','Enter a name': '請輸入名稱',diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.jsindex f5345a91a..6f70ef2c2 100644--- a/frontend/src/locales/zh.js+++ b/frontend/src/locales/zh.js@@ -273,6 +273,8 @@ export default {'Copy routine': '复制训练日','Copy': '副本','{0} exercises with animations': '{0} 个带动画的动作',+ '{1} animated exercises + 1 of your own': '{1} 个动画动作 + 1 个自建',+ '{1} animated exercises + {0} of your own': '{1} 个动画动作 + {0} 个自建','Search…': '搜索…','No workouts yet. Your first one will land here.': '还没有训练。你的第一次训练会出现在这里。','Enter a name': '请输入名字',diff --git a/frontend/src/views/Library.jsx b/frontend/src/views/Library.jsxindex 379768123..3294ff3e4 100644--- a/frontend/src/views/Library.jsx+++ b/frontend/src/views/Library.jsx@@ -6,7 +6,7 @@ import { MUSCLE_NAME } from '../lib/muscles.js'import { activeProfile, exAvailable } from '../lib/equipment.js'import { bestWeightFor } from '../lib/history.js'import { fmtNum, exCount } from '../lib/format.js'-import { t, exerciseNameFor, exerciseNameClass } from '../lib/i18n.js'+import { t, tn, exerciseNameFor, exerciseNameClass } from '../lib/i18n.js'import { Thumb } from '../components/Media.jsx'import { exerciseDetailSheet, addToRoutineSheet, customExSheet } from '../sheets.jsx'import Icon from '../components/Icon.jsx'@@ -24,6 +24,9 @@ export default function Library() {const [shown, setShown] = useState(40)const bpStrip = useRef(null), eqStrip = useRef(null)const profile = activeProfile(S)+ // Your own exercises, counted the way the list below shows them (allExercises puts every+ // custom entry in front of the catalogue; deleting one removes it from customEx outright).+ const ownCount = (S.customEx || []).filter(c => c && c.id).lengthconst base = searchExercises(allExercises(S).filter(e => !bp || e.bp === bp), q)const eqFiltered = (profile && !showAll) ? base.filter(e => exAvailable(S, e)) : baseconst eqOpts = equipmentOf(eqFiltered)@@ -38,8 +41,11 @@ export default function Library() {const narrowed = !!(q.trim() || bp || eqOn)return <>- <div className="hdr"><div><h1>{t('Exercises')}</h1><div className="sub">{t('{0} exercises with animations', EXDB.length)}</div></div>+ <div className="hdr lib-hdr"><div><h1>{t('Exercises')}</h1></div><Button size="sm" variant="tinted" icon="target" onClick={() => nav('/muscles')}>{t('By muscle')}</Button>+ <div className="sub lib-count">{ownCount+ ? tn('{1} animated exercises + 1 of your own', '{1} animated exercises + {0} of your own', ownCount, EXDB.length)+ : t('{0} exercises with animations', EXDB.length)}</div></div><div className={'search' + (narrowed ? ' has-count' : '') + (q ? ' has-clear' : '')} style={{ marginBottom: 10 }}><svg viewBox="0 0 24 24"><circle cx="11" cy="11" r="7" /><path d="m21 21-4.3-4.3" /></svg><input className="input" placeholder={t('Search…')} value={q} onChange={e => { setQ(e.target.value); setShown(40) }} />diff --git a/frontend/src/views/Library.test.jsx b/frontend/src/views/Library.test.jsxindex 35e651ed6..3a9d84519 100644--- a/frontend/src/views/Library.test.jsx+++ b/frontend/src/views/Library.test.jsx@@ -104,3 +104,51 @@ describe('Library exercise-name casing per language', () => {})}})++// The header counts the catalogue, and from the first exercise of your own, those too (owner+// request for v1.3.10): "1324 animated exercises + 5 of your own". It has to stay one line on a+// phone, so it runs under the title row at full width, never wraps, and ellipsizes as a last resort.+describe('Library header count', () => {+ const sub = host => host.querySelector('.hdr .sub').textContent+ const own = n => Array.from({ length: n }, (_, i) => ({ id: 'c' + i, n: 'my move ' + i, bp: 'chest', eq: '', custom: true }))+ afterEach(() => _setLangState('en', {}, null, null))++ it('shows only the catalogue while you have no exercises of your own', () => {+ expect(sub(render())).toBe(`${EXDB.length} exercises with animations`)+ })++ it('adds "+ 1 of your own" for a single custom exercise', () => {+ mocks.S.customEx = own(1)+ expect(sub(render())).toBe(`${EXDB.length} animated exercises + 1 of your own`)+ })++ it('adds the count for several custom exercises', () => {+ mocks.S.customEx = own(5)+ expect(sub(render())).toBe(`${EXDB.length} animated exercises + 5 of your own`)+ })++ it('uses the language\'s own plural forms (Russian: 1 своё, 2 своих, 5 своих)', async () => {+ const { default: ru } = await import('../locales/ru.js')+ _setLangState('ru', ru, null, null)+ const forms = ru['{1} animated exercises + {0} of your own']+ expect(typeof forms).toBe('object')+ mocks.S.customEx = own(1)+ const one = sub(render())+ act(() => { mounted.splice(0).forEach(root => root.unmount()) })+ mocks.S.customEx = own(5)+ const five = sub(render())+ expect(one).toContain(String(EXDB.length))+ expect(five).toBe(forms.many.replace('{0}', '5').replace('{1}', String(EXDB.length)))+ expect(one).not.toBe(five.replace('5', '1'))+ })++ it('keeps the subtitle on one line, clipping with an ellipsis rather than wrapping', () => {+ expect(sub(render())).toBeTruthy()+ const rule = cssSource.match(/^\.hdr\.lib-hdr>\.sub\.lib-count\{([^}]*)\}/m)?.[1] || ''+ expect(rule).toContain('white-space:nowrap')+ expect(rule).toContain('overflow:hidden')+ expect(rule).toContain('text-overflow:ellipsis')+ expect(rule).toContain('flex:1 0 100%')+ expect(cssSource).toMatch(/^\.hdr\.lib-hdr\{[^}]*flex-wrap:wrap/m)+ })+})