diff --git a/frontend/src/index.css b/frontend/src/index.css index 8ae1926..8e6920b 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -997,6 +997,18 @@ h4.sec{ .ss-ex{position:relative} .ss-amp{text-align:center;font-size:15px;font-weight:600;color:var(--acc);margin:14px 0 8px} +/* --- workout list view: every unit stacked, the current one outlined --- */ +.workout-list{display:grid;gap:14px} +.wl-unit{ + border-radius:var(--r-lg);padding:14px 14px 4px; + background:var(--surface-2); +} +.wl-unit.cur{box-shadow:inset 0 0 0 1.5px var(--acc-line)} +.wl-hd{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px} +@media (max-width:400px){ + .wl-unit{padding:10px 8px 2px} +} + /* --- home: today's session row --- */ .today-row{ display:flex;align-items:center;justify-content:space-between;gap:10px; diff --git a/frontend/src/lib/pt-br-locale.test.js b/frontend/src/lib/pt-br-locale.test.js index 2e75329..ce83fd8 100644 --- a/frontend/src/lib/pt-br-locale.test.js +++ b/frontend/src/lib/pt-br-locale.test.js @@ -28,10 +28,10 @@ describe('Brazilian Portuguese locale', () => { const fingerprint = createHash('sha256').update(JSON.stringify(inherited)).digest('hex') expect(Object.keys(PT_BR_OVERRIDES)).toHaveLength(603) - expect(inherited).toHaveLength(565) + expect(inherited).toHaveLength(571) // If this fails, review the changed keys and wording before accepting a new hash. From // frontend/: node scripts/pt-br-inheritance-fingerprint.mjs --list - expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('e6addc025574b25e392121fe543012a189116d8cb9c91fe5e96caeb3c3e450f2') + expect(fingerprint, 'pt-PT inheritance changed; review the inherited pt-BR wording').toBe('1bc5c2825a8e797b2b8e129d1c06b6baca568e95ea9a1e43ae9dacae4bc98801') }) test('does not leak European Portuguese UI terms', () => { diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js index 4c84a00..a3b18b1 100644 --- a/frontend/src/locales/de.js +++ b/frontend/src/locales/de.js @@ -414,6 +414,12 @@ export default { 'Minimize': 'Verkleinern', 'Expand': 'Vergrössern', 'Exercise animations': 'Übungs-Animationen', + 'Workout view': 'Trainingsansicht', + 'Cards': 'Karten', + 'List': 'Liste', + 'Current': 'Aktuell', + 'Set current': 'Als aktuell markieren', + 'Move, swap and remove below act on the exercise marked {0}.': 'Verschieben, Tauschen und Entfernen unten wirken auf die als {0} markierte Übung.', 'Full': 'Gross', 'Small': 'Klein', 'Hidden': 'Versteckt', diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js index 3f3b361..d70304c 100644 --- a/frontend/src/locales/es.js +++ b/frontend/src/locales/es.js @@ -396,6 +396,12 @@ export default { 'Minimize': 'Minimizar', 'Expand': 'Ampliar', 'Exercise animations': 'Animaciones de los ejercicios', + 'Workout view': 'Vista del entrenamiento', + 'Cards': 'Tarjetas', + 'List': 'Lista', + 'Current': 'Actual', + 'Set current': 'Marcar actual', + 'Move, swap and remove below act on the exercise marked {0}.': 'Mover, cambiar y eliminar actúan sobre el ejercicio marcado como {0}.', 'Full': 'Completa', 'Small': 'Pequeña', 'Hidden': 'Oculta', diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js index 654e131..de83a9f 100644 --- a/frontend/src/locales/fr.js +++ b/frontend/src/locales/fr.js @@ -396,6 +396,12 @@ export default { 'Minimize': 'Réduire', 'Expand': 'Agrandir', 'Exercise animations': 'Animations des exercices', + 'Workout view': 'Vue de l’entraînement', + 'Cards': 'Cartes', + 'List': 'Liste', + 'Current': 'En cours', + 'Set current': 'Marquer comme en cours', + 'Move, swap and remove below act on the exercise marked {0}.': 'Déplacer, échanger et supprimer ci-dessous s’appliquent à l’exercice marqué {0}.', 'Full': 'Grande', 'Small': 'Petite', 'Hidden': 'Masquée', diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js index 66b2794..5266cbe 100644 --- a/frontend/src/locales/hi.js +++ b/frontend/src/locales/hi.js @@ -396,6 +396,12 @@ export default { 'Minimize': 'छोटा करें', 'Expand': 'बड़ा करें', 'Exercise animations': 'व्यायाम एनिमेशन', + 'Workout view': 'वर्कआउट दृश्य', + 'Cards': 'कार्ड', + 'List': 'सूची', + 'Current': 'वर्तमान', + 'Set current': 'वर्तमान के रूप में चिह्नित करें', + 'Move, swap and remove below act on the exercise marked {0}.': 'नीचे दिए गए मूव, स्वैप और रिमूव {0} के रूप में चिह्नित व्यायाम पर लागू होते हैं।', 'Full': 'पूर्ण', 'Small': 'छोटा', 'Hidden': 'छिपा', diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js index b40d7ac..4a9ec57 100644 --- a/frontend/src/locales/hu.js +++ b/frontend/src/locales/hu.js @@ -406,6 +406,12 @@ export default { 'Minimize': 'Kicsinyítés', 'Expand': 'Kibontás', 'Exercise animations': 'Gyakorlat-animációk', + 'Workout view': 'Edzésnézet', + 'Cards': 'Kártyák', + 'List': 'Lista', + 'Current': 'Aktuális', + 'Set current': 'Megjelölés aktuálisként', + 'Move, swap and remove below act on the exercise marked {0}.': 'Az alábbi áthelyezés, csere és törlés a {0} jelölésű gyakorlatra vonatkozik.', 'Full': 'Teljes', 'Small': 'Kicsi', 'Hidden': 'Rejtett', diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js index 5c04c36..e873013 100644 --- a/frontend/src/locales/it.js +++ b/frontend/src/locales/it.js @@ -396,6 +396,12 @@ export default { 'Minimize': 'Riduci', 'Expand': 'Ingrandisci', 'Exercise animations': 'Animazioni degli esercizi', + 'Workout view': 'Vista allenamento', + 'Cards': 'Schede', + 'List': 'Elenco', + 'Current': 'Corrente', + 'Set current': 'Imposta come corrente', + 'Move, swap and remove below act on the exercise marked {0}.': 'Spostamento, scambio e rimozione qui sotto agiscono sull’esercizio contrassegnato come {0}.', 'Full': 'Grande', 'Small': 'Piccola', 'Hidden': 'Nascosta', diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js index 5a29281..49037fe 100644 --- a/frontend/src/locales/ko.js +++ b/frontend/src/locales/ko.js @@ -396,6 +396,12 @@ export default { 'Minimize': '축소', 'Expand': '확대', 'Exercise animations': '운동 애니메이션', + 'Workout view': '운동 보기', + 'Cards': '카드', + 'List': '목록', + 'Current': '현재', + 'Set current': '현재 운동으로 설정', + 'Move, swap and remove below act on the exercise marked {0}.': '아래의 이동, 교체, 삭제는 {0} 표시된 운동에 적용됩니다.', 'Full': '전체', 'Small': '작게', 'Hidden': '숨김', diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js index 40b2359..20e1e7d 100644 --- a/frontend/src/locales/pl.js +++ b/frontend/src/locales/pl.js @@ -396,6 +396,12 @@ export default { 'Minimize': 'Zmniejsz', 'Expand': 'Powiększ', 'Exercise animations': 'Animacje ćwiczeń', + 'Workout view': 'Widok treningu', + 'Cards': 'Karty', + 'List': 'Lista', + 'Current': 'Bieżące', + 'Set current': 'Ustaw jako bieżące', + 'Move, swap and remove below act on the exercise marked {0}.': 'Przenoszenie, zamiana i usuwanie poniżej dotyczą ćwiczenia oznaczonego {0}.', 'Full': 'Pełna', 'Small': 'Mała', 'Hidden': 'Ukryta', diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js index 6ad33e3..6ec95d6 100644 --- a/frontend/src/locales/pt.js +++ b/frontend/src/locales/pt.js @@ -396,6 +396,12 @@ export default { 'Minimize': 'Minimizar', 'Expand': 'Ampliar', 'Exercise animations': 'Animações dos exercícios', + 'Workout view': 'Vista do treino', + 'Cards': 'Cartões', + 'List': 'Lista', + 'Current': 'Atual', + 'Set current': 'Marcar como atual', + 'Move, swap and remove below act on the exercise marked {0}.': 'Mover, trocar e remover abaixo atuam sobre o exercício marcado como {0}.', 'Full': 'Grande', 'Small': 'Pequena', 'Hidden': 'Oculta', diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js index fd8054f..84172b0 100644 --- a/frontend/src/locales/ru.js +++ b/frontend/src/locales/ru.js @@ -396,6 +396,12 @@ export default { 'Minimize': 'Свернуть', 'Expand': 'Развернуть', 'Exercise animations': 'Анимации упражнений', + 'Workout view': 'Вид тренировки', + 'Cards': 'Карточки', + 'List': 'Список', + 'Current': 'Текущее', + 'Set current': 'Сделать текущим', + 'Move, swap and remove below act on the exercise marked {0}.': 'Кнопки перемещения, замены и удаления ниже действуют на упражнение с пометкой {0}.', 'Full': 'Полная', 'Small': 'Малая', 'Hidden': 'Скрыта', diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js index bb94261..fa62459 100644 --- a/frontend/src/locales/th.js +++ b/frontend/src/locales/th.js @@ -406,6 +406,12 @@ export default { 'Minimize': 'ย่อ', 'Expand': 'ขยาย', 'Exercise animations': 'ภาพเคลื่อนไหวท่าออกกำลังกาย', + 'Workout view': 'มุมมองการฝึก', + 'Cards': 'การ์ด', + 'List': 'รายการ', + 'Current': 'ปัจจุบัน', + 'Set current': 'ตั้งเป็นปัจจุบัน', + 'Move, swap and remove below act on the exercise marked {0}.': 'การย้าย สลับ และลบด้านล่างจะมีผลกับท่าที่ทำเครื่องหมาย {0} ไว้', 'Full': 'เต็ม', 'Small': 'เล็ก', 'Hidden': 'ซ่อน', diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js index 610249d..6210857 100644 --- a/frontend/src/locales/tr.js +++ b/frontend/src/locales/tr.js @@ -396,6 +396,12 @@ export default { 'Minimize': 'Küçült', 'Expand': 'Büyüt', 'Exercise animations': 'Egzersiz animasyonları', + 'Workout view': 'Antrenman görünümü', + 'Cards': 'Kartlar', + 'List': 'Liste', + 'Current': 'Aktif', + 'Set current': 'Aktif olarak işaretle', + 'Move, swap and remove below act on the exercise marked {0}.': 'Aşağıdaki taşıma, değiştirme ve kaldırma işlemleri {0} olarak işaretli egzersiz için geçerlidir.', 'Full': 'Tam', 'Small': 'Küçük', 'Hidden': 'Gizli', diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js index a8cd713..59a91e6 100644 --- a/frontend/src/locales/zh.js +++ b/frontend/src/locales/zh.js @@ -396,6 +396,12 @@ export default { 'Minimize': '缩小', 'Expand': '放大', 'Exercise animations': '动作动画', + 'Workout view': '训练视图', + 'Cards': '卡片', + 'List': '列表', + 'Current': '当前', + 'Set current': '设为当前', + 'Move, swap and remove below act on the exercise marked {0}.': '下方的移动、替换和删除将作用于标记为{0}的动作。', 'Full': '完整', 'Small': '小', 'Hidden': '隐藏', diff --git a/frontend/src/store/useStore.js b/frontend/src/store/useStore.js index 7a51aa1..4c5f879 100644 --- a/frontend/src/store/useStore.js +++ b/frontend/src/store/useStore.js @@ -14,6 +14,10 @@ export const DEF = { theme: 'dark', accent: 'lime', body: 'male', targetW: null, bodyweight: [], routines: [], week: {}, dayPlan: {}, exWeights: {}, workouts: [], active: null, customEx: [], gifSize: 'full', + // How the active workout is laid out — 'cards' (one exercise at a time with Prev/Next) + // or 'list' (every exercise stacked and scrollable). Purely presentational: profiles + // written before this setting existed overlay onto DEF and keep the 'cards' behaviour. + workoutView: 'cards', // effort: which per-set effort scale is logged — 'none' | 'rir' | 'rpe'. null, not 'none', so // that a profile which never chose (loaded state is overlaid on DEF, on every path: local, // server pull, backup import) still falls back to the `showRir` boolean this replaced and diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx index f36d16b..b12fca6 100644 --- a/frontend/src/views/Settings.jsx +++ b/frontend/src/views/Settings.jsx @@ -149,6 +149,14 @@ export default function Settings() { {/* ---------- during a workout ---------- */}
+ {/* One exercise at a time (cards with Prev/Next) or the whole session stacked as a + scrollable list. Legacy/unknown values read as cards. */} + + update(s => { s.workoutView = v })} /> + update(s => { s.restSec = v })} options={[{ value: 0, label: t('Off') }, ...[60, 90, 120, 150, 180].map(v => ({ value: v, label: v + 's' }))]} /> diff --git a/frontend/src/views/Settings.workoutview.test.jsx b/frontend/src/views/Settings.workoutview.test.jsx new file mode 100644 index 0000000..1817bd0 --- /dev/null +++ b/frontend/src/views/Settings.workoutview.test.jsx @@ -0,0 +1,89 @@ +// @vitest-environment happy-dom +import React, { act } from 'react' +import { createRoot } from 'react-dom/client' +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' +import Settings from './Settings.jsx' + +globalThis.IS_REACT_ACT_ENVIRONMENT = true + +const mocks = vi.hoisted(() => { + const state = { S: null } + state.snapshot = () => ({ + S: state.S, + user: null, + update: mut => { + const next = structuredClone(state.S) + mut(next) + state.S = next + }, + replaceState: vi.fn(), setUser: vi.fn(), pullState: vi.fn(), pushState: vi.fn(), + signOut: vi.fn(), signOutAll: vi.fn(), resetDemo: vi.fn(), disconnectServer: vi.fn(), + }) + return state +}) +vi.mock('../store/useStore.js', () => { + const useStore = selector => selector ? selector(mocks.snapshot()) : mocks.snapshot() + useStore.getState = mocks.snapshot + return { useStore, DEF: { reminder: { time: '17:30' } }, hasData: () => false } +}) +vi.mock('../store/useUI.js', () => { + const snap = () => ({ toast: vi.fn(), openSheet: vi.fn() }) + const useUI = selector => selector ? selector(snap()) : snap() + useUI.getState = snap + return { useUI } +}) +vi.mock('react-router-dom', () => ({ useNavigate: () => () => {} })) +vi.mock('../lib/api.js', () => ({ + api: vi.fn(), webauthnOK: () => false, passkeyLogin: vi.fn(), passkeyRegister: vi.fn(), IS_ANDROID: false, +})) +vi.mock('../lib/push.js', () => ({ pushSupported: () => false, enablePush: vi.fn(), disablePush: vi.fn(), sendTestPush: vi.fn() })) +vi.mock('../lib/wakelock.js', () => ({ wakeLockSupported: () => false })) +vi.mock('../lib/mobile.js', () => ({ MOBILE: false, shareExport: vi.fn(), syncReminder: vi.fn() })) +vi.mock('./MobileOnboarding.jsx', () => ({ ConnectSheet: () => null })) +vi.mock('../sheets.jsx', () => ({ + loadStarterPlan: vi.fn(), confirmSheet: vi.fn(), importFromApp: vi.fn(), + importFromHevy: vi.fn(), equipmentProfileSheet: vi.fn(), +})) + +// The Settings view reads the build-time version constant at render time. +globalThis.__APP_VERSION__ ??= 'test' + +let host, root +beforeEach(() => { + mocks.S = { + unit: 'kg', restSec: 90, restPauseSec: 15, sound: false, effort: 'none', + gifSize: 'full', workouts: [], routines: [], exWeights: {}, + } + host = document.createElement('div') + document.body.appendChild(host) + root = createRoot(host) +}) +afterEach(() => { + act(() => root.unmount()) + host.remove() +}) + +const mount = () => act(() => root.render()) +const segButton = label => [...host.querySelectorAll('.seg button')].find(b => b.textContent === label) + +describe('Settings — workout view', () => { + it('offers Cards / List and writes workoutView to the store', () => { + mount() + expect(segButton('Cards')).toBeTruthy() + expect(segButton('List')).toBeTruthy() + expect(segButton('Cards').getAttribute('aria-pressed')).toBe('true') + act(() => { segButton('List').click() }) + expect(mocks.S.workoutView).toBe('list') + mount() + expect(segButton('List').getAttribute('aria-pressed')).toBe('true') + act(() => { segButton('Cards').click() }) + expect(mocks.S.workoutView).toBe('cards') + }) + + it('shows a legacy/absent value as Cards', () => { + delete mocks.S.workoutView + mount() + expect(segButton('Cards').getAttribute('aria-pressed')).toBe('true') + expect(segButton('List').getAttribute('aria-pressed')).toBe('false') + }) +}) diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx index 40cd7f3..f8bb8d9 100644 --- a/frontend/src/views/Workout.jsx +++ b/frontend/src/views/Workout.jsx @@ -328,6 +328,12 @@ function ActiveWorkout() { const unit = A.entries.length ? unitOf(units, cur) : [] const unitIdx = units.findIndex(u => u === unit) const isSuperset = unit.length > 1 + // Cards show one unit at a time with Prev/Next + swipe; list stacks every unit so the + // whole session is visible and scrollable (Settings → During a workout → Workout view). + // Every set handler below is already entry-index parameterised, so list mode only changes + // what is rendered — completion, rest, top-weight and auto-advance share one path. + // Unknown/absent values read as cards, keeping every pre-existing profile as it was. + const listMode = S.workoutView === 'list' // Superset flow: center the actionable row when completing a set moves to the partner or // back to the first exercise of the next round. Entry-bound maps keep repeated exercise IDs // distinct, while each rendered set index identifies the existing row within that entry. @@ -368,13 +374,13 @@ function ActiveWorkout() { } }) useEffect(() => { - if (!isSuperset) return + if (!isSuperset || listMode) return const entry = A.entries[cur] const firstIncomplete = entry?.sets.findIndex(s => !s.done) ?? -1 const setIdx = firstIncomplete >= 0 ? firstIncomplete : (entry?.sets.length ?? 0) - 1 const el = (setIdx >= 0 && setRefs.current.get(entry)?.get(setIdx)) || exRefs.current.get(entry) if (el && typeof el.scrollIntoView === 'function') el.scrollIntoView({ behavior: 'smooth', block: 'center' }) - }, [cur, isSuperset, A.entries.length]) + }, [cur, isSuperset, listMode, A.entries.length]) const total = A.entries.reduce((n, e) => n + e.sets.length, 0) const done = setsDoneActive(A) @@ -431,6 +437,17 @@ function ActiveWorkout() { }, true) } + // One prop object per entry so the card and list layouts share the exact same wiring. + const blockProps = idx => ({ + onToggle: i => toggle(idx, i), + onField: (i, f, v) => setField(idx, i, f, v), + onAddSet: () => addSet(idx), + onRemoveSet: () => removeSet(idx), + onAddWarmup: () => addWarmup(idx), + onRemoveSetAt: i => removeSetAt(idx, i), + onStartTimed: i => startTimed(idx, i), + onProgressionSettings: () => openProgressionSettings(idx), + }) const navigateUnit = direction => { const targetFor = active => { if (!active || !Array.isArray(active.entries) || !Number.isInteger(active.cur)) return null @@ -445,6 +462,10 @@ function ActiveWorkout() { if (target != null) s.active.cur = target }) } + // List mode shows every unit at once, so the "current" exercise is chosen by tapping + // "Set current" on its header instead of Prev/Next. The bottom Move/Swap/Remove actions + // keep operating on it, and completing sets still advances it on its own. + const focusUnit = firstIdx => update(s => { if (s.active) s.active.cur = firstIdx }) const onSwipePointerDown = event => { if (swipe.current || (event.pointerType && event.pointerType !== 'touch' && event.pointerType !== 'pen')) return if (event.target.closest?.(SWIPE_IGNORED_TARGETS)) return @@ -653,7 +674,43 @@ function ActiveWorkout() {
{A.backfill &&
{t('Logging a past workout — no rest timers.')}
} - {A.entries.length ? <> + {A.entries.length ? (listMode ? ( +
+ {units.map((u, ui) => { + const multi = u.length > 1 + const isCur = u.includes(cur) + return
+
+ {multi ? t('Superset {0} / {1}', ui + 1, units.length) : t('Exercise {0} / {1}', ui + 1, units.length)} + {isCur + ? {t('Current')} + : } +
+ {multi ? ( +
+
+ {t('Superset · do these back-to-back, rest when done')} + +
+ {u.map((idx, k) => { + const entry = A.entries[idx] + return
bindExRef(entry, el)} className="ss-ex" data-exidx={idx}> + {k > 0 &&
+
} + bindSetRef(entry, setIdx, el)} + {...blockProps(idx)} /> +
+ })} +
+ ) : ( + 0 ? () => pairAt(u[0] - 1, u[0]) : null} + onPairNext={u[0] < A.entries.length - 1 ? () => pairAt(u[0], u[0] + 1) : null} + {...blockProps(u[0])} /> + )} +
+ })} +
+ ) : <>
{isSuperset ? t('Superset {0} / {1}', unitIdx + 1, units.length) : t('Exercise {0} / {1}', unitIdx + 1, units.length)}
bindExRef(entry, el)} className="ss-ex" data-exidx={idx}> {k > 0 &&
+
} bindSetRef(entry, setIdx, el)} - onToggle={i => toggle(idx, i)} onField={(i, f, v) => setField(idx, i, f, v)} onAddSet={() => addSet(idx)} onRemoveSet={() => removeSet(idx)} onAddWarmup={() => addWarmup(idx)} onRemoveSetAt={i => removeSetAt(idx, i)} onStartTimed={i => startTimed(idx, i)} onProgressionSettings={() => openProgressionSettings(idx)} /> + {...blockProps(idx)} />
})} ) : ( - toggle(cur, i)} onField={(i, f, v) => setField(cur, i, f, v)} onAddSet={() => addSet(cur)} onRemoveSet={() => removeSet(cur)} onAddWarmup={() => addWarmup(cur)} onRemoveSetAt={i => removeSetAt(cur, i)} onStartTimed={i => startTimed(cur, i)} onPairPrev={onPairPrev} onPairNext={onPairNext} onProgressionSettings={() => openProgressionSettings(cur)} /> + )} - :
{t('Freestyle workout — add your first exercise.')}
} + ) :
{t('Freestyle workout — add your first exercise.')}
}
-
+ {!listMode &&
-
-
+
} + {!listMode &&
} + {listMode && A.entries.length > 0 &&
{t('Move, swap and remove below act on the exercise marked {0}.', t('Current'))}
}