Custom exercises: create your own with name + body part
Users can add movements missing from the catalogue (issue #11) from the exercise picker or the Exercises tab. Custom exercises live in synced state (S.customEx) and are merged into the exercise index, so routines, supersets, logging, PRs, stats and history all work unchanged. The animation stays blank by design. Editable and deletable from the detail sheet; deleting keeps logged history readable by stamping the name into past entries. Translated into all 12 UI languages. Closes #11
This commit is contained in:
1 parent
93bd4e3850
commit
0cefcb3636
21 files changed
+355
-34
No files matched your search
@@ -1,11 +1,11 @@
|
||||
import { useState } from 'react'
|
||||
import { useStore } from '../store/useStore.js'
|
||||
import { EXDB, BODYPARTS } from '../lib/exercises.js'
|
||||
import { EXDB, BODYPARTS, allExercises } from '../lib/exercises.js'
|
||||
import { bestWeightFor } from '../lib/history.js'
|
||||
import { fmtNum } from '../lib/format.js'
|
||||
import { t } from '../lib/i18n.js'
|
||||
import { Thumb } from '../components/Media.jsx'
|
||||
import { exerciseDetailSheet, addToRoutineSheet } from '../sheets.jsx'
|
||||
import { exerciseDetailSheet, addToRoutineSheet, customExSheet } from '../sheets.jsx'
|
||||
|
||||
export default function Library() {
|
||||
const S = useStore(s => s.S)
|
||||
@@ -13,7 +13,7 @@ export default function Library() {
|
||||
const [bp, setBp] = useState('')
|
||||
const [shown, setShown] = useState(40)
|
||||
const ql = q.toLowerCase().trim()
|
||||
const f = EXDB.filter(e => (!bp || e.bp === bp) && (!ql || e.n.includes(ql) || e.tg.includes(ql) || e.eq.includes(ql)))
|
||||
const f = allExercises(S).filter(e => (!bp || e.bp === bp) && (!ql || e.n.toLowerCase().includes(ql) || e.tg.includes(ql) || e.eq.includes(ql)))
|
||||
|
||||
return <>
|
||||
<div className="hdr"><div><h1>{t('Exercises')}</h1><div className="sub">{t('{0} exercises with animations', EXDB.length)}</div></div></div>
|
||||
@@ -24,6 +24,10 @@ export default function Library() {
|
||||
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => { setBp(b); setShown(40) }}>{t(b)}</button>)}
|
||||
</div>
|
||||
<div className="list">
|
||||
<div className="item" onClick={() => customExSheet(null, ex => exerciseDetailSheet(ex), q.trim())}>
|
||||
<div className="thumb thumb-x">✨</div>
|
||||
<div className="grow"><div className="tt">{t('Create your own exercise')}</div><div className="ss">{t('name + body part, no animation')}</div></div><span className="chev">+</span>
|
||||
</div>
|
||||
{f.slice(0, shown).map(e => {
|
||||
const best = bestWeightFor(S, e.id)
|
||||
return <div key={e.id} className="item" onClick={() => exerciseDetailSheet(e)}>
|
||||
|
||||
@@ -4,17 +4,10 @@ import { useStore } from '../store/useStore.js'
|
||||
import { EXIDX, isCardio } from '../lib/exercises.js'
|
||||
import { fmtNum, uid } from '../lib/format.js'
|
||||
import { t } from '../lib/i18n.js'
|
||||
import { supersetUnits } from '../lib/history.js'
|
||||
import { supersetUnits, cleanupSg } from '../lib/history.js'
|
||||
import { Thumb } from '../components/Media.jsx'
|
||||
import { emojiPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'
|
||||
|
||||
// drop superset ids that no longer have an adjacent partner (after unlink/reorder)
|
||||
function cleanupSg(ex) {
|
||||
ex.forEach((e, i) => {
|
||||
if (e.sg && !(ex[i - 1]?.sg === e.sg || ex[i + 1]?.sg === e.sg)) delete e.sg
|
||||
})
|
||||
}
|
||||
|
||||
export default function RoutineEdit() {
|
||||
const nav = useNavigate()
|
||||
const { id } = useParams()
|
||||
|
||||
Reference in new issue
Block a user