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.

Merge !72: Exercise picker: the "+" adds now instead of opening the detail sheet

Duarte Santosd8130443a94b
diff --cc frontend/src/sheets.jsx
index 0716f725a,4a328e88e..f327356d8
--- a/frontend/src/sheets.jsx
+++ b/frontend/src/sheets.jsx
@@@ -756,9 -500,16 +756,16 @@@ function ExercisePicker({ onPick, clos
<div className="thumb thumb-x"><Icon name="sparkles" /></div>
<div className="grow"><div className="tt">{t('Create your own exercise')}</div><div className="ss">{t('name + body part, no animation')}</div></div><Icon name="plus" className="chev" />
</div>}
- {f.slice(0, shown).map(e => <div key={e.id} className="item" onClick={() => onPick(e)}>
+ {f.slice(0, shown).map(e => <div key={e.id} className="item" {...tappable(() => onPick(e))}>
<Thumb ex={e} /><div className="grow"><div className="tt capitalize">{exerciseNameFor(e)}</div><div className="ss capitalize">{t(e.tg || e.bp)} · {t(e.eq)}</div></div>
- {usage[e.id] && <span className="tag acc"><Icon name="starFill" /></span>}<Icon name="plus" className="chev" />
+ {usage[e.id] && <span className="tag acc"><Icon name="starFill" /></span>}
+ {/* A "+" glyph reads as "add this now" — it used to just open the same detail sheet as
+ tapping the row, so it added nothing until you'd scrolled past the sets/reps config
+ and found the real button. Now it does what it looks like: adds with the default
+ config right away. Tapping the row itself still opens the detail/config sheet, for
+ when you want to set sets/reps before adding. */}
+ <button className="iconbtn chev" aria-label={t('Add “{0}”', exerciseNameFor(e))} style={{ padding: 8, margin: -8 }}
+ onClick={ev => { ev.stopPropagation(); onPick(e, true) }}><Icon name="plus" /></button>
</div>)}
{f.length === 0 && bp === '★' && <div className="empty">{t('Nothing chosen yet — add exercises and they’ll show up here.')}</div>}
</div>
diff --cc frontend/src/views/RoutineEdit.jsx
index bedef9628,76ab8108e..0cce76979
--- a/frontend/src/views/RoutineEdit.jsx
+++ b/frontend/src/views/RoutineEdit.jsx
@@@ -1,11 -1,12 +1,12 @@@
import { useNavigate, useParams } from 'react-router-dom'
-import { useEffect } from 'react'
+import { useEffect, useRef, useState } from 'react'
import { useStore } from '../store/useStore.js'
+ import { useUI } from '../store/useUI.js'
import { exOr } from '../lib/exercises.js'
import { activeProfile, exAvailable } from '../lib/equipment.js'
import { uid } from '../lib/format.js'
import { t, exerciseNameFor } from '../lib/i18n.js'
- import { supersetUnits, moveSupersetUnit, cleanupSg, exLine } from '../lib/history.js'
-import { supersetUnits, cleanupSg, exLine, defaultConfig } from '../lib/history.js'
++import { supersetUnits, moveSupersetUnit, cleanupSg, exLine, defaultConfig } from '../lib/history.js'
import { Thumb } from '../components/Media.jsx'
import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
@@@ -424,14 -113,15 +426,21 @@@ export default function RoutineEdit()
})()}
<div className="small dim row" style={{ margin: '10px 2px', gap: 5 }}><Icon name="link" style={{ fontSize: 13 }} />{t('Tap the link button on an exercise to superset it with the one above — you’ll do them back-to-back.')}</div>
- <Button variant="primary" onClick={() => exercisePicker(ex => exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) }), null, r))} icon="plus">{t('Add exercise')}</Button>
+ <Button variant="primary" onClick={() => exercisePicker((ex, quick) => {
+ if (quick) {
+ edit(x => x.push({ id: ex.id, ...defaultConfig(ex.id) }))
+ toast(t('“{0}” added to {1}', exerciseNameFor(ex), r.name))
+ } else {
+ exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) }), null, r)
+ }
+ })} icon="plus">{t('Add exercise')}</Button>
<div style={{ height: 10 }} />
+ <Button onClick={() => {
+ const copy = copyRoutine(r, t('Copy'))
+ update(s => { s.routines.push(copy) })
+ nav('/plan/r/' + copy.id)
+ }}>{t('Copy routine')}</Button>
+ <div style={{ height: 10 }} />
<Button variant="danger" onClick={() => confirmSheet({
title: t('Delete routine?'), message: t('“{0}” and its exercises will be removed.', r.name), confirmText: t('Delete'), danger: true,
onConfirm: () => {
diff --cc frontend/src/views/Workout.jsx
index 84532472f,275e503bb..40cd7f39f
--- a/frontend/src/views/Workout.jsx
+++ b/frontend/src/views/Workout.jsx
@@@ -685,45 -515,35 +685,52 @@@ function ActiveWorkout()
<div style={{ height: 12 }} />
<div className="row">
- <Button icon="chevronLeft" disabled={unitIdx <= 0} onClick={() => update(s => { s.active.cur = units[unitIdx - 1][0] })}>{t('Prev')}</Button>
- <Button trailingIcon="chevronRight" disabled={unitIdx < 0 || unitIdx >= units.length - 1} onClick={() => update(s => { s.active.cur = units[unitIdx + 1][0] })}>{t('Next')}</Button>
+ <Button icon="chevronLeft" disabled={unitIdx <= 0} onClick={() => navigateUnit(-1)}>{t('Prev')}</Button>
+ <Button trailingIcon="chevronRight" disabled={unitIdx < 0 || unitIdx >= units.length - 1} onClick={() => navigateUnit(1)}>{t('Next')}</Button>
</div>
<div style={{ height: 10 }} />
- <Button onClick={() => exercisePicker(ex => {
+ <Button onClick={() => exercisePicker((ex, quick) => {
const routine = S.routines.find(r => r.id === A.routineId)
const freestyle = !A.routineId
// Freestyle has no routine prescription to apply: show the last target in the config
- // sheet and carry its completed rows forward. A planned session keeps its existing path.
+ // sheet and carry its completed rows forward. A planned session uses its configured
+ // target when progression is off, while progression-enabled sessions keep their path.
const seed = freestyle ? freestyleConfig(S, { id: ex.id, ...defaultConfig(ex.id) }) : null
- exConfigSheet(ex, null, cfg => update(s => {
+ const commit = cfg => update(s => {
const full = { ...cfg, id: ex.id }
const plan = freestyle ? null : nextPrescription(s, full, s.routines.find(r => r.id === s.active.routineId))
- const sets = buildSets(s, full, { step: defaultIncrement(ex.id, s.unit), ...(freestyle ? { preferLast: true } : {}) })
+ const sets = buildSets(s, full, {
+ step: defaultIncrement(ex.id, s.unit),
+ ...(freestyle ? { preferLast: true } : {}),
+ ...(plan?.kind === 'off' ? { useTarget: true } : {})
+ })
const progressed = freestyle ? sets : applyPrescription(sets, plan, defaultIncrement(ex.id, s.unit))
const insertAt = insertionIndexAfterCurrentUnit(supersetUnits(s.active.entries), s.active.cur, s.active.entries.length)
s.active.entries.splice(insertAt, 0, { id: ex.id, target: { ...cfg }, plan, sets: applyIntensifierPlan(progressed, full) })
s.active.cur = insertAt
useUI.getState().shiftRestOwner(insertAt, 1)
- }), null, routine, seed)
+ })
+ // The "+" on a picker row reads as "add this now" — routed through the same detail
+ // sheet before, so it added nothing until you'd scrolled past it and found the real
+ // button. Quick-add commits with the same default (or, freestyle, last-session) config
+ // the sheet would have opened with; tapping the row still opens that sheet for anyone
+ // who wants to set sets/reps first.
+ if (quick) { commit(seed || defaultConfig(ex.id)); useUI.getState().toast(t('“{0}” added to {1}', exerciseNameFor(ex), routine ? routine.name : t('Freestyle'))) }
+ else exConfigSheet(ex, null, commit, null, routine, seed)
})} icon="plus">{t('Add exercise')}</Button>
{A.entries.length > 0 && <>
+ <div style={{ height: 6 }} />
+ <div className="row">
+ <Button size="sm" icon="chevronUp" aria-label={t('Move up')}
+ disabled={!!work || !canMoveActiveWorkoutUnit(A, cur, -1)} onClick={() => moveCurrentUnit(-1)}>{t('Move up')}</Button>
+ <Button size="sm" trailingIcon="chevronDown" aria-label={t('Move down')}
+ disabled={!!work || !canMoveActiveWorkoutUnit(A, cur, 1)} onClick={() => moveCurrentUnit(1)}>{t('Move down')}</Button>
+ </div>
+ <div style={{ height: 6 }} />
+ <div style={{ display: 'flex', justifyContent: 'center' }}>
+ <Button size="sm" icon="shuffle" aria-label={t('Swap exercise')} disabled={!!work}
+ onClick={() => swapActiveWorkoutExercise(cur)}>{t('Swap exercise')}</Button>
+ </div>
<div style={{ height: 6 }} />
<div style={{ display: 'flex', justifyContent: 'center' }}>
<Button size="sm" icon="minus" style={{ color: 'var(--red)' }} disabled={!!work} onClick={removeExerciseSheet}>{t('Remove exercise')}</Button>