Skip to content

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.

feat(workout): exercise chips at the top of a running workout (#323)

Duarte Santosfa631bced075
diff --git a/frontend/src/components/WorkoutChips.jsx b/frontend/src/components/WorkoutChips.jsx
new file mode 100644
index 000000000..a24a1de4a
--- /dev/null
+++ b/frontend/src/components/WorkoutChips.jsx
@@ -0,0 +1,46 @@
+import { useEffect, useRef } from 'react'
+import Icon from './Icon.jsx'
+import { exOr } from '../lib/exercises.js'
+import { exerciseNameText } from '../lib/format.js'
+import { exerciseChips } from '../lib/exercise-chips.js'
+import { revealChip } from '../lib/use-sheet-keyboard.js'
+import { t } from '../lib/i18n.js'
+
+// The chip row at the top of a running workout (#323, the "coloured dots" of #163): one numbered
+// chip per exercise, a superset as one chip, filled as far as it is done (empty, half, full), so
+// the state reads without the colour too. The current one wears the accent ring. A tap jumps
+// there; what "there" means is the view's call (onPick), since Cards, List and Focus each go to
+// an exercise differently.
+//
+// The row has one fixed height whatever happens in it, so ticking a set or typing a weight never
+// moves the page under your thumb, and it scrolls sideways on its own (the .chips strip rules in
+// index.css), never the page.
+// Functions, so each word is a literal t() call the string checks can see.
+const STATE_WORD = { done: () => t('Finished'), partial: () => t('Started'), todo: () => t('Not started yet') }
+
+export default function WorkoutChips({ entries, cur, onPick }) {
+ const strip = useRef(null)
+ const chips = exerciseChips(entries, cur)
+ const curKey = chips.find(c => c.current)?.key
+ // Keep the current chip in view along the strip, as the filter strips do (useRevealActiveChip):
+ // after a tap, a swipe to the next card, or the marker moving on. Only the strip scrolls.
+ useEffect(() => {
+ const el = strip.current
+ const chip = el?.querySelector?.('[aria-current]')
+ if (chip) revealChip(el, chip)
+ }, [curKey, chips.length])
+ if (!chips.length) return null
+ return <nav ref={strip} className="chips wchips" aria-label={t('Exercises in this workout')}>
+ {chips.map(c => {
+ const names = c.unit.map(idx => exerciseNameText(exOr(entries[idx].id))).join(' + ')
+ const label = c.unit.length > 1
+ ? t('Superset {0}: {1} ({2})', c.n, names, STATE_WORD[c.state]())
+ : t('Exercise {0}: {1} ({2})', c.n, names, STATE_WORD[c.state]())
+ return <button key={c.key} type="button" className={'wchip ' + c.state + (c.current ? ' cur' : '')}
+ data-unit-key={c.key} aria-current={c.current ? 'step' : undefined} aria-label={label} title={names}
+ onClick={() => onPick(c)}>
+ <span>{c.n}</span>{c.unit.length > 1 && <Icon name="link" />}
+ </button>
+ })}
+ </nav>
+}
diff --git a/frontend/src/index.css b/frontend/src/index.css
index 3b1a7318f..5bd506030 100644
--- a/frontend/src/index.css
+++ b/frontend/src/index.css
@@ -1846,6 +1846,25 @@ body.no-tabbar.resting #toast{bottom:calc(100px + var(--sab))}
.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}
.wl-summary{display:grid;gap:8px;padding-bottom:10px}
+
+/* --- the chip per exercise at the top of a running workout (#323) --- */
+/* One numbered chip per unit, filled as far as it is done: an outline waiting, half full started,
+ full when every work set is ticked, so the state reads without the colour. The current one has
+ the accent ring. Every chip is the same height whatever its state, and the row scrolls sideways
+ (.chips), so nothing here can move the page while you type. 28px chips with the strip's own
+ padding keep the row at about the height of the line it replaces. */
+.chips.wchips{gap:6px;padding:4px 5px 5px;margin-bottom:2px} /* room for the current chip's ring: the strip clips */
+.wchip{
+ flex:none;position:relative;display:inline-flex;align-items:center;justify-content:center;gap:2px;
+ min-width:28px;height:28px;padding:0 8px;border-radius:99px;
+ font-size:13px;font-weight:600;font-variant-numeric:tabular-nums;color:var(--label-2);
+ background:var(--surface);box-shadow:inset 0 0 0 1.5px var(--sep);
+}
+.wchip .icn{width:12px;height:12px}
+.wchip.partial{background:linear-gradient(to top,color-mix(in srgb,var(--orange) 45%,var(--surface)) 50%,var(--surface) 50%);box-shadow:inset 0 0 0 1.5px var(--orange);color:var(--label)}
+.wchip.done{background:color-mix(in srgb,var(--green) 70%,var(--surface));box-shadow:none;color:var(--label)}
+.wchip.cur{box-shadow:0 0 0 2px var(--bg),0 0 0 3.5px var(--acc);color:var(--label)}
+.wchip.partial.cur{box-shadow:inset 0 0 0 1.5px var(--orange),0 0 0 2px var(--bg),0 0 0 3.5px var(--acc)}
/* part of the give-back above — one edge for all three insets of a row in the list view */
@media (max-width:404px){
.wl-unit{padding:10px 8px 2px}
diff --git a/frontend/src/lib/exercise-chips.js b/frontend/src/lib/exercise-chips.js
new file mode 100644
index 000000000..b7599d124
--- /dev/null
+++ b/frontend/src/lib/exercise-chips.js
@@ -0,0 +1,29 @@
+// The chip row at the top of a running workout (#323, the "coloured dots" of #163): one chip per
+// unit (a superset is one chip), saying how far along it is. It needs no new data, only the
+// session's own rows, so it lives here as a plain function the view and the tests share.
+import { supersetUnits } from './history.js'
+import { isWarmupRow, isSideSet } from './workout-model.js'
+
+// Anything ticked counts as a start, one side of a per-side set included.
+const touched = s => !!(s.done || (isSideSet(s) && (s.sides.L?.done || s.sides.R?.done)))
+
+/** How far one exercise is: 'done' once every work set is ticked (a warm-up you skipped does not
+ * hold the chip back), 'partial' once anything is ticked, else 'todo'. An exercise with no rows
+ * yet has nothing done. */
+export function entryProgress(entry) {
+ const sets = entry?.sets || []
+ const work = sets.filter(s => !isWarmupRow(s))
+ if (work.length && work.every(s => s.done)) return 'done'
+ return sets.some(touched) ? 'partial' : 'todo'
+}
+
+/** One chip per unit: { key, unit, n, state, current }. A superset is done when all of its
+ * members are, and started when any of them is. `cur` is the session's marker (s.active.cur). */
+export function exerciseChips(entries, cur) {
+ const list = Array.isArray(entries) ? entries : []
+ return supersetUnits(list).map((unit, k) => {
+ const states = unit.map(idx => entryProgress(list[idx]))
+ const state = states.every(s => s === 'done') ? 'done' : states.some(s => s !== 'todo') ? 'partial' : 'todo'
+ return { key: unit.join('-'), unit, n: k + 1, state, current: unit.includes(cur) }
+ })
+}
diff --git a/frontend/src/lib/exercise-chips.test.js b/frontend/src/lib/exercise-chips.test.js
new file mode 100644
index 000000000..575cfe000
--- /dev/null
+++ b/frontend/src/lib/exercise-chips.test.js
@@ -0,0 +1,38 @@
+import { describe, expect, it } from 'vitest'
+import { entryProgress, exerciseChips } from './exercise-chips.js'
+
+const ex = (sets, extra = {}) => ({ id: 'x', sets: sets.map(done => ({ w: 60, r: 5, done })), ...extra })
+
+describe('exercise chips (#323)', () => {
+ it('reads an exercise as waiting, started or finished', () => {
+ expect(entryProgress(ex([false, false]))).toBe('todo')
+ expect(entryProgress(ex([true, false]))).toBe('partial')
+ expect(entryProgress(ex([true, true]))).toBe('done')
+ expect(entryProgress(ex([]))).toBe('todo')
+ expect(entryProgress(undefined)).toBe('todo')
+ })
+
+ it('calls an exercise finished once its work sets are, whatever a skipped warm-up says', () => {
+ const e = { id: 'x', sets: [{ w: 20, r: 8, phase: 'warmup', done: false }, { w: 60, r: 5, done: true }] }
+ expect(entryProgress(e)).toBe('done')
+ // a ticked warm-up alone is a start
+ expect(entryProgress({ id: 'x', sets: [{ w: 20, r: 8, phase: 'warmup', done: true }, { w: 60, r: 5, done: false }] })).toBe('partial')
+ })
+
+ it('counts one side of a per-side set as a start', () => {
+ const e = { id: 'x', sets: [{ done: false, w: 10, r: 16, sides: { L: { w: 10, r: 8, done: true }, R: { w: 10, r: 8, done: false } } }] }
+ expect(entryProgress(e)).toBe('partial')
+ })
+
+ it('gives a superset one chip, done only when every member is, and marks the current unit', () => {
+ const entries = [ex([true]), ex([true], { sg: 'a' }), ex([false], { sg: 'a' }), ex([false])]
+ const chips = exerciseChips(entries, 2)
+ expect(chips.map(c => [c.key, c.n, c.state, c.current])).toEqual([
+ ['0', 1, 'done', false],
+ ['1-2', 2, 'partial', true],
+ ['3', 3, 'todo', false],
+ ])
+ expect(exerciseChips([ex([true], { sg: 'a' }), ex([true], { sg: 'a' })], 0)[0].state).toBe('done')
+ expect(exerciseChips(null, 0)).toEqual([])
+ })
+})
diff --git a/frontend/src/lib/workout-controls.js b/frontend/src/lib/workout-controls.js
index 6f63dbef8..86f5a3416 100644
--- a/frontend/src/lib/workout-controls.js
+++ b/frontend/src/lib/workout-controls.js
@@ -8,6 +8,8 @@ export const WC_DEFAULT = Object.freeze({
setShortcuts: false, // "+ Drop" / "+ Burst" chips on every set and the warm-up/remove/add row
pairButtons: false, // "Make superset with previous/next" in the exercise header
exerciseButtons: false, // Move up/down, Swap, Remove exercise below the exercise
+ exerciseChips: true, // the numbered chip per exercise at the top of the workout (#323); one row
+ // of fixed height that replaces the "Exercise 2 / 5" line in Cards and Focus
swipeSets: true, // swipe actions: a set row (start deletes with Undo, end copies) and, despite the
// name, Plan's routines, loop and routine exercises too (Settings: "Swipe actions")
})
diff --git a/frontend/src/locales/ar.js b/frontend/src/locales/ar.js
index 7b002676a..e5ab9f003 100644
--- a/frontend/src/locales/ar.js
+++ b/frontend/src/locales/ar.js
@@ -2213,4 +2213,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'تمارين مشابهة',
'No exact match. These come close:': 'لا تطابق تام. هذه قريبة:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'التمارين في هذه الحصة',
+ 'Exercise {0}: {1} ({2})': 'التمرين {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'سوبر سِت {0}: {1} ({2})',
+ 'Finished': 'انتهى',
+ 'Started': 'بدأ',
+ 'Not started yet': 'لم يبدأ بعد',
+ 'Exercise chips at the top': 'شارات التمارين في الأعلى',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'نقطة مرقّمة لكل تمرين تمتلئ كلما تقدّمت. اضغط على واحدة للانتقال إليه.',
}
diff --git a/frontend/src/locales/bn.js b/frontend/src/locales/bn.js
index 39745f383..3f22dfde0 100644
--- a/frontend/src/locales/bn.js
+++ b/frontend/src/locales/bn.js
@@ -2237,4 +2237,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'একই ধরনের ব্যায়াম',
'No exact match. These come close:': 'হুবহু মিল নেই। এগুলো কাছাকাছি:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'এই ওয়ার্কআউটের ব্যায়ামগুলো',
+ 'Exercise {0}: {1} ({2})': 'ব্যায়াম {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'সুপারসেট {0}: {1} ({2})',
+ 'Finished': 'শেষ',
+ 'Started': 'শুরু হয়েছে',
+ 'Not started yet': 'এখনও শুরু হয়নি',
+ 'Exercise chips at the top': 'উপরে ব্যায়ামের চিপ',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'প্রতিটি ব্যায়ামের জন্য একটি নম্বরওয়ালা বিন্দু, এগোতে এগোতে ভরে ওঠে। ট্যাপ করলেই সেখানে চলে যাবেন।',
}
diff --git a/frontend/src/locales/de.js b/frontend/src/locales/de.js
index a54996bf8..ab83e8a62 100644
--- a/frontend/src/locales/de.js
+++ b/frontend/src/locales/de.js
@@ -2178,4 +2178,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Ähnliche Übungen',
'No exact match. These come close:': 'Kein genauer Treffer. Die hier kommen nah ran:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Übungen in diesem Training',
+ 'Exercise {0}: {1} ({2})': 'Übung {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Supersatz {0}: {1} ({2})',
+ 'Finished': 'Fertig',
+ 'Started': 'Angefangen',
+ 'Not started yet': 'Noch nicht angefangen',
+ 'Exercise chips at the top': 'Übungs-Chips oben',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Ein nummerierter Punkt pro Übung, der sich beim Trainieren füllt. Tipp einen an und du bist da.',
}
diff --git a/frontend/src/locales/es.js b/frontend/src/locales/es.js
index fbfa422c9..0aed55fe1 100644
--- a/frontend/src/locales/es.js
+++ b/frontend/src/locales/es.js
@@ -2158,4 +2158,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Ejercicios parecidos',
'No exact match. These come close:': 'Nada exacto. Estos se acercan:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Ejercicios de este entreno',
+ 'Exercise {0}: {1} ({2})': 'Ejercicio {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Superserie {0}: {1} ({2})',
+ 'Finished': 'Terminado',
+ 'Started': 'Empezado',
+ 'Not started yet': 'Sin empezar',
+ 'Exercise chips at the top': 'Chips de ejercicios arriba',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Un punto numerado por ejercicio que se llena sobre la marcha. Toca uno para saltar ahí.',
}
diff --git a/frontend/src/locales/fr.js b/frontend/src/locales/fr.js
index 6dd9b5430..6a732a285 100644
--- a/frontend/src/locales/fr.js
+++ b/frontend/src/locales/fr.js
@@ -2158,4 +2158,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Exercices similaires',
'No exact match. These come close:': 'Rien d’exact. Ceux-ci s’en approchent :',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Exercices de cette séance',
+ 'Exercise {0}: {1} ({2})': 'Exercice {0} : {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Superset {0} : {1} ({2})',
+ 'Finished': 'Terminé',
+ 'Started': 'Commencé',
+ 'Not started yet': 'Pas encore commencé',
+ 'Exercise chips at the top': 'Pastilles d’exercices en haut',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Une pastille numérotée par exercice, qui se remplit au fil de la séance. Touchez-en une pour y aller.',
}
diff --git a/frontend/src/locales/hi.js b/frontend/src/locales/hi.js
index 57b07f370..e025ae804 100644
--- a/frontend/src/locales/hi.js
+++ b/frontend/src/locales/hi.js
@@ -2158,4 +2158,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'मिलते-जुलते व्यायाम',
'No exact match. These come close:': 'सटीक मेल नहीं मिला। ये करीब हैं:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'इस वर्कआउट के व्यायाम',
+ 'Exercise {0}: {1} ({2})': 'व्यायाम {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'सुपरसेट {0}: {1} ({2})',
+ 'Finished': 'पूरा',
+ 'Started': 'शुरू हुआ',
+ 'Not started yet': 'अभी शुरू नहीं हुआ',
+ 'Exercise chips at the top': 'ऊपर व्यायाम चिप्स',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'हर व्यायाम के लिए एक नंबर वाला बिंदु, जो आगे बढ़ते हुए भरता है। किसी पर टैप करें और वहीं पहुँच जाएँ।',
}
diff --git a/frontend/src/locales/hu.js b/frontend/src/locales/hu.js
index a496dfb81..b00595227 100644
--- a/frontend/src/locales/hu.js
+++ b/frontend/src/locales/hu.js
@@ -2161,4 +2161,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Hasonló gyakorlatok',
'No exact match. These come close:': 'Nincs pontos találat. Ezek közel állnak:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Az edzés gyakorlatai',
+ 'Exercise {0}: {1} ({2})': '{0}. gyakorlat: {1} ({2})',
+ 'Superset {0}: {1} ({2})': '{0}. szuperszett: {1} ({2})',
+ 'Finished': 'Kész',
+ 'Started': 'Elkezdve',
+ 'Not started yet': 'Még nincs elkezdve',
+ 'Exercise chips at the top': 'Gyakorlatjelölők felül',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Minden gyakorlatnak egy számozott pötty, ami menet közben telik meg. Koppints rá, és ott vagy.',
}
diff --git a/frontend/src/locales/it.js b/frontend/src/locales/it.js
index 8c3d96f6f..3e41b433d 100644
--- a/frontend/src/locales/it.js
+++ b/frontend/src/locales/it.js
@@ -2158,4 +2158,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Esercizi simili',
'No exact match. These come close:': 'Niente di esatto. Questi ci vanno vicino:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Esercizi di questo allenamento',
+ 'Exercise {0}: {1} ({2})': 'Esercizio {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Superset {0}: {1} ({2})',
+ 'Finished': 'Finito',
+ 'Started': 'Iniziato',
+ 'Not started yet': 'Non ancora iniziato',
+ 'Exercise chips at the top': 'Chip degli esercizi in alto',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Un pallino numerato per esercizio, che si riempie man mano. Toccane uno per andarci.',
}
diff --git a/frontend/src/locales/ko.js b/frontend/src/locales/ko.js
index c906b2b53..2926166d6 100644
--- a/frontend/src/locales/ko.js
+++ b/frontend/src/locales/ko.js
@@ -2158,4 +2158,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': '비슷한 운동',
'No exact match. These come close:': '정확히 일치하는 항목이 없어요. 이건 비슷해요:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': '이 운동의 종목',
+ 'Exercise {0}: {1} ({2})': '운동 {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': '슈퍼세트 {0}: {1} ({2})',
+ 'Finished': '완료',
+ 'Started': '진행 중',
+ 'Not started yet': '아직 시작 안 함',
+ 'Exercise chips at the top': '위쪽 운동 칩',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': '운동마다 번호 점이 하나씩 있고, 진행할수록 채워져요. 누르면 바로 그 운동으로 가요.',
}
diff --git a/frontend/src/locales/pl.js b/frontend/src/locales/pl.js
index 0525f3041..96f229b0a 100644
--- a/frontend/src/locales/pl.js
+++ b/frontend/src/locales/pl.js
@@ -2158,4 +2158,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Podobne ćwiczenia',
'No exact match. These come close:': 'Brak dokładnego dopasowania. Te są blisko:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Ćwiczenia w tym treningu',
+ 'Exercise {0}: {1} ({2})': 'Ćwiczenie {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Superseria {0}: {1} ({2})',
+ 'Finished': 'Ukończone',
+ 'Started': 'Rozpoczęte',
+ 'Not started yet': 'Jeszcze nie rozpoczęte',
+ 'Exercise chips at the top': 'Znaczniki ćwiczeń na górze',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Ponumerowana kropka dla każdego ćwiczenia, wypełnia się w trakcie. Stuknij jedną, aby tam przejść.',
}
diff --git a/frontend/src/locales/pt-BR.js b/frontend/src/locales/pt-BR.js
index 9f283b0d1..c6022f9f0 100644
--- a/frontend/src/locales/pt-BR.js
+++ b/frontend/src/locales/pt-BR.js
@@ -1331,6 +1331,15 @@ export const PT_BR_OVERRIDES = {
'Where an exercise is drawn on both figures. Your workouts stay exactly as they are.': 'Que figura mostra um exercício quando está desenhado nas duas. Seus treinos ficam exatamente como estão.',
'Enter the address of the server this token is for': 'Informe o endereço do servidor a que este token pertence',
'No exact match. These come close:': 'Nada exato. Estes chegam perto:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Exercícios deste treino',
+ 'Exercise {0}: {1} ({2})': 'Exercício {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Superset {0}: {1} ({2})',
+ 'Finished': 'Concluído',
+ 'Started': 'Começado',
+ 'Not started yet': 'Ainda não começou',
+ 'Exercise chips at the top': 'Marcadores de exercícios no topo',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Um ponto numerado por exercício, que vai enchendo conforme você treina. Toque em um para ir até lá.',
}
export default { ...pt, ...PT_BR_OVERRIDES }
diff --git a/frontend/src/locales/pt.js b/frontend/src/locales/pt.js
index 31486ba97..9416d4641 100644
--- a/frontend/src/locales/pt.js
+++ b/frontend/src/locales/pt.js
@@ -2158,4 +2158,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Exercícios semelhantes',
'No exact match. These come close:': 'Nada exato. Estes andam perto:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Exercícios deste treino',
+ 'Exercise {0}: {1} ({2})': 'Exercício {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Supersérie {0}: {1} ({2})',
+ 'Finished': 'Terminado',
+ 'Started': 'Começado',
+ 'Not started yet': 'Ainda não começado',
+ 'Exercise chips at the top': 'Marcadores de exercícios no topo',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Um ponto numerado por exercício, que se vai enchendo. Toque num para saltar para lá.',
}
diff --git a/frontend/src/locales/ru.js b/frontend/src/locales/ru.js
index 9bbf9caa1..a5ea47151 100644
--- a/frontend/src/locales/ru.js
+++ b/frontend/src/locales/ru.js
@@ -2162,4 +2162,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Похожие упражнения',
'No exact match. These come close:': 'Точного совпадения нет. Вот что близко:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Упражнения этой тренировки',
+ 'Exercise {0}: {1} ({2})': 'Упражнение {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Суперсет {0}: {1} ({2})',
+ 'Finished': 'Готово',
+ 'Started': 'Начато',
+ 'Not started yet': 'Ещё не начато',
+ 'Exercise chips at the top': 'Метки упражнений сверху',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'По пронумерованной точке на каждое упражнение, заполняется по ходу. Нажмите на точку, чтобы перейти к упражнению.',
}
diff --git a/frontend/src/locales/th.js b/frontend/src/locales/th.js
index 475397099..831643e56 100644
--- a/frontend/src/locales/th.js
+++ b/frontend/src/locales/th.js
@@ -2169,4 +2169,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'ท่าที่คล้ายกัน',
'No exact match. These come close:': 'ไม่พบที่ตรงทั้งหมด ท่าเหล่านี้ใกล้เคียง:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'ท่าในการฝึกนี้',
+ 'Exercise {0}: {1} ({2})': 'ท่า {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'ซูเปอร์เซ็ต {0}: {1} ({2})',
+ 'Finished': 'เสร็จแล้ว',
+ 'Started': 'เริ่มแล้ว',
+ 'Not started yet': 'ยังไม่เริ่ม',
+ 'Exercise chips at the top': 'ชิปท่าฝึกด้านบน',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'จุดมีหมายเลขหนึ่งจุดต่อท่า เติมเต็มไปเรื่อยๆ ตามที่คุณฝึก แตะเพื่อไปที่ท่านั้นได้เลย',
}
diff --git a/frontend/src/locales/tr.js b/frontend/src/locales/tr.js
index edf569226..58cb14e66 100644
--- a/frontend/src/locales/tr.js
+++ b/frontend/src/locales/tr.js
@@ -2158,4 +2158,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Benzer egzersizler',
'No exact match. These come close:': 'Tam eşleşme yok. Bunlar yakın:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Bu antrenmandaki egzersizler',
+ 'Exercise {0}: {1} ({2})': 'Egzersiz {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Süperset {0}: {1} ({2})',
+ 'Finished': 'Bitti',
+ 'Started': 'Başlandı',
+ 'Not started yet': 'Henüz başlanmadı',
+ 'Exercise chips at the top': 'Üstte egzersiz çipleri',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Her egzersiz için numaralı bir nokta, ilerledikçe dolar. Birine dokun, oraya atla.',
}
diff --git a/frontend/src/locales/uk.js b/frontend/src/locales/uk.js
index fad71d4f9..937c66b61 100644
--- a/frontend/src/locales/uk.js
+++ b/frontend/src/locales/uk.js
@@ -2155,4 +2155,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': 'Схожі вправи',
'No exact match. These come close:': 'Точного збігу немає. Ось що близько:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': 'Вправи цього тренування',
+ 'Exercise {0}: {1} ({2})': 'Вправа {0}: {1} ({2})',
+ 'Superset {0}: {1} ({2})': 'Суперсет {0}: {1} ({2})',
+ 'Finished': 'Готово',
+ 'Started': 'Розпочато',
+ 'Not started yet': 'Ще не розпочато',
+ 'Exercise chips at the top': 'Позначки вправ угорі',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': 'Пронумерована крапка для кожної вправи, заповнюється по ходу. Торкніться її, щоб перейти до вправи.',
}
diff --git a/frontend/src/locales/zh-TW.js b/frontend/src/locales/zh-TW.js
index ad7411e1d..ba0e73d88 100644
--- a/frontend/src/locales/zh-TW.js
+++ b/frontend/src/locales/zh-TW.js
@@ -2151,4 +2151,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': '相似動作',
'No exact match. These come close:': '沒有完全符合,這些比較接近:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': '這次訓練的動作',
+ 'Exercise {0}: {1} ({2})': '動作 {0}:{1}({2})',
+ 'Superset {0}: {1} ({2})': '超級組 {0}:{1}({2})',
+ 'Finished': '已完成',
+ 'Started': '已開始',
+ 'Not started yet': '還沒開始',
+ 'Exercise chips at the top': '頂部動作圓點',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': '每個動作一個帶編號的圓點,練著練著就填滿了。點一下就能跳過去。',
}
diff --git a/frontend/src/locales/zh.js b/frontend/src/locales/zh.js
index c7b7277d9..b47cfd849 100644
--- a/frontend/src/locales/zh.js
+++ b/frontend/src/locales/zh.js
@@ -2158,4 +2158,13 @@ export default {
// --- search: similar exercises ---
'Similar exercises': '相似动作',
'No exact match. These come close:': '没有完全匹配,这些比较接近:',
+ // --- exercise chips (#323) ---
+ 'Exercises in this workout': '本次训练的动作',
+ 'Exercise {0}: {1} ({2})': '动作 {0}:{1}({2})',
+ 'Superset {0}: {1} ({2})': '超级组 {0}:{1}({2})',
+ 'Finished': '已完成',
+ 'Started': '已开始',
+ 'Not started yet': '还没开始',
+ 'Exercise chips at the top': '顶部动作圆点',
+ 'A numbered dot per exercise, filled as you go. Tap one to jump there.': '每个动作一个带编号的圆点,练着练着就填满了。点一下就能跳过去。',
}
diff --git a/frontend/src/views/Settings.jsx b/frontend/src/views/Settings.jsx
index f2eb01a06..c3e41cc10 100644
--- a/frontend/src/views/Settings.jsx
+++ b/frontend/src/views/Settings.jsx
@@ -545,6 +545,11 @@ export default function Settings({ page = null, find = null, via = null }) {
<Row icon="swap" iconTint="var(--indigo)" title={t('Swipe actions')} subtitle={t('Sets, routines and the loop: left removes, right copies')}>
<Switch aria-label={t('Swipe actions')} checked={wc.swipeSets} onChange={v => setWc('swipeSets', v)} />
</Row>
+ {/* The chip row at the top of a workout (#323): not a button row, but the same question of
+ what the workout screen shows. On by default, it is about one line tall. */}
+ <Row icon="more" iconTint="var(--mint)" title={t('Exercise chips at the top')} subtitle={t('A numbered dot per exercise, filled as you go. Tap one to jump there.')}>
+ <Switch aria-label={t('Exercise chips at the top')} checked={wc.exerciseChips} onChange={v => setWc('exerciseChips', v)} />
+ </Row>
<Row icon="link" iconTint="var(--blue)" title={t('Superset buttons in the exercise header')}>
<Switch checked={wc.pairButtons} onChange={v => setWc('pairButtons', v)} />
</Row>
diff --git a/frontend/src/views/Workout.jsx b/frontend/src/views/Workout.jsx
index 2843f697f..5abdcaa32 100644
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@ -19,6 +19,7 @@ import { pyramidRestFor, maxRecordAt, isPyramid, pyramidLabel } from '../lib/pyr
import { insertionIndexAfterCurrentUnit, nextUnfinishedUnit, setProgressHighWater, supersetFlowStep, restAfterSet, restOnRecheck, restSecFor, warmupRestSecFor } from '../lib/supersetFlow.js'
import Media from '../components/Media.jsx'
import WorkoutScrollAnchor from '../components/WorkoutScrollAnchor.jsx'
+import WorkoutChips from '../components/WorkoutChips.jsx'
import { supersetMeta } from '../lib/superset-meta.js'
import WorkoutThumb, { hasWorkoutMedia } from '../components/WorkoutThumb.jsx'
import { workoutSettingsSheet } from '../components/WorkoutSettingsSheet.jsx'
@@ -1070,16 +1071,8 @@ function ActiveWorkout() {
const cancel = frame => window.cancelAnimationFrame
? window.cancelAnimationFrame(frame)
: window.clearTimeout(frame)
- const frame = schedule(() => {
- const list = listRef.current
- const el = list?.querySelector('.wl-unit.cur')
- if (!el || typeof el.scrollIntoView !== 'function') return
- // The sticky header grows when the workout name wraps; the unit's scroll margin (index.css)
- // clears whatever height it has right now, with a one-line height as the fallback.
- const hdrH = hdrRef.current?.offsetHeight
- if (hdrH) list.style.setProperty('--whdr-h', hdrH + 'px')
- el.scrollIntoView({ block: 'start' })
- })
+ // scrollToUnit (below) clears the sticky header at whatever height it has right now.
+ const frame = schedule(() => scrollToUnit(listRef.current?.querySelector('.wl-unit.cur')))
return () => cancel(frame)
}, [workoutView])
@@ -1687,6 +1680,34 @@ function ActiveWorkout() {
}
}
+ // Brings a list unit to the top of the screen, under the pinned header. The header grows when
+ // the name wraps and by the chip row, so the unit's scroll margin (index.css) is fed its height
+ // as it is right now. A jump the eye should follow glides, unless the system asks for less motion.
+ const scrollToUnit = (el, glide) => {
+ if (!el || typeof el.scrollIntoView !== 'function') return
+ const hdrH = hdrRef.current?.offsetHeight
+ if (hdrH) listRef.current?.style.setProperty('--whdr-h', hdrH + 'px')
+ const still = typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches
+ el.scrollIntoView(glide && !still ? { block: 'start', behavior: 'smooth' } : { block: 'start' })
+ }
+ // A tap on a chip at the top (#323). Cards and Focus show one unit, so the chip makes it the one
+ // on screen: the marker moves because you asked it to, never on its own. The list already shows
+ // every unit, so there the chip only scrolls to it and leaves "Current" where it was, the same
+ // as scrolling there by hand; the frame wait is the one opening the list uses (above).
+ const pickChip = chip => {
+ if (listMode) {
+ const go = () => scrollToUnit(listRef.current?.querySelector(`.wl-unit[data-unit-key="${chip.key}"]`), true)
+ if (window.requestAnimationFrame) window.requestAnimationFrame(go)
+ else window.setTimeout(go, 0)
+ return
+ }
+ if (chip.unit.includes(cur)) return
+ update(s => { if (s.active) s.active.cur = chip.unit[0] })
+ }
+ const chipRow = wc.exerciseChips && A.entries.length > 0
+ ? <WorkoutChips entries={A.entries} cur={cur} onPick={pickChip} />
+ : null
+
// Hardware keys (issue #133, lib/workout-keys.js): Space or Enter ticks the next set, ← and →
// switch exercise. The listener is added once and calls the handler of the latest render, so
// toggle() and navigateUnit() always see the session as it is now.
@@ -1696,10 +1717,7 @@ function ActiveWorkout() {
// view the way opening the list does; ticking and tapping never scroll it (see above).
const showCurrent = () => {
if (!listMode) return
- const scroll = () => {
- const el = listRef.current?.querySelector('.wl-unit.cur')
- if (el && typeof el.scrollIntoView === 'function') el.scrollIntoView({ block: 'start' })
- }
+ const scroll = () => scrollToUnit(listRef.current?.querySelector('.wl-unit.cur'))
// After the render that moves the marker, as the effect above waits for its frame.
if (window.requestAnimationFrame) window.requestAnimationFrame(scroll)
else window.setTimeout(scroll, 0)
@@ -1821,6 +1839,9 @@ function ActiveWorkout() {
onClick={() => (editing ? finishWorkout() : finishWorkoutSheet({ onDiscard: discardWorkout }))}>{editing ? t('Save') : t('Finish')}</button>
</div>
<div className="wprog"><i style={{ width: (total ? done / total * 100 : 0) + '%' }} /></div>
+ {/* In the list the chips ride in the pinned header, so any exercise is one tap away from
+ anywhere in a long stack. */}
+ {listMode && chipRow}
</div>
{editing && <p className="muted small">{t('Editing a saved workout. Date and duration stay unchanged.')}</p>}
{A.backfill && <div className="muted small" style={{ marginBottom: 8 }}>{t('Logging a past workout, so no rest timers.')}</div>}
@@ -1871,7 +1892,9 @@ function ActiveWorkout() {
})}
</div>
) : <>
- <div className="muted small" style={{ marginBottom: 6 }}>{isSuperset ? t('Superset {0} / {1}', unitIdx + 1, units.length) : t('Exercise {0} / {1}', unitIdx + 1, units.length)}</div>
+ {/* The chips stand in for "Exercise 2 / 5": the number is on the current chip, and the
+ others say what is done and what is waiting (#323). */}
+ {chipRow || <div className="muted small" style={{ marginBottom: 6 }}>{isSuperset ? t('Superset {0} / {1}', unitIdx + 1, units.length) : t('Exercise {0} / {1}', unitIdx + 1, units.length)}</div>}
<SwipeCards index={unitIdx} count={units.length} revision={A}
timerKey={timer && `${timer.endsAt}:${timer.forIdx ?? ''}`} workKey={work?.endsAt}
onNavigate={navigateUnit} renderPreview={direction => {
diff --git a/frontend/src/views/Workout.test.jsx b/frontend/src/views/Workout.test.jsx
index 936eab51e..ec69a70ad 100644
--- a/frontend/src/views/Workout.test.jsx
+++ b/frontend/src/views/Workout.test.jsx
@@ -2467,6 +2467,100 @@ describe('collapsing completed workout exercises', () => {
})
})
+describe('exercise chips at the top of the workout (#323)', () => {
+ const chips = () => [...container.querySelectorAll('.wchip')]
+ const chip = n => chips()[n - 1]
+ const session = () => [exercise('bench', [true, true]), exercise('fly', [true, false], { sg: 'pair' }), exercise('row', [false], { sg: 'pair' }), exercise('squat', [false])]
+
+ it('shows one chip per unit with its state in Cards, a superset as one, in place of "Exercise N / M"', async () => {
+ await mount(session(), 3)
+ expect(chips().map(c => c.className)).toEqual(['wchip done', 'wchip partial', 'wchip todo cur'])
+ expect(chip(3).getAttribute('aria-current')).toBe('step')
+ expect(chip(1).getAttribute('aria-current')).toBeNull()
+ // test ids are not in the catalogue, so each name reads as the unknown-exercise fallback
+ expect(chip(1).getAttribute('aria-label')).toMatch(/^Exercise 1: .+ \(Finished\)$/)
+ expect(chip(2).getAttribute('aria-label')).toMatch(/^Superset 2: .+ \+ .+ \(Started\)$/)
+ expect(chip(3).getAttribute('aria-label')).toMatch(/^Exercise 3: .+ \(Not started yet\)$/)
+ expect(chip(2).querySelector('[data-icon="link"]')).toBeTruthy()
+ expect(container.querySelector('nav.wchips').getAttribute('aria-label')).toBe('Exercises in this workout')
+ expect(container.textContent).not.toContain('Exercise 3 / 3')
+ })
+
+ it('jumps to the tapped exercise in Cards, and only on a tap', async () => {
+ await mount(session(), 3)
+ await click(chip(2))
+ expect(mocks.S.active.cur).toBe(1)
+ await rerender()
+ expect(chip(2).getAttribute('aria-current')).toBe('step')
+ expect(container.querySelectorAll('.ss-card').length).toBe(1)
+ // the current chip is a no-op, not a write
+ const before = mocks.S
+ await click(chip(2))
+ expect(mocks.S).toBe(before)
+ })
+
+ it('follows the ticks: waiting, then started, then finished', async () => {
+ await mount([exercise('bench', [false, false]), exercise('row', [false])], 0)
+ expect(chip(1).className).toBe('wchip todo cur')
+ await toggleSet(0)
+ await rerender()
+ expect(chip(1).className).toBe('wchip partial cur')
+ await toggleSet(1)
+ await rerender()
+ expect(chip(1).className).toBe('wchip done cur')
+ // ticking never moved the marker, so the chip did not either
+ expect(mocks.S.active.cur).toBe(0)
+ })
+
+ it('switches the exercise in Focus', async () => {
+ await mount(session(), 3, { active: { workoutView: 'focus' } })
+ await click(chip(1))
+ expect(mocks.S.active.cur).toBe(0)
+ await rerender()
+ expect(chip(1).getAttribute('aria-current')).toBe('step')
+ })
+
+ it.each(['list', 'compact'])('rides in the pinned header in %s and scrolls to the unit without moving Current', async workoutView => {
+ await mount(session(), 0, { active: { workoutView } })
+ expect(container.querySelector('.whdr .wchips')).toBeTruthy()
+ await flushFrame() // the list's own open-at-current scroll
+ mocks.scrollCalls.length = 0
+ mocks.headerHeight = 150
+ await click(chip(3))
+ expect(mocks.scrollCalls).toEqual([]) // waits for the frame, like opening the list
+ await flushFrame()
+ expect(mocks.scrollCalls).toHaveLength(1)
+ expect(mocks.scrollCalls[0].node.dataset.unitKey).toBe('3')
+ expect(mocks.scrollCalls[0].options).toEqual({ block: 'start', behavior: 'smooth' })
+ expect(container.querySelector('.workout-list').style.getPropertyValue('--whdr-h')).toBe('150px')
+ expect(mocks.S.active.cur).toBe(0)
+ })
+
+ it('jumps without the glide when the system asks for less motion', async () => {
+ await mount(session(), 0, { active: { workoutView: 'list' } })
+ dom.matchMedia = q => ({ matches: q.includes('reduce') })
+ await flushFrame()
+ mocks.scrollCalls.length = 0
+ await click(chip(2))
+ await flushFrame()
+ expect(mocks.scrollCalls[0].options).toEqual({ block: 'start' })
+ })
+
+ it('goes away with its switch, and the old line comes back', async () => {
+ await mount(session(), 3, { wc: { exerciseChips: false } })
+ expect(container.querySelector('.wchips')).toBeNull()
+ expect(container.textContent).toContain('Exercise 3 / 3')
+ await unmount()
+ await mount(session(), 0, { wc: { exerciseChips: false }, active: { workoutView: 'list' } })
+ expect(container.querySelector('.wchips')).toBeNull()
+ })
+
+ it('has nothing to show in an empty freestyle session', async () => {
+ await mount([], 0)
+ expect(container.querySelector('.wchips')).toBeNull()
+ })
+})
+
describe('workout controls: the more menu and the set menu', () => {
const lastMenu = () => mocks.menuSheet.mock.calls.at(-1)[0]
const item = label => menuItemsOf(lastMenu()).find(it => it.label === label)
diff --git a/frontend/src/views/settings-pages.js b/frontend/src/views/settings-pages.js
index c1cc04c49..accab9372 100644
--- a/frontend/src/views/settings-pages.js
+++ b/frontend/src/views/settings-pages.js
@@ -66,6 +66,7 @@ export const SEARCH = [
{ page: 'advanced', title: 'Weight and reps buttons', icon: 'plusCircle', tint: 'var(--green)', kw: 'steppers plus minus buttons workout controls' },
{ page: 'advanced', title: 'Drop and burst shortcuts on every set', icon: 'bolt', tint: 'var(--orange)', kw: 'drop set burst shortcuts workout controls' },
{ page: 'advanced', title: 'Swipe actions', icon: 'swap', tint: 'var(--indigo)', kw: 'swipe gesture slide delete remove copy duplicate set routine loop plan workout controls', tkw: () => t('swipe gesture') },
+ { page: 'advanced', title: 'Exercise chips at the top', icon: 'more', tint: 'var(--mint)', kw: 'chips dots overview progress jump navigate exercise list workout controls' },
{ page: 'advanced', title: 'Superset buttons in the exercise header', icon: 'link', tint: 'var(--blue)', kw: 'superset pair workout controls' },
{ page: 'advanced', title: 'Move, swap and remove buttons below the exercise', icon: 'swap', tint: 'var(--teal)', kw: 'move swap remove replace workout controls' },
// Timer alerts
diff --git a/frontend/src/views/settings-pages.test.jsx b/frontend/src/views/settings-pages.test.jsx
index 2a3ebf7f8..3a9341943 100644
--- a/frontend/src/views/settings-pages.test.jsx
+++ b/frontend/src/views/settings-pages.test.jsx
@@ -283,13 +283,18 @@ describe('the pages', () => {
expect([...host.querySelectorAll('.sect-f')].some(f => /screen stays on/.test(f.textContent))).toBe(false)
mount('advanced')
expect(titles()).toEqual(['Planned sessions start from', 'Keep timing after target', 'Weight and reps buttons',
- 'Drop and burst shortcuts on every set', 'Swipe actions', 'Superset buttons in the exercise header', 'Move, swap and remove buttons below the exercise'])
+ 'Drop and burst shortcuts on every set', 'Swipe actions', 'Exercise chips at the top', 'Superset buttons in the exercise header', 'Move, swap and remove buttons below the exercise'])
})
it('the Fine-tuning switches write S.wc as the old Workout controls sheet did', () => {
mount('advanced')
act(() => rowTitled('Superset buttons in the exercise header').querySelector('[role="switch"]').click())
expect(mocks.S.wc.pairButtons).toBe(true)
+ // the chip row at the top of a workout (#323) is on by default; its switch turns it off
+ const chips = rowTitled('Exercise chips at the top').querySelector('[role="switch"]')
+ expect(chips.getAttribute('aria-checked')).toBe('true')
+ act(() => chips.click())
+ expect(mocks.S.wc.exerciseChips).toBe(false)
})
it('a sub-page names where back goes; Fine-tuning goes back to Workout', () => {