Release v1.2.0: complete visual redesign
Rebuilt design system (one type scale, neutral surface ramp, hairline separators), a 77-icon hand-drawn set replacing every emoji in the UI, grouped routine-icon picker with the old emoji mapped forward, new tab bar with a raised Start/Resume button, and a reorganised Home. Chart fixes that came out of it: axis labels, gridlines and the target line were painted with colour variables the new sheet no longer defines and fell back to black-on-black; the hover readout is now placed from its measured size so it can't be clipped at the edges, and it clears when the pointer leaves the chart.
This commit is contained in:
1 parent
fc36476a5f
commit
b28a58930c
37 files changed
+2168
-1061
No files matched your search
+104
-87
@@ -9,6 +9,9 @@ import { t, instrFor, getLang, INSTR_LANGS } from './lib/i18n.js'
|
||||
import { nav } from './lib/nav.js'
|
||||
import Media, { Thumb } from './components/Media.jsx'
|
||||
import Stepper from './components/Stepper.jsx'
|
||||
import Icon from './components/Icon.jsx'
|
||||
import { Button, Slider } from './components/ui.jsx'
|
||||
import { glyphOf, GLYPH_GROUPS, DEFAULT_GLYPH } from './lib/glyphs.js'
|
||||
|
||||
const S = () => useStore.getState().S
|
||||
const update = (...a) => useStore.getState().update(...a)
|
||||
@@ -23,7 +26,7 @@ function ConfirmDialog({ title, message, confirmText, cancelText, danger, onConf
|
||||
<div className="muted" style={{ marginBottom: 18, lineHeight: 1.5 }}>{message}</div>
|
||||
<button className={'btn ' + (danger ? 'danger' : 'primary')} onClick={() => { close(); onConfirm && onConfirm() }}>{confirmText || t('Confirm')}</button>
|
||||
<div style={{ height: 8 }} />
|
||||
<button className="btn ghost dim" onClick={close}>{cancelText || t('Cancel')}</button>
|
||||
<Button variant="ghost" className="dim" onClick={close}>{cancelText || t('Cancel')}</Button>
|
||||
</div>
|
||||
}
|
||||
// Themed replacement for window.confirm — callback-based (no blocking).
|
||||
@@ -35,9 +38,9 @@ export function confirmSheet(opts) {
|
||||
export function loadStarterPlan() {
|
||||
const mk = (name, emoji, list) => ({ id: uid(), name, emoji, ex: list.map(([id, sets, reps]) => ({ id, sets, reps, weight: 0 })) })
|
||||
update(st => {
|
||||
const push = mk('Push Day', '🫸', [['0025', 4, 8], ['0047', 3, 10], ['0426', 3, 10], ['0334', 3, 12], ['0241', 3, 12], ['0251', 3, 10]])
|
||||
const pull = mk('Pull Day', '🫷', [['2330', 4, 10], ['0027', 4, 8], ['1323', 3, 10], ['0031', 3, 10], ['0313', 3, 12]])
|
||||
const legs = mk('Leg Day', '🦵', [['0043', 4, 8], ['0085', 3, 10], ['0739', 3, 12], ['0585', 3, 12], ['0586', 3, 12], ['0605', 4, 15]])
|
||||
const push = mk('Push Day', 'barbell', [['0025', 4, 8], ['0047', 3, 10], ['0426', 3, 10], ['0334', 3, 12], ['0241', 3, 12], ['0251', 3, 10]])
|
||||
const pull = mk('Pull Day', 'pullup', [['2330', 4, 10], ['0027', 4, 8], ['1323', 3, 10], ['0031', 3, 10], ['0313', 3, 12]])
|
||||
const legs = mk('Leg Day', 'legs', [['0043', 4, 8], ['0085', 3, 10], ['0739', 3, 12], ['0585', 3, 12], ['0586', 3, 12], ['0605', 4, 15]])
|
||||
st.routines.push(push, pull, legs)
|
||||
st.week[1] = push.id; st.week[3] = pull.id; st.week[5] = legs.id
|
||||
})
|
||||
@@ -53,13 +56,12 @@ const W_LO = 1, W_HI = 300
|
||||
function WeightInput({ value, setValue, unit }) {
|
||||
const clamp = x => Math.max(W_LO, Math.min(W_HI, Math.round((x || 0) * 10) / 10))
|
||||
const sv = Math.max(W_LO, Math.min(W_HI, value))
|
||||
const pct = ((sv - W_LO) / (W_HI - W_LO)) * 100
|
||||
const onSlide = v => setValue(clamp(v))
|
||||
return <>
|
||||
<div className="bwstep">
|
||||
<button className="bw-pm" onClick={() => onSlide(value - 0.1)} aria-label="minus 0.1">−</button>
|
||||
<button className="bw-pm" onClick={() => onSlide(value - 0.1)} aria-label="minus 0.1"><Icon name="minus" /></button>
|
||||
<div className="bw-read">{fmtNum(value)}<span className="u"> {unit}</span></div>
|
||||
<button className="bw-pm" onClick={() => onSlide(value + 0.1)} aria-label="plus 0.1">+</button>
|
||||
<button className="bw-pm" onClick={() => onSlide(value + 0.1)} aria-label="plus 0.1"><Icon name="plus" /></button>
|
||||
</div>
|
||||
<div className="chips" style={{ justifyContent: 'center', margin: '8px 0' }}>
|
||||
<button className="chip" onClick={() => onSlide(value - 1)}>−1</button>
|
||||
@@ -67,9 +69,7 @@ function WeightInput({ value, setValue, unit }) {
|
||||
<button className="chip" onClick={() => onSlide(value + 0.5)}>+0.5</button>
|
||||
<button className="chip" onClick={() => onSlide(value + 1)}>+1</button>
|
||||
</div>
|
||||
<input className="bw-slider" type="range" min={W_LO} max={W_HI} step="0.5" value={sv}
|
||||
onChange={e => onSlide(parseFloat(e.target.value))}
|
||||
style={{ '--track': `linear-gradient(90deg, var(--acc) ${pct}%, var(--bg2) ${pct}%)` }} />
|
||||
<Slider value={sv} min={W_LO} max={W_HI} step={0.5} onChange={onSlide} />
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -89,27 +89,27 @@ function BwSheet({ required, onDone, close }) {
|
||||
s.bodyweight.sort((a, b) => (a.d < b.d ? -1 : 1))
|
||||
})
|
||||
close()
|
||||
if (onDone) onDone(n); else toast(t('Weight saved ✓'))
|
||||
if (onDone) onDone(n); else toast(t('Weight saved'))
|
||||
}
|
||||
const recent = [...st.bodyweight].reverse().slice(0, 3)
|
||||
const delEntry = d => update(s => { s.bodyweight = s.bodyweight.filter(b => b.d !== d) })
|
||||
return <>
|
||||
<h3>{required ? t('Quick check-in ⚖️') : t('Log body weight')}</h3>
|
||||
<h3>{required ? t('Quick check-in') : t('Log body weight')}</h3>
|
||||
<div className="muted small">{required ? t('Slide or tap to set your weight — tracked before every workout so your curve stays honest.') : t('Today') + ', ' + fmtDate(todayISO(), true)}</div>
|
||||
<WeightInput value={v} setValue={setV} unit={unit} />
|
||||
<div style={{ height: 14 }} />
|
||||
<button className="btn primary" onClick={save}>{required ? t('Save & start workout') : t('Save')}</button>
|
||||
<Button variant="primary" onClick={save}>{required ? t('Save & start workout') : t('Save')}</Button>
|
||||
{required && <>
|
||||
<div style={{ height: 8 }} /><button className="btn ghost dim" onClick={() => { close(); onDone && onDone(null) }}>{t('Skip today')}</button>
|
||||
<div style={{ height: 2 }} /><button className="btn ghost dim" onClick={() => { close(); nav('/workout') }}>{t('↺ Choose a different workout')}</button>
|
||||
<div style={{ height: 8 }} /><Button variant="ghost" className="dim" onClick={() => { close(); onDone && onDone(null) }}>{t('Skip today')}</Button>
|
||||
<div style={{ height: 2 }} /><Button variant="ghost" className="dim" icon="reset" onClick={() => { close(); nav('/workout') }}>{t('Choose a different workout')}</Button>
|
||||
</>}
|
||||
{!required && recent.length > 0 && <>
|
||||
<h4 className="sec">{t('Recent weigh-ins')}</h4>
|
||||
<div className="list" style={{ gap: 0 }}>
|
||||
{recent.map(b => <div key={b.d} className="row between" style={{ padding: '9px 2px', borderBottom: '1px solid var(--bg2)' }}>
|
||||
{recent.map(b => <div key={b.d} className="row between" style={{ padding: '9px 2px', borderBottom: '1px solid var(--sep)' }}>
|
||||
<span className="small muted">{fmtDate(b.d, true)}</span>
|
||||
<span className="row" style={{ gap: 12 }}><b>{fmtNum(b.w)} {unit}</b>
|
||||
<button className="iconbtn" style={{ width: 34, height: 30, fontSize: '.9rem' }} onClick={() => delEntry(b.d)} aria-label="delete">🗑</button></span>
|
||||
<button className="iconbtn" style={{ width: 32, height: 30, borderRadius: 8, fontSize: 15, color: 'var(--red)' }} onClick={() => delEntry(b.d)} aria-label="delete"><Icon name="trash" /></button></span>
|
||||
</div>)}
|
||||
</div>
|
||||
</>}
|
||||
@@ -122,8 +122,8 @@ export function bwSheet(opts = {}) {
|
||||
|
||||
/* ============================ target weight ============================ */
|
||||
export function bwDeltaColor(delta, currentW) {
|
||||
if (!delta) return 'var(--mut)'
|
||||
if (!S().targetW) return 'var(--txt)'
|
||||
if (!delta) return 'var(--label-2)'
|
||||
if (!S().targetW) return 'var(--label)'
|
||||
const up = S().targetW > currentW
|
||||
return (delta > 0) === up ? 'var(--acc)' : 'var(--red)'
|
||||
}
|
||||
@@ -132,17 +132,17 @@ function GoalSheet({ close }) {
|
||||
const bw = lastBW(st)
|
||||
const [v, setV] = useState(st.targetW || (bw ? bw.w : 70))
|
||||
return <>
|
||||
<h3>{t('Target weight 🎯')}</h3>
|
||||
<h3>{t('Target weight')}</h3>
|
||||
<div className="muted small">{t('Your goal is drawn as a line through the weight charts, and gains/losses are colored by whether they move toward it.')}</div>
|
||||
<WeightInput value={v} setValue={setV} unit={st.unit} />
|
||||
<div style={{ height: 14 }} />
|
||||
<button className="btn primary" onClick={() => {
|
||||
<Button variant="primary" onClick={() => {
|
||||
const n = Math.round((v || 0) * 10) / 10
|
||||
if (!n || n <= 0) { toast(t('Enter a valid weight')); return }
|
||||
update(s => { s.targetW = n }); close()
|
||||
const b = lastBW(S()); toast(t('Goal set: {0}', fmtNum(n) + ' ' + st.unit) + (b ? ' (' + t('{0} to go', fmtNum(Math.abs(n - b.w))) + ')' : ''))
|
||||
}}>{t('Save goal')}</button>
|
||||
{st.targetW && <><div style={{ height: 8 }} /><button className="btn danger" onClick={() => { update(s => { s.targetW = null }); close(); toast(t('Goal removed')) }}>{t('Remove goal')}</button></>}
|
||||
}}>{t('Save goal')}</Button>
|
||||
{st.targetW && <><div style={{ height: 8 }} /><Button variant="danger" onClick={() => { update(s => { s.targetW = null }); close(); toast(t('Goal removed')) }}>{t('Remove goal')}</Button></>}
|
||||
</>
|
||||
}
|
||||
export const goalSheet = () => ui().openSheet(close => <GoalSheet close={close} />)
|
||||
@@ -157,16 +157,16 @@ function ExerciseDetail({ ex, close }) {
|
||||
<Media ex={ex} />
|
||||
<div className="row" style={{ gap: 6, flexWrap: 'wrap', margin: '10px 0' }}>
|
||||
<span className="tag acc">{t(ex.bp)}</span>
|
||||
{ex.tg && <span className="tag">🎯 {t(ex.tg)}</span>}
|
||||
<span className="tag">🛠 {t(ex.eq)}</span>
|
||||
{ex.tg && <span className="tag"><Icon name="target" />{t(ex.tg)}</span>}
|
||||
<span className="tag"><Icon name="dumbbell" />{t(ex.eq)}</span>
|
||||
{(ex.sm || []).slice(0, 3).map((s, i) => <span key={i} className="tag">{t(s)}</span>)}
|
||||
</div>
|
||||
{ex.desc && <div className="exnote">{ex.desc}</div>}
|
||||
{best > 0 && <div className="small" style={{ marginBottom: 6 }}>🏆 {t('Best:')} <b className="accent">{fmtNum(best)} {st.unit}</b>{last ? ` · ${t('last')} ${fmtDate(last.d)}: ${last.sets.map(s => setLabel(ex.id, s)).join(', ')}` : ''}</div>}
|
||||
<button className="btn primary" style={{ margin: '10px 0 4px' }} onClick={() => addToRoutineSheet(ex)}>{t('+ Add to my plan')}</button>
|
||||
{best > 0 && <div className="small row" style={{ marginBottom: 6, gap: 5 }}><Icon name="trophy" style={{ fontSize: 14, color: 'var(--yellow)' }} />{t('Best:')} <b className="accent">{fmtNum(best)} {st.unit}</b>{last ? ` · ${t('last')} ${fmtDate(last.d)}: ${last.sets.map(s => setLabel(ex.id, s)).join(', ')}` : ''}</div>}
|
||||
<Button variant="primary" icon="plus" style={{ margin: '10px 0 4px' }} onClick={() => addToRoutineSheet(ex)}>{t('Add to my plan')}</Button>
|
||||
{ex.custom && <div className="row" style={{ gap: 8, marginTop: 8 }}>
|
||||
<button className="btn" style={{ flex: 1 }} onClick={() => { close(); customExSheet(ex) }}>✏️ {t('Edit')}</button>
|
||||
<button className="btn danger" style={{ flex: 1 }} onClick={() => deleteCustomEx(ex, close)}>🗑 {t('Delete')}</button>
|
||||
<Button icon="pencil" style={{ flex: 1 }} onClick={() => { close(); customExSheet(ex) }}>{t('Edit')}</Button>
|
||||
<Button variant="danger" icon="trash" style={{ flex: 1 }} onClick={() => deleteCustomEx(ex, close)}>{t('Delete')}</Button>
|
||||
</div>}
|
||||
{instrFor(ex).length > 0 && <><h4 className="sec">{t('How to')}{!INSTR_LANGS.includes(getLang()) && <span className="dim" style={{ textTransform: 'none', letterSpacing: 0 }}> · {t('instructions in English')}</span>}</h4><ol className="steps-list">{instrFor(ex).map((s, i) => <li key={i}>{s}</li>)}</ol></>}
|
||||
</>
|
||||
@@ -181,12 +181,12 @@ function AddToRoutine({ ex, close }) {
|
||||
const isNew = rid === '_new'
|
||||
exConfigSheet(ex, null, cfg => {
|
||||
update(s => {
|
||||
let r = isNew ? { id: uid(), name: t('New routine'), emoji: '💪', ex: [] } : s.routines.find(x => x.id === rid)
|
||||
let r = isNew ? { id: uid(), name: t('New routine'), emoji: DEFAULT_GLYPH, ex: [] } : s.routines.find(x => x.id === rid)
|
||||
if (isNew) s.routines.push(r)
|
||||
if (r) r.ex.push({ id: ex.id, ...cfg })
|
||||
})
|
||||
const r = isNew ? S().routines[S().routines.length - 1] : st.routines.find(x => x.id === rid)
|
||||
toast(t('“{0}” added to {1} ✓', ex.n, r ? r.name : t('routine')))
|
||||
toast(t('“{0}” added to {1}', ex.n, r ? r.name : t('routine')))
|
||||
if (isNew && r) nav('/plan/r/' + r.id)
|
||||
})
|
||||
}
|
||||
@@ -195,12 +195,12 @@ function AddToRoutine({ ex, close }) {
|
||||
<div className="muted small" style={{ marginBottom: 12 }}>{t('Pick a routine — sets, reps & weight come next.')}</div>
|
||||
<div className="list">
|
||||
{st.routines.map(r => <div key={r.id} className="item" onClick={() => pick(r.id)}>
|
||||
<div style={{ fontSize: '1.3rem', flex: 'none' }}>{r.emoji || '💪'}</div>
|
||||
<span className="lrow-i"><Icon name={glyphOf(r.emoji)} /></span>
|
||||
<div className="grow"><div className="tt">{r.name}</div><div className="ss">{t('{0} exercises', r.ex.length)}</div></div>
|
||||
{r.ex.some(e => e.id === ex.id) && <span className="tag">{t('already in')}</span>}<span className="chev">+</span>
|
||||
{r.ex.some(e => e.id === ex.id) && <span className="tag">{t('already in')}</span>}<Icon name="plus" className="chev" />
|
||||
</div>)}
|
||||
<div className="item" onClick={() => pick('_new')}><div style={{ fontSize: '1.3rem', flex: 'none' }}>✨</div>
|
||||
<div className="grow"><div className="tt">{t('New routine')}</div><div className="ss">{t('Create one and start with this exercise')}</div></div><span className="chev">+</span></div>
|
||||
<div className="item" onClick={() => pick('_new')}><span className="lrow-i" style={{ background: 'var(--surface-3)' }}><Icon name="sparkles" /></span>
|
||||
<div className="grow"><div className="tt">{t('New routine')}</div><div className="ss">{t('Create one and start with this exercise')}</div></div><Icon name="plus" className="chev" /></div>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
@@ -227,7 +227,7 @@ function CustomExForm({ existing, prefill, onDone, close }) {
|
||||
update(s => { (s.customEx = s.customEx || []).push({ id, n: name, bp, desc: d, tg: '', eq: 'custom', custom: true }) })
|
||||
}
|
||||
close()
|
||||
toast(existing ? t('Saved ✓') : t('“{0}” created ✓', name))
|
||||
toast(existing ? t('Saved') : t('“{0}” created', name))
|
||||
onDone && onDone(EXIDX[id])
|
||||
}
|
||||
return <>
|
||||
@@ -237,12 +237,12 @@ function CustomExForm({ existing, prefill, onDone, close }) {
|
||||
<div className="chips" style={{ margin: '12px 0' }}>
|
||||
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => setBp(b)}>{t(b)}</button>)}
|
||||
</div>
|
||||
{bp === 'cardio' && <div className="small dim" style={{ marginBottom: 10 }}>🏃 {t('Cardio exercises log time + speed instead of weight × reps.')}</div>}
|
||||
{bp === 'cardio' && <div className="small dim row" style={{ marginBottom: 10, gap: 5 }}><Icon name="figureRun" style={{ fontSize: 13 }} />{t('Cardio exercises log time + speed instead of weight × reps.')}</div>}
|
||||
<textarea className="input" rows={4} maxLength={1000} placeholder={t('Description (optional) — setup, cues, anything you want to remember')}
|
||||
value={desc} onChange={e => setDesc(e.target.value)} />
|
||||
<div style={{ height: 14 }} />
|
||||
<button className="btn primary" onClick={save}>{existing ? t('Save') : t('Create exercise')}</button>
|
||||
{existing && <><div style={{ height: 8 }} /><button className="btn danger" onClick={() => { close(); deleteCustomEx(existing) }}>🗑 {t('Delete exercise')}</button></>}
|
||||
<Button variant="primary" onClick={save}>{existing ? t('Save') : t('Create exercise')}</Button>
|
||||
{existing && <><div style={{ height: 8 }} /><Button variant="danger" icon="trash" onClick={() => { close(); deleteCustomEx(existing) }}>{t('Delete exercise')}</Button></>}
|
||||
</>
|
||||
}
|
||||
export const customExSheet = (existing, onDone, prefill) => ui().openSheet(close => <CustomExForm existing={existing} prefill={prefill} onDone={onDone} close={close} />)
|
||||
@@ -298,26 +298,26 @@ function ExercisePicker({ onPick, close }) {
|
||||
<div className="search"><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 {0} exercises…', all.length)} value={q} onChange={e => { setQ(e.target.value); setShown(50) }} /></div>
|
||||
<div className="chips" style={{ margin: eqOpts.length > 1 ? '10px 0 6px' : '10px 0' }}>
|
||||
{chosenCount > 0 && <button className={'chip' + (bp === '★' ? ' on' : '')} onClick={() => { setBp('★'); setEq(''); setShown(50) }}>⭐ {t('Chosen')} ({chosenCount})</button>}
|
||||
<button className={'chip' + (!bp ? ' on' : '')} onClick={() => { setBp(''); setEq(''); setShown(50) }}>{t('All')}</button>
|
||||
{chosenCount > 0 && <button className={'chip' + (bp === '★' ? ' on' : '')} onClick={() => { setBp('★'); setEq(''); setShown(50) }}><Icon name="starFill" style={{ fontSize: 12, display: 'inline-block', marginRight: 4, verticalAlign: '-1px' }} />{t('Chosen')} ({chosenCount})</button>}
|
||||
<button className={'chip nocap' + (!bp ? ' on' : '')} onClick={() => { setBp(''); setEq(''); setShown(50) }}>{t('All')}</button>
|
||||
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => { setBp(b); setEq(''); setShown(50) }}>{t(b)}</button>)}
|
||||
</div>
|
||||
{eqOpts.length > 1 && <div className="chips" style={{ marginBottom: 10 }}>
|
||||
<button className={'chip' + (!eqOn ? ' on' : '')} onClick={() => { setEq(''); setShown(50) }}>{t('Any equipment')}</button>
|
||||
<button className={'chip nocap' + (!eqOn ? ' on' : '')} onClick={() => { setEq(''); setShown(50) }}>{t('Any equipment')}</button>
|
||||
{eqOpts.map(x => <button key={x} className={'chip' + (eqOn === x ? ' on' : '')} onClick={() => { setEq(x); setShown(50) }}>{t(x)}</button>)}
|
||||
</div>}
|
||||
<div className="list">
|
||||
{bp !== '★' && <div className="item" onClick={() => customExSheet(null, ex => onPick(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 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)}>
|
||||
<Thumb ex={e} /><div className="grow"><div className="tt">{e.n}</div><div className="ss">{t(e.tg || e.bp)} · {t(e.eq)}</div></div>
|
||||
{usage[e.id] && <span className="tag acc">⭐</span>}<span className="chev">+</span>
|
||||
<Thumb ex={e} /><div className="grow"><div className="tt capitalize">{e.n}</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" />
|
||||
</div>)}
|
||||
{f.length === 0 && bp === '★' && <div className="empty">{t('Nothing chosen yet — add exercises and they’ll show up here.')}</div>}
|
||||
</div>
|
||||
{f.length > shown && <><div style={{ height: 8 }} /><button className="btn" onClick={() => setShown(s => s + 50)}>{t('Show more')}</button></>}
|
||||
{f.length > shown && <><div style={{ height: 8 }} /><Button onClick={() => setShown(s => s + 50)}>{t('Show more')}</Button></>}
|
||||
</>
|
||||
}
|
||||
export const exercisePicker = onPick => ui().openSheet(close => <ExercisePicker onPick={onPick} close={close} />)
|
||||
@@ -336,7 +336,7 @@ function ExConfig({ ex, existing, onSave, onDelete, close }) {
|
||||
<h3 className="capitalize">{ex.n}</h3>
|
||||
<Media ex={ex} />
|
||||
<div className="row" style={{ gap: 6, flexWrap: 'wrap', margin: '10px 0 14px' }}>
|
||||
{cardio && <span className="tag acc">🏃 {t('Cardio')}</span>}
|
||||
{cardio && <span className="tag acc"><Icon name="figureRun" />{t('Cardio')}</span>}
|
||||
<span className="tag">{t(ex.tg || ex.bp)}</span><span className="tag">{t(ex.eq)}</span>
|
||||
</div>
|
||||
{ex.desc && <div className="exnote">{ex.desc}</div>}
|
||||
@@ -351,19 +351,36 @@ function ExConfig({ ex, existing, onSave, onDelete, close }) {
|
||||
<Stepper label={t('Weight ({0})', st.unit)} value={c.weight} step={2.5} onChange={v => setC(x => ({ ...x, weight: v }))} />
|
||||
</>}
|
||||
</div>
|
||||
<button className="btn primary" onClick={save}>{existing ? t('Save') : t('Add to routine')}</button>
|
||||
{ex.custom && <><div style={{ height: 8 }} /><button className="btn" onClick={() => { close(); customExSheet(ex) }}>✏️ {t('Edit or delete this exercise')}</button></>}
|
||||
{onDelete && <><div style={{ height: 8 }} /><button className="btn danger" onClick={() => { close(); onDelete() }}>{t('Remove from routine')}</button></>}
|
||||
<Button variant="primary" onClick={save}>{existing ? t('Save') : t('Add to routine')}</Button>
|
||||
{ex.custom && <><div style={{ height: 8 }} /><Button icon="pencil" onClick={() => { close(); customExSheet(ex) }}>{t('Edit or delete this exercise')}</Button></>}
|
||||
{onDelete && <><div style={{ height: 8 }} /><Button variant="danger" onClick={() => { close(); onDelete() }}>{t('Remove from routine')}</Button></>}
|
||||
</>
|
||||
}
|
||||
export const exConfigSheet = (ex, existing, onSave, onDelete) => ui().openSheet(close => <ExConfig ex={ex} existing={existing} onSave={onSave} onDelete={onDelete} close={close} />)
|
||||
|
||||
/* ============================ emoji picker ============================ */
|
||||
const ROUTINE_EMOJIS = ['💪', '🏋️', '🏋️♀️', '🦵', '🦾', '🫸', '🫷', '🔥', '⚡', '💥', '🏃', '🏃♀️', '🚴', '🏊', '🤸', '🥊', '🧗', '⛰️', '🏔️', '🚀', '🧘', '🧘♀️', '🎯', '🏆', '🥇', '⭐', '🌟', '👑', '🛡️', '⚔️', '🦍', '🐂', '🐻', '🦁', '🐺', '🦈', '😤', '🤖', '🧨', '❤️🔥']
|
||||
export const emojiPicker = (current, onPick) => ui().openSheet(close => <>
|
||||
<h3>{t('Pick an emoji')}</h3>
|
||||
<div className="emoji-grid">{ROUTINE_EMOJIS.map(e => <button key={e} className={'emoji-cell' + (e === current ? ' on' : '')} onClick={() => { close(); onPick(e) }}>{e}</button>)}</div>
|
||||
</>)
|
||||
/* ============================ glyph picker ============================ */
|
||||
// Grouped by what the glyph means for a training day, so picking one is a scan
|
||||
// of four short rows rather than a hunt through twenty loose icons.
|
||||
export const glyphPicker = (current, onPick) => {
|
||||
const cur = glyphOf(current)
|
||||
return ui().openSheet(close => <>
|
||||
<h3>{t('Pick an icon')}</h3>
|
||||
{GLYPH_GROUPS.map(g => (
|
||||
<div key={g.key} style={{ marginBottom: 14 }}>
|
||||
<div className="sect-t" style={{ padding: '0 2px 7px' }}>{t(g.key)}</div>
|
||||
<div className="glyph-grid">
|
||||
{g.items.map(n => (
|
||||
<button key={n} className={'glyph-cell' + (n === cur ? ' on' : '')}
|
||||
onClick={() => { close(); onPick(n) }} aria-label={n}>
|
||||
<Icon name={n} />
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
<div style={{ height: 4 }} />
|
||||
</>)
|
||||
}
|
||||
|
||||
/* ============================ day override / assign ============================ */
|
||||
function DayOverride({ iso, close }) {
|
||||
@@ -375,18 +392,18 @@ function DayOverride({ iso, close }) {
|
||||
const set = v => {
|
||||
update(s => { if (!v) delete s.dayPlan[iso]; else s.dayPlan[iso] = v })
|
||||
close()
|
||||
toast(v === '' ? t('Back to weekly plan') : v === 'rest' ? t('{0} set to rest', fmtDate(iso)) : t('{0} planned for {1} ✓', (st.routines.find(r => r.id === v) || {}).name, fmtDate(iso)))
|
||||
toast(v === '' ? t('Back to weekly plan') : v === 'rest' ? t('{0} set to rest', fmtDate(iso)) : t('{0} planned for {1}', (st.routines.find(r => r.id === v) || {}).name, fmtDate(iso)))
|
||||
}
|
||||
return <>
|
||||
<h3>{fmtDate(iso, true)}</h3>
|
||||
<div className="muted small" style={{ marginBottom: 12 }}>{t('Weekly plan:')} {weeklyR ? weeklyR.name : t('Rest')}{hasOvr && <span style={{ color: 'var(--orange)' }}> · {t('changed for this day')}</span>}<br />{t('Sick, missed a day or want a different session? Pick what to train instead.')}</div>
|
||||
<div className="list">
|
||||
{st.routines.map(r => <div key={r.id} className="item" onClick={() => set(r.id)}>
|
||||
<div style={{ fontSize: '1.3rem', flex: 'none' }}>{r.emoji || '💪'}</div>
|
||||
<span className="lrow-i"><Icon name={glyphOf(r.emoji)} /></span>
|
||||
<div className="grow"><div className="tt">{r.name}</div><div className="ss">{t('{0} exercises', r.ex.length)}</div></div>
|
||||
{effId === r.id && <span className="accent">✓</span>}</div>)}
|
||||
<div className="item" onClick={() => set('rest')}><div className="grow"><div className="tt">😌 {t('Rest / skip this day')}</div></div>{effId === null && <span className="accent">✓</span>}</div>
|
||||
{hasOvr && <div className="item" onClick={() => set('')}><div className="grow"><div className="tt">↺ {t('Back to weekly plan')}</div></div></div>}
|
||||
{effId === r.id && <Icon name="check" className="accent" />}</div>)}
|
||||
<div className="item" onClick={() => set('rest')}><span className="lrow-i" style={{ background: 'var(--surface-3)' }}><Icon name="moon" /></span><div className="grow"><div className="tt">{t('Rest / skip this day')}</div></div>{effId === null && <Icon name="check" className="accent" />}</div>
|
||||
{hasOvr && <div className="item" onClick={() => set('')}><span className="lrow-i" style={{ background: 'var(--surface-3)' }}><Icon name="reset" /></span><div className="grow"><div className="tt">{t('Back to weekly plan')}</div></div></div>}
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
@@ -398,11 +415,11 @@ function DayAssign({ day, close }) {
|
||||
return <>
|
||||
<h3>{t(DAYN[day])}</h3>
|
||||
<div className="list">
|
||||
<div className="item" onClick={() => set('')}><div className="grow"><div className="tt">😌 {t('Rest day')}</div></div>{!st.week[day] && <span className="accent">✓</span>}</div>
|
||||
<div className="item" onClick={() => set('')}><span className="lrow-i" style={{ background: 'var(--surface-3)' }}><Icon name="moon" /></span><div className="grow"><div className="tt">{t('Rest day')}</div></div>{!st.week[day] && <Icon name="check" className="accent" />}</div>
|
||||
{st.routines.map(r => <div key={r.id} className="item" onClick={() => set(r.id)}>
|
||||
<div style={{ fontSize: '1.3rem', flex: 'none' }}>{r.emoji || '💪'}</div>
|
||||
<span className="lrow-i"><Icon name={glyphOf(r.emoji)} /></span>
|
||||
<div className="grow"><div className="tt">{r.name}</div><div className="ss">{t('{0} exercises', r.ex.length)}</div></div>
|
||||
{st.week[day] === r.id && <span className="accent">✓</span>}</div>)}
|
||||
{st.week[day] === r.id && <Icon name="check" className="accent" />}</div>)}
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
@@ -413,16 +430,16 @@ function WorkoutDetail({ w, close }) {
|
||||
const st = useStore(s => s.S)
|
||||
return <>
|
||||
<h3>{w.name}</h3>
|
||||
<div className="muted small" style={{ marginBottom: 12 }}>{fmtDate(w.d, true)} · {fmtDur(w.end - w.start)} · {fmtVol(w.vol, st.unit)}{w.bw ? ' · ⚖️ ' + fmtNum(w.bw) + ' ' + st.unit : ''}</div>
|
||||
<div className="muted small" style={{ marginBottom: 12 }}>{fmtDate(w.d, true)} · {fmtDur(w.end - w.start)} · {fmtVol(w.vol, st.unit)}{w.bw ? ' · ' + fmtNum(w.bw) + ' ' + st.unit : ''}</div>
|
||||
{w.entries.map((e, i) => {
|
||||
const ex = EXIDX[e.id]
|
||||
return <div key={i} className="row" style={{ marginBottom: 12, alignItems: 'flex-start' }}>
|
||||
{ex && <Thumb ex={ex} />}
|
||||
<div className="grow"><div className="tt capitalize" style={{ fontWeight: 700 }}>{ex ? ex.n : (e.n || e.id)} {w.prs && w.prs.includes(e.id) && <span className="pr">🏆 PR</span>}</div>
|
||||
<div className="grow"><div className="tt capitalize" style={{ fontWeight: 600 }}>{ex ? ex.n : (e.n || e.id)} {w.prs && w.prs.includes(e.id) && <span className="pr"><Icon name="trophy" />PR</span>}</div>
|
||||
<div className="ss">{e.sets.filter(s => s.done).map(s => setLabel(e.id, s)).join(' · ') || t('no sets')}</div></div>
|
||||
</div>
|
||||
})}
|
||||
<button className="btn danger" onClick={() => confirmSheet({ title: t('Delete workout?'), message: t('This removes it from your history for good.'), confirmText: t('Delete'), danger: true, onConfirm: () => { update(s => { s.workouts = s.workouts.filter(x => x.id !== w.id) }); close(); toast(t('Workout deleted')) } })}>{t('Delete workout')}</button>
|
||||
<Button variant="danger" onClick={() => confirmSheet({ title: t('Delete workout?'), message: t('This removes it from your history for good.'), confirmText: t('Delete'), danger: true, onConfirm: () => { update(s => { s.workouts = s.workouts.filter(x => x.id !== w.id) }); close(); toast(t('Workout deleted')) } })}>{t('Delete workout')}</Button>
|
||||
</>
|
||||
}
|
||||
export const workoutDetailSheet = w => ui().openSheet(close => <WorkoutDetail w={w} close={close} />)
|
||||
@@ -453,9 +470,9 @@ function Calendar({ start, close }) {
|
||||
}
|
||||
return <>
|
||||
<div className="row between" style={{ marginBottom: 2 }}>
|
||||
<button className="iconbtn" onClick={() => setCur(new Date(y, mo - 1, 1))}>‹</button>
|
||||
<button className="iconbtn" onClick={() => setCur(new Date(y, mo - 1, 1))} aria-label="Previous month"><Icon name="chevronLeft" /></button>
|
||||
<h3 style={{ margin: 0 }}>{t(MONTHS_LONG[mo])} {y}</h3>
|
||||
<button className="iconbtn" onClick={() => setCur(new Date(y, mo + 1, 1))}>›</button>
|
||||
<button className="iconbtn" onClick={() => setCur(new Date(y, mo + 1, 1))} aria-label="Next month"><Icon name="chevronRight" /></button>
|
||||
</div>
|
||||
<div className="small muted" style={{ textAlign: 'center' }}>{monthWs.length ? `${t(monthWs.length === 1 ? '{0} workout' : '{0} workouts', monthWs.length)} · ${fmtDur(monthMs)} · ${fmtVol(monthVol, st.unit)}` : t('No workouts this month')}</div>
|
||||
<div className="cal-grid">{['Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa', 'Su'].map(l => <div key={l} className="cal-h">{t(l)}</div>)}{cells}</div>
|
||||
@@ -472,13 +489,13 @@ export const calendarSheet = start => ui().openSheet(close => <Calendar start={s
|
||||
/* shared small workout row (used in lists) */
|
||||
export function WorkoutRow({ w, onClick }) {
|
||||
const st = useStore(s => s.S)
|
||||
const emoji = (st.routines.find(r => r.id === w.routineId) || {}).emoji || '💪'
|
||||
const glyph = glyphOf((st.routines.find(r => r.id === w.routineId) || {}).emoji)
|
||||
return <div className="item" onClick={onClick}>
|
||||
<div style={{ fontSize: '1.5rem', flex: 'none' }}>{emoji}</div>
|
||||
<span className="lrow-i" style={{ width: 34, height: 34, borderRadius: 8, fontSize: 19 }}><Icon name={glyph} /></span>
|
||||
<div className="grow"><div className="tt">{w.name}</div>
|
||||
<div className="ss">{fmtDate(w.d, true)} · {fmtDur(w.end - w.start)} · {t('{0} sets', setsDone(w))} · {fmtVol(w.vol, st.unit)}</div></div>
|
||||
{w.prs && w.prs.length > 0 && <span className="pr">🏆 {w.prs.length} PR</span>}
|
||||
<span className="chev">›</span>
|
||||
{w.prs && w.prs.length > 0 && <span className="pr"><Icon name="trophy" />{w.prs.length} PR</span>}
|
||||
<Icon name="chevronRight" className="chev" />
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -523,18 +540,18 @@ function TopWeight({ entryIdx, close }) {
|
||||
if (advance && unitDone) {
|
||||
if (isLastUnit) workoutCompleteSheet() // whole workout done → finish/continue prompt
|
||||
else update(s => { s.active.cur = units[unitIdx + 1][0] })
|
||||
} else toast(t('Tracked — next time starts at {0} 📈', fmtNum(S().exWeights[entry.id].w) + ' ' + st.unit))
|
||||
} else toast(t('Tracked — next time starts at {0}', fmtNum(S().exWeights[entry.id].w) + ' ' + st.unit))
|
||||
}
|
||||
return <>
|
||||
<h3 className="capitalize">✅ {t('{0} done', ex.n)}</h3>
|
||||
<h3 className="capitalize row" style={{ gap: 8 }}><Icon name="checkCircle" style={{ color: 'var(--acc)' }} />{t('{0} done', ex.n)}</h3>
|
||||
<div className="muted small">{t('Confirm the weight you worked with — your highest becomes the default next time.')}{!unitDone && unit.length > 1 ? ' ' + t('Then finish the superset partner.') : ''}</div>
|
||||
<WeightInput value={v} setValue={setV} unit={st.unit} />
|
||||
<div style={{ height: 10 }} />
|
||||
{prevBest > 0 ? <div className="small dim" style={{ textAlign: 'center', marginBottom: 12 }}>{t('Previous best:')} {fmtNum(prevBest)} {st.unit}{maxSet > prevBest && <span style={{ color: 'var(--gold)' }}> — {t('new record! 🏆')}</span>}</div> : <div style={{ height: 4 }} />}
|
||||
{prevBest > 0 ? <div className="small dim" style={{ textAlign: 'center', marginBottom: 12 }}>{t('Previous best:')} {fmtNum(prevBest)} {st.unit}{maxSet > prevBest && <span style={{ color: 'var(--yellow)' }}> — {t('new record!')}</span>}</div> : <div style={{ height: 4 }} />}
|
||||
{unitDone ? <>
|
||||
<button className="btn primary" onClick={() => commit(true)}>{isLastUnit ? t('Save ✓') : t('Save & next exercise ›')}</button>
|
||||
<div style={{ height: 8 }} /><button className="btn ghost dim" onClick={() => commit(false)}>{t('Just close')}</button>
|
||||
</> : <button className="btn primary" onClick={() => commit(false)}>{t('Save weight')}</button>}
|
||||
<Button variant="primary" trailingIcon={isLastUnit ? null : 'chevronRight'} onClick={() => commit(true)}>{isLastUnit ? t('Save') : t('Save & next exercise')}</Button>
|
||||
<div style={{ height: 8 }} /><Button variant="ghost" className="dim" onClick={() => commit(false)}>{t('Just close')}</Button>
|
||||
</> : <Button variant="primary" onClick={() => commit(false)}>{t('Save weight')}</Button>}
|
||||
</>
|
||||
}
|
||||
export const topWeightSheet = entryIdx => ui().openSheet(close => <TopWeight entryIdx={entryIdx} close={close} />)
|
||||
@@ -542,12 +559,12 @@ export const topWeightSheet = entryIdx => ui().openSheet(close => <TopWeight ent
|
||||
// Shown when the last exercise's last set is checked — finish, or keep going.
|
||||
function WorkoutComplete({ close }) {
|
||||
return <div style={{ textAlign: 'center', padding: '8px 0' }}>
|
||||
<div style={{ fontSize: '3rem' }}>🎉</div>
|
||||
<div style={{ fontSize: 44, display: 'flex', justifyContent: 'center', color: 'var(--acc)' }}><Icon name="checkCircle" /></div>
|
||||
<h3 style={{ margin: '8px 0' }}>{t("That's the whole workout!")}</h3>
|
||||
<div className="muted small" style={{ marginBottom: 16 }}>{t('Every exercise done — great work. Finish up, or keep going and add another exercise.')}</div>
|
||||
<button className="btn primary" onClick={() => { close(); finishWorkout() }}>{t('Finish workout 🏁')}</button>
|
||||
<Button variant="primary" icon="flag" onClick={() => { close(); finishWorkout() }}>{t('Finish workout')}</Button>
|
||||
<div style={{ height: 8 }} />
|
||||
<button className="btn" onClick={() => { close(); useUI.getState().toast(t('Keep going 💪 — tap “+ Add exercise” below')) }}>{t('Continue workout')}</button>
|
||||
<Button onClick={() => { close(); useUI.getState().toast(t('Keep going — tap “+ Add exercise” below')) }}>{t('Continue workout')}</Button>
|
||||
</div>
|
||||
}
|
||||
export const workoutCompleteSheet = () => ui().openSheet(close => <WorkoutComplete close={close} />, { kind: 'center' })
|
||||
@@ -555,16 +572,16 @@ export const workoutCompleteSheet = () => ui().openSheet(close => <WorkoutComple
|
||||
function FinishSummary({ w, prs, close }) {
|
||||
const st = useStore(s => s.S)
|
||||
return <div style={{ textAlign: 'center', padding: '8px 0' }}>
|
||||
<div style={{ fontSize: '3rem' }}>🎉</div>
|
||||
<div style={{ fontSize: 44, display: 'flex', justifyContent: 'center', color: 'var(--acc)' }}><Icon name="trophy" /></div>
|
||||
<h3 style={{ margin: '8px 0' }}>{t('Workout complete!')}</h3>
|
||||
<div className="tiles" style={{ textAlign: 'left' }}>
|
||||
<div className="tile"><div className="l">{t('Duration')}</div><div className="v" style={{ fontSize: '1.1rem' }}>{fmtDur(w.end - w.start)}</div></div>
|
||||
<div className="tile"><div className="l">{t('Volume')}</div><div className="v" style={{ fontSize: '1.1rem' }}>{fmtVol(w.vol, st.unit)}</div></div>
|
||||
<div className="tile"><div className="l">{t('Sets')}</div><div className="v" style={{ fontSize: '1.1rem' }}>{setsDone(w)}</div></div>
|
||||
<div className="tile"><div className="l">{t('PRs')}</div><div className="v" style={{ fontSize: '1.1rem' }}>{prs.length ? '🏆 ' + prs.length : '—'}</div></div>
|
||||
<div className="tile"><div className="l">{t('PRs')}</div><div className="v" style={{ fontSize: 20 }}>{prs.length || '—'}</div></div>
|
||||
</div>
|
||||
{prs.length > 0 && <div style={{ textAlign: 'left', marginBottom: 12 }}>{prs.map(id => <div key={id} className="small accent capitalize">🏆 {t('New PR:')} {(EXIDX[id] || {}).n || id}</div>)}</div>}
|
||||
<button className="btn primary" onClick={() => { close(); nav('/home') }}>{t('Nice! 💪')}</button>
|
||||
{prs.length > 0 && <div style={{ textAlign: 'left', marginBottom: 12 }}>{prs.map(id => <div key={id} className="small accent capitalize row" style={{ gap: 5 }}><Icon name="trophy" style={{ fontSize: 13 }} />{t('New PR:')} {(EXIDX[id] || {}).n || id}</div>)}</div>}
|
||||
<Button variant="primary" onClick={() => { close(); nav('/home') }}>{t('Nice!')}</Button>
|
||||
</div>
|
||||
}
|
||||
export function finishWorkout() {
|
||||
|
||||
Reference in new issue
Block a user