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:
Duarte Santos committed 2026-07-23 11:55:52 +02:00
1 parent fc36476a5f
commit b28a58930c
37 files changed
+2168 -1061

No files matched your search

+15 -13
View File
@@ -6,6 +6,8 @@ import { api } from '../lib/api.js'
import { fmtDate, fmtNum, fmtVol, fmtDur } from '../lib/format.js'
import { workoutVolume, setsDone } from '../lib/history.js'
import { confirmSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
import { Button } from '../components/ui.jsx'
// Admin-only operator dashboard (owner passkey + admin flag; guarded again server-side).
// Deliberately English-only — it isn't part of the translated end-user surface, so it stays
@@ -52,9 +54,9 @@ function UserDetail({ id, onChanged, close }) {
{u.disabled ? 'Enable account' : 'Disable account'}</button>}
<h4 className="sec">Workout history</h4>
{d.workouts.length ? <div className="list" style={{ gap: 0 }}>
{d.workouts.slice(0, 60).map(w => <div key={w.id} className="row between" style={{ padding: '9px 2px', borderBottom: '1px solid var(--bg2)' }}>
<div><div className="small" style={{ fontWeight: 700 }}>{w.name}</div>
<div className="dim" style={{ fontSize: '.72rem' }}>{fmtDate(w.d, true)} · {fmtDur((w.end || w.start) - w.start)} · {setsDone(w)} sets{w.prs?.length ? ' · 🏆 ' + w.prs.length : ''}</div></div>
{d.workouts.slice(0, 60).map(w => <div key={w.id} className="row between" style={{ padding: '9px 2px', borderBottom: '1px solid var(--sep)' }}>
<div><div className="small" style={{ fontWeight: 600 }}>{w.name}</div>
<div className="dim" style={{ fontSize: '.72rem' }}>{fmtDate(w.d, true)} · {fmtDur((w.end || w.start) - w.start)} · {setsDone(w)} sets{w.prs?.length ? ' · ' + w.prs.length + ' PR' : ''}</div></div>
<span className="small muted">{fmtVol(w.vol ?? workoutVolume(w), d.unit)}</span>
</div>)}
</div> : <div className="empty small">No workouts logged.</div>}
@@ -72,12 +74,12 @@ function InvitesCard({ invites, reload }) {
const used = (invites || []).filter(i => i.usedBy)
return <div className="card">
<div className="row between"><h2 style={{ margin: 0 }}>Invite codes</h2>
<button className="btn sm primary" onClick={gen}>+ Generate</button></div>
<Button variant="primary" size="sm" onClick={gen} icon="plus">Generate</Button></div>
<div className="small muted" style={{ margin: '6px 0 10px' }}>{open.length} unused · {used.length} redeemed</div>
{open.map(i => <div key={i.code} className="row between" style={{ padding: '7px 2px', borderBottom: '1px solid var(--bg2)' }}>
<span style={{ fontFamily: 'monospace', fontWeight: 700, letterSpacing: '.06em' }}
{open.map(i => <div key={i.code} className="row between" style={{ padding: '7px 2px', borderBottom: '1px solid var(--sep)' }}>
<span style={{ fontFamily: 'ui-monospace,SFMono-Regular,Menlo,monospace', fontWeight: 500, letterSpacing: '.06em' }}
onClick={() => { navigator.clipboard?.writeText(i.code).catch(() => {}); toast('Copied ' + i.code) }}>{i.code}</span>
<button className="iconbtn" style={{ width: 34, height: 30, fontSize: '.9rem' }} onClick={() => revoke(i.code)} aria-label="revoke">🗑</button>
<button className="iconbtn" style={{ width: 32, height: 30, borderRadius: 8, fontSize: 15, color: 'var(--red)' }} onClick={() => revoke(i.code)} aria-label="revoke"><Icon name="trash" /></button>
</div>)}
{used.map(i => <div key={i.code} className="row between dim" style={{ padding: '7px 2px', fontSize: '.8rem' }}>
<span style={{ fontFamily: 'monospace' }}>{i.code}</span><span>→ {i.usedByName || 'used'}</span>
@@ -108,7 +110,7 @@ export default function Admin() {
return <div className="narrow">
<div className="hdr">
<button className="iconbtn" onClick={() => nav('/settings')}>‹</button>
<button className="iconbtn" onClick={() => nav('/settings')} aria-label="Back"><Icon name="chevronLeft" /></button>
<div style={{ flex: 1, marginLeft: 8 }}><h1 style={{ margin: 0 }}>Admin</h1>
<div className="sub">{users ? users.length + ' users · ' + activeCount + ' active this week' : 'Loading…'}</div></div>
<button className="iconbtn" onClick={() => { loadUsers(); loadInvites() }} aria-label="refresh">↻</button>
@@ -122,9 +124,9 @@ export default function Admin() {
</div>
{liveUsers.length > 0 && <div className="card" style={{ borderColor: 'var(--acc)' }}>
<h2 style={{ margin: '0 0 8px' }}>🟢 Training now</h2>
{liveUsers.map(u => <div key={u.id} className="row between" style={{ padding: '8px 2px', borderBottom: '1px solid var(--bg2)' }} onClick={() => openUser(u.id)}>
<div><div className="small" style={{ fontWeight: 700 }}>{u.name}</div>
<h2 className="row" style={{ margin: '0 0 8px', gap: 6 }}><Icon name="dot" style={{ fontSize: 10, color: 'var(--green)' }} />Training now</h2>
{liveUsers.map(u => <div key={u.id} className="row between" style={{ padding: '8px 2px', borderBottom: '1px solid var(--sep)' }} onClick={() => openUser(u.id)}>
<div><div className="small" style={{ fontWeight: 600 }}>{u.name}</div>
<div className="dim" style={{ fontSize: '.72rem' }}>{u.live.name} · ex {u.live.exIdx}/{u.live.exTotal} · {u.live.setsDone}/{u.live.setsTotal} sets</div></div>
<span className="tag acc">{dur(Date.now() - u.live.startedAt)}</span>
</div>)}
@@ -135,9 +137,9 @@ export default function Admin() {
<h4 className="sec">Users</h4>
<div className="list">
{(users || []).map(u => <div key={u.id} className="item" onClick={() => openUser(u.id)} style={u.disabled ? { opacity: .55 } : null}>
<div className="grow"><div className="tt">{u.live && '🟢 '}{u.name} {u.admin && <span className="tag acc" style={{ marginLeft: 4 }}>admin</span>}{u.disabled && <span className="tag" style={{ marginLeft: 4, color: 'var(--red)' }}>off</span>}</div>
<div className="grow"><div className="tt">{u.live && <Icon name="dot" style={{ fontSize: 9, color: 'var(--green)', display: 'inline-block', marginRight: 5 }} />}{u.name} {u.admin && <span className="tag acc" style={{ marginLeft: 4 }}>admin</span>}{u.disabled && <span className="tag" style={{ marginLeft: 4, color: 'var(--red)' }}>off</span>}</div>
<div className="ss">{u.live ? 'training now · ' + u.live.name : u.workouts + ' workouts' + (u.lastWorkout ? ' · last ' + fmtDate(u.lastWorkout) : '') + ' · synced ' + rel(u.lastSync)}</div></div>
{u.hasPush && <span title="push enabled">🔔</span>}<span className="chev">›</span>
{u.hasPush && <Icon name="bell" title="push enabled" style={{ fontSize: 15, color: 'var(--label-3)' }} />}<Icon name="chevronRight" className="chev" />
</div>)}
{users && !users.length && <div className="empty">No users yet.</div>}
</div>
+3 -2
View File
@@ -2,14 +2,15 @@ import { useNavigate } from 'react-router-dom'
import { useStore } from '../store/useStore.js'
import { t } from '../lib/i18n.js'
import { WorkoutRow, workoutDetailSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
export default function History() {
const nav = useNavigate()
const S = useStore(s => s.S)
return <>
<div className="hdr"><button className="iconbtn" onClick={() => nav('/stats')}>‹</button>
<div className="hdr"><button className="iconbtn" onClick={() => nav('/stats')} aria-label={t('Stats')}><Icon name="chevronLeft" /></button>
<div style={{ flex: 1, marginLeft: 12 }}><h1>{t('History')}</h1><div className="sub">{t('{0} workouts', S.workouts.length)}</div></div></div>
{S.workouts.length ? <div className="list">{[...S.workouts].reverse().map(w => <WorkoutRow key={w.id} w={w} onClick={() => workoutDetailSheet(w)} />)}</div>
: <div className="empty"><div className="ico">🗂</div>{t('No workouts yet.')}</div>}
: <div className="empty"><div className="ico"><Icon name="history" /></div>{t('No workouts yet.')}</div>}
</>
}
+39 -18
View File
@@ -6,6 +6,9 @@ import { fmtNum, fmtDate, todayISO, isoOf, weekKey, DAYS } from '../lib/format.j
import { t, dateLocale } from '../lib/i18n.js'
import { bwSheet, goalSheet, dayOverrideSheet, calendarSheet, startFlow, loadStarterPlan, bwDeltaColor } from '../sheets.jsx'
import LineChart from '../components/LineChart.jsx'
import Icon from '../components/Icon.jsx'
import { Button } from '../components/ui.jsx'
import { glyphOf } from '../lib/glyphs.js'
// Home = what to do now + a quick glance. Deep charts & history live in Stats.
export default function Home() {
@@ -44,37 +47,42 @@ export default function Home() {
return <div className="narrow">
<div className="hdr">
<div><h1>{user ? t('Hi {0} 💪', user.name) : 'openGym 🏋️'}</h1><div className="sub">{today.toLocaleDateString(dateLocale(), { weekday: 'long', day: 'numeric', month: 'long' })}</div></div>
<button className="iconbtn" onClick={() => nav('/settings')}>⚙️</button>
<div><h1>{user ? t('Hi {0}', user.name) : 'openGym'}</h1><div className="sub">{today.toLocaleDateString(dateLocale(), { weekday: 'long', day: 'numeric', month: 'long' })}</div></div>
<button className="iconbtn" onClick={() => nav('/settings')} aria-label={t('Settings')}><Icon name="gear" /></button>
</div>
<div className="card">
<div className="row between" style={{ marginBottom: 8 }}>
<button className="iconbtn" style={{ width: 32, height: 32 }} onClick={() => setWeekOffset(w => w - 1)}>‹</button>
<div className="small muted" style={{ fontWeight: 600 }}>{wkLabel}</div>
<button className="iconbtn" style={{ width: 32, height: 32 }} onClick={() => setWeekOffset(w => w + 1)}>›</button>
<button className="iconbtn" style={{ width: 30, height: 30, fontSize: 15 }} onClick={() => setWeekOffset(w => w - 1)} aria-label="Previous week"><Icon name="chevronLeft" /></button>
<div className="small muted" style={{ fontWeight: 500 }}>{wkLabel}</div>
<button className="iconbtn" style={{ width: 30, height: 30, fontSize: 15 }} onClick={() => setWeekOffset(w => w + 1)} aria-label="Next week"><Icon name="chevronRight" /></button>
</div>
<div className="week">{strip}</div>
<div className="today-row" onClick={onToday}>
<div className="row" style={{ gap: 9, minWidth: 0 }}>
<span style={{ fontSize: '1.35rem', flex: 'none' }}>{S.active ? '⏱️' : routine ? (routine.emoji || '💪') : '😌'}</span>
<span className="lrow-i" style={{ background: S.active ? 'var(--orange)' : routine ? 'var(--acc)' : 'var(--surface-3)' }}>
<Icon name={S.active ? 'timer' : routine ? glyphOf(routine.emoji) : 'moon'} />
</span>
<div style={{ minWidth: 0 }}>
<div className="lbl2">{t('Today')}</div>
<div className="ttl">{S.active ? t('{0} — in progress', S.active.name) : routine ? routine.name : t('Rest day')}{todayOvr && routine ? ' · ' + t('rescheduled') : ''}</div>
</div>
</div>
{S.active ? <span className="tag" style={{ color: 'var(--orange)', borderColor: 'var(--orange)' }}>{t('Resume ▶')}</span>
: routine ? <span className="tag acc">{t('Start ▶')}</span>
: <span className="chev">+</span>}
{S.active ? <span className="tag" style={{ color: 'var(--orange)', background: 'color-mix(in srgb,var(--orange) 16%,transparent)' }}>{t('Resume')}</span>
: routine ? <span className="tag acc">{t('Start')}</span>
: <Icon name="plus" className="chev" />}
</div>
</div>
{!S.routines.length && !S.active && (
<div className="card">
<div className="big" style={{ marginBottom: 4 }}>{t('Welcome! 👋')}</div>
<div className="row" style={{ gap: 10, marginBottom: 6 }}>
<span className="lrow-i"><Icon name="sparkles" /></span>
<div className="big" style={{ fontSize: 22 }}>{t('Welcome!')}</div>
</div>
<div className="muted small" style={{ marginBottom: 12 }}>{t('Set up your weekly routine to get going — or load a ready-made Push / Pull / Legs plan.')}</div>
<button className="btn primary" onClick={loadStarterPlan}>{t('Load starter plan (PPL)')}</button>
<div style={{ height: 8 }} /><button className="btn" onClick={() => nav('/plan')}>{t('Build my own plan')}</button>
<Button variant="primary" icon="sparkles" onClick={loadStarterPlan}>{t('Load starter plan (PPL)')}</Button>
<div style={{ height: 8 }} /><Button onClick={() => nav('/plan')}>{t('Build my own plan')}</Button>
</div>
)}
@@ -82,17 +90,27 @@ export default function Home() {
<div className="row between" style={{ marginBottom: 6 }}>
<h2 style={{ margin: 0 }}>{t('Body weight')}</h2>
<div className="row" style={{ gap: 8 }}>
<button className="btn sm" style={S.targetW ? { color: 'var(--gold)' } : undefined} onClick={goalSheet}>🎯 {S.targetW ? fmtNum(S.targetW) : t('Goal')}</button>
<button className="btn sm" onClick={() => bwSheet()}>+ {t('Log')}</button>
<Button size="sm" icon="target" style={S.targetW ? { color: 'var(--yellow)' } : undefined} onClick={goalSheet}>{S.targetW ? fmtNum(S.targetW) : t('Goal')}</Button>
<Button size="sm" icon="plus" onClick={() => bwSheet()}>{t('Log')}</Button>
</div>
</div>
{bw ? <>
<div className="row" style={{ gap: 8, alignItems: 'baseline' }}>
<div className="big">{fmtNum(bw.w)} <span className="muted" style={{ fontSize: '1rem' }}>{S.unit}</span></div>
{delta !== null && <span className="small" style={{ fontWeight: 700, color: bwDeltaColor(delta, bw.w) }}>{delta > 0 ? '▲' : delta < 0 ? '▼' : '•'} {fmtNum(Math.abs(delta))}</span>}
{delta !== null && (
<span className="small row" style={{ gap: 2, fontWeight: 500, color: bwDeltaColor(delta, bw.w) }}>
<Icon name={delta > 0 ? 'arrowUp' : delta < 0 ? 'arrowDown' : 'minus'} style={{ fontSize: 12 }} />
{fmtNum(Math.abs(delta))}
</span>
)}
<span className="dim small" style={{ marginLeft: 'auto' }}>{fmtDate(bw.d, true)}</span>
</div>
{S.targetW && <div className="small" style={{ color: 'var(--gold)', marginTop: 2 }}>🎯 {t('Goal')} {fmtNum(S.targetW)} {S.unit} · {Math.abs(S.targetW - bw.w) < 0.05 ? t('reached! 🎉') : t(S.targetW > bw.w ? '{0} to gain' : '{0} to lose', fmtNum(Math.abs(S.targetW - bw.w)) + ' ' + S.unit)}</div>}
{S.targetW && (
<div className="small row" style={{ color: 'var(--yellow)', marginTop: 4, gap: 5 }}>
<Icon name="target" style={{ fontSize: 13 }} />
<span>{t('Goal')} {fmtNum(S.targetW)} {S.unit} · {Math.abs(S.targetW - bw.w) < 0.05 ? t('reached!') : t(S.targetW > bw.w ? '{0} to gain' : '{0} to lose', fmtNum(Math.abs(S.targetW - bw.w)) + ' ' + S.unit)}</span>
</div>
)}
<div className="chart" style={{ marginTop: 8 }}><LineChart points={bwPoints} h={130} unit={S.unit} goal={S.targetW} /></div>
</> : <div className="muted small">{t("No entries yet — log your weight to start the curve. It's also asked before every workout.")}</div>}
</div>
@@ -100,10 +118,13 @@ export default function Home() {
<div className="card tappable" style={{ cursor: 'pointer' }} onClick={() => calendarSheet()}>
<div className="row between">
<div>
<div style={{ fontSize: '1.35rem', fontWeight: 800 }}>🔥 {t('{0} week streak', streakWeeks(S))}</div>
<div className="row" style={{ gap: 7, fontSize: 22, fontWeight: 600, letterSpacing: '-.021em' }}>
<Icon name="flame" style={{ color: 'var(--orange)' }} />
{t('{0} week streak', streakWeeks(S))}
</div>
<div className="muted small" style={{ marginTop: 2 }}>{wThisWeek}{plannedPerWeek ? ' / ' + plannedPerWeek : ''} {t('this week')} · {t(S.workouts.length === 1 ? '{0} workout total' : '{0} workouts total', S.workouts.length)}</div>
</div>
<span className="chev" style={{ fontSize: '1.4rem' }}>📅</span>
<Icon name="calendar" className="chev" style={{ fontSize: 20 }} />
</div>
</div>
</div>
+10 -8
View File
@@ -6,6 +6,8 @@ import { fmtNum } from '../lib/format.js'
import { t } from '../lib/i18n.js'
import { Thumb } from '../components/Media.jsx'
import { exerciseDetailSheet, addToRoutineSheet, customExSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
import { Button } from '../components/ui.jsx'
export default function Library() {
const S = useStore(s => s.S)
@@ -25,29 +27,29 @@ export default function Library() {
<div className="search" style={{ marginBottom: 10 }}><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…')} value={q} onChange={e => { setQ(e.target.value); setShown(40) }} /></div>
<div className="chips" style={{ marginBottom: eqOpts.length > 1 ? 8 : 12 }}>
<button className={'chip' + (!bp ? ' on' : '')} onClick={() => { setBp(''); setEq(''); setShown(40) }}>{t('All')}</button>
<button className={'chip nocap' + (!bp ? ' on' : '')} onClick={() => { setBp(''); setEq(''); setShown(40) }}>{t('All')}</button>
{BODYPARTS.map(b => <button key={b} className={'chip' + (bp === b ? ' on' : '')} onClick={() => { setBp(b); setEq(''); setShown(40) }}>{t(b)}</button>)}
</div>
{eqOpts.length > 1 && <div className="chips" style={{ marginBottom: 12 }}>
<button className={'chip' + (!eqOn ? ' on' : '')} onClick={() => { setEq(''); setShown(40) }}>{t('Any equipment')}</button>
<button className={'chip nocap' + (!eqOn ? ' on' : '')} onClick={() => { setEq(''); setShown(40) }}>{t('Any equipment')}</button>
{eqOpts.map(x => <button key={x} className={'chip' + (eqOn === x ? ' on' : '')} onClick={() => { setEq(x); setShown(40) }}>{t(x)}</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 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 => {
const best = bestWeightFor(S, e.id)
return <div key={e.id} className="item" onClick={() => exerciseDetailSheet(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>
<div className="grow"><div className="tt capitalize">{e.n}</div><div className="ss capitalize">{t(e.tg || e.bp)} · {t(e.eq)}</div></div>
{best > 0 && <span className="tag acc">{fmtNum(best)}</span>}
<button className="btn sm primary" onClick={ev => { ev.stopPropagation(); addToRoutineSheet(e) }}>+ {t('Plan')}</button>
<Button size="sm" variant="tinted" icon="plus" onClick={ev => { ev.stopPropagation(); addToRoutineSheet(e) }}>{t('Plan')}</Button>
</div>
})}
{f.length === 0 && <div className="empty">{t('No match 🤷')}</div>}
{f.length === 0 && <div className="empty"><div className="ico"><Icon name="magnifier" /></div>{t('No match')}</div>}
</div>
{f.length > shown && <><div style={{ height: 10 }} /><button className="btn" onClick={() => setShown(s => s + 40)}>{t('Show more')}</button></>}
{f.length > shown && <><div style={{ height: 10 }} /><Button onClick={() => setShown(s => s + 40)}>{t('Show more')}</Button></>}
</>
}
+13 -11
View File
@@ -4,6 +4,8 @@ import { webauthnOK, passkeyLogin, passkeyRegister, api, BIO } from '../lib/api.
import { hasData } from '../store/useStore.js'
import { t } from '../lib/i18n.js'
import { useState, useRef, useEffect } from 'react'
import Icon from '../components/Icon.jsx'
import { Button } from '../components/ui.jsx'
function RegisterSheet({ close }) {
const { setUser, pushState, pullState } = useStore()
@@ -20,43 +22,43 @@ function RegisterSheet({ close }) {
try {
const u = await passkeyRegister(n, code.trim())
setUser(u); close()
if (hasData(useStore.getState().S)) { await pushState(); useUI.getState().toast(t('Profile created — data from this device moved into it ✓')) }
else { await pullState(); useUI.getState().toast(t('Welcome, {0} 💪', u.name)) }
if (hasData(useStore.getState().S)) { await pushState(); useUI.getState().toast(t('Profile created — data from this device moved into it')) }
else { await pullState(); useUI.getState().toast(t('Welcome, {0}', u.name)) }
} catch (e) { if (e.name !== 'NotAllowedError' && e.name !== 'AbortError') useUI.getState().toast(e.message || t('Registration failed')) }
}
return <>
<h3>{t('Create your profile ✨')}</h3>
<h3>{t('Create your profile')}</h3>
<div className="muted small" style={{ marginBottom: 14 }}>{t('Pick a name, then confirm with {0}. The passkey is saved in your device — no password needed.', BIO)}</div>
<input ref={ref} className="input" placeholder={t('Your name')} maxLength={40} value={name} onChange={e => setName(e.target.value)} />
{inviteOnly && <>
<div style={{ height: 10 }} />
<input className="input" placeholder={t('Invite code')} maxLength={40} value={code}
onChange={e => setCode(e.target.value.toUpperCase())} style={{ letterSpacing: '.08em', fontWeight: 700 }} />
onChange={e => setCode(e.target.value.toUpperCase())} style={{ letterSpacing: '.14em', fontWeight: 600, textAlign: 'center' }} />
<div className="dim small" style={{ marginTop: 6 }}>{t('This app is invite-only — enter the code you were given.')}</div>
</>}
<div style={{ height: 12 }} />
<button className="btn primary" onClick={go}>{t('Create passkey')}</button>
<Button variant="primary" onClick={go}>{t('Create passkey')}</Button>
</>
}
export default function Login() {
const { setUser, pullState, setGuest } = useStore()
const signIn = async () => {
try { const u = await passkeyLogin(); setUser(u); await pullState(); useUI.getState().toast(t('Welcome back, {0} 💪', u.name)) }
try { const u = await passkeyLogin(); setUser(u); await pullState(); useUI.getState().toast(t('Welcome back, {0}', u.name)) }
catch (e) { if (e.name !== 'NotAllowedError' && e.name !== 'AbortError') useUI.getState().toast(e.message || t('Sign-in failed')) }
}
return (
<div className="narrow" style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', minHeight: '78vh', textAlign: 'center' }}>
<div style={{ fontSize: '4rem' }}>🏋️</div>
<h1 style={{ fontSize: '2.2rem', fontWeight: 800, letterSpacing: '-.02em', margin: '8px 0 4px' }}>openGym</h1>
<div style={{ fontSize: 54, display: 'flex', justifyContent: 'center', color: 'var(--acc)' }}><Icon name="dumbbell" /></div>
<h1 style={{ fontSize: 34, fontWeight: 700, letterSpacing: '-.028em', margin: '10px 0 4px' }}>openGym</h1>
<div className="muted" style={{ marginBottom: 34 }}>{t('Your workouts. Your weights. Your profile.')}</div>
{webauthnOK() ? <>
<button className="btn primary" onClick={signIn}>👤 {t('Sign in with passkey')}</button>
<Button variant="primary" icon="person" onClick={signIn}>{t('Sign in with passkey')}</Button>
<div style={{ height: 10 }} />
<button className="btn" onClick={() => useUI.getState().openSheet(close => <RegisterSheet close={close} />)}>✨ {t('Create new profile')}</button>
<Button icon="sparkles" onClick={() => useUI.getState().openSheet(close => <RegisterSheet close={close} />)}>{t('Create new profile')}</Button>
<div style={{ height: 10 }} />
</> : <div className="card small muted" style={{ textAlign: 'left' }}>{t("This browser doesn't support passkeys — you can still use openGym locally on this device.")}</div>}
<button className="btn ghost dim" onClick={() => setGuest(true)}>{t('Continue without account')}</button>
<Button variant="ghost" className="dim" onClick={() => setGuest(true)}>{t('Continue without account')}</Button>
<div className="dim small" style={{ marginTop: 26, lineHeight: 1.5 }}>{t('Passkeys use {0} — no passwords.', BIO)}<br />{t('Each profile keeps its own plan, workouts & body weight.')}</div>
</div>
)
+11 -8
View File
@@ -3,6 +3,9 @@ import { useStore } from '../store/useStore.js'
import { DAYN, uid } from '../lib/format.js'
import { t } from '../lib/i18n.js'
import { dayAssignSheet, loadStarterPlan } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
import { Button } from '../components/ui.jsx'
import { glyphOf, DEFAULT_GLYPH } from '../lib/glyphs.js'
export default function Plan() {
const nav = useNavigate()
@@ -10,7 +13,7 @@ export default function Plan() {
const update = useStore(s => s.update)
const addRoutine = () => {
const r = { id: uid(), name: t('New routine'), emoji: '💪', ex: [] }
const r = { id: uid(), name: t('New routine'), emoji: DEFAULT_GLYPH, ex: [] }
update(s => { s.routines.push(r) })
nav('/plan/r/' + r.id)
}
@@ -24,21 +27,21 @@ export default function Plan() {
const r = S.routines.find(x => x.id === S.week[d])
return <div key={d} className="item" onClick={() => dayAssignSheet(d)}>
<div className="grow"><div className="tt">{t(DAYN[d])}</div></div>
{r ? <span className="tag acc">{(r.emoji || '') + ' ' + r.name}</span> : <span className="tag">{t('Rest')}</span>}
<span className="chev">›</span></div>
{r ? <span className="tag acc"><Icon name={glyphOf(r.emoji)} />{r.name}</span> : <span className="tag">{t('Rest')}</span>}
<Icon name="chevronRight" className="chev" /></div>
})}
</div>
</div><div>
<div className="row between" style={{ marginTop: 22, marginBottom: 10 }}>
<h4 className="sec" style={{ margin: 0 }}>{t('Routines')}</h4>
<button className="btn sm primary" onClick={addRoutine}>+ {t('New')}</button>
<Button size="sm" variant="tinted" icon="plus" onClick={addRoutine}>{t('New')}</Button>
</div>
{S.routines.length ? <div className="list">{S.routines.map(r => <div key={r.id} className="item" onClick={() => nav('/plan/r/' + r.id)}>
<div style={{ fontSize: '1.5rem', 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>
<span className="chev">›</span></div>)}</div> : <>
<div className="empty"><div className="ico">📋</div>{t('No routines yet.')}<br />{t('Create one or load the starter plan.')}</div>
<button className="btn" onClick={loadStarterPlan}>{t('Load starter plan (Push / Pull / Legs)')}</button>
<Icon name="chevronRight" className="chev" /></div>)}</div> : <>
<div className="empty"><div className="ico"><Icon name="clipboard" /></div>{t('No routines yet.')}<br />{t('Create one or load the starter plan.')}</div>
<Button icon="sparkles" onClick={loadStarterPlan}>{t('Load starter plan (Push / Pull / Legs)')}</Button>
</>}
</div></div>
</>
+17 -14
View File
@@ -6,7 +6,10 @@ import { fmtNum, uid } from '../lib/format.js'
import { t } from '../lib/i18n.js'
import { supersetUnits, cleanupSg } from '../lib/history.js'
import { Thumb } from '../components/Media.jsx'
import { emojiPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'
import { glyphPicker, exercisePicker, exConfigSheet, confirmSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
import { glyphOf } from '../lib/glyphs.js'
import { Button } from '../components/ui.jsx'
export default function RoutineEdit() {
const nav = useNavigate()
@@ -33,39 +36,39 @@ export default function RoutineEdit() {
return <div className="narrow">
<div className="hdr">
<button className="iconbtn" onClick={() => nav('/plan')}>‹</button>
<button className="iconbtn" onClick={() => nav('/plan')} aria-label={t('Plan')}><Icon name="chevronLeft" /></button>
<div style={{ flex: 1, margin: '0 12px' }}>
<input className="input" defaultValue={r.name} style={{ fontWeight: 800, fontSize: '1.1rem' }}
<input className="input" defaultValue={r.name} style={{ fontWeight: 600, fontSize: 20, letterSpacing: '-.021em' }}
onChange={e => update(s => { s.routines.find(x => x.id === id).name = e.target.value.trim() || t('Routine') })} />
</div>
<button className="iconbtn" onClick={() => emojiPicker(r.emoji, emo => update(s => { s.routines.find(x => x.id === id).emoji = emo }))}>{r.emoji || '💪'}</button>
<button className="iconbtn" aria-label={t('Pick an icon')} onClick={() => glyphPicker(r.emoji, g => update(s => { s.routines.find(x => x.id === id).emoji = g }))}><Icon name={glyphOf(r.emoji)} /></button>
</div>
{r.ex.length ? <div className="list">{r.ex.map((e, i) => {
const ex = EXIDX[e.id]; if (!ex) return null
const linkedPrev = i > 0 && e.sg && r.ex[i - 1].sg === e.sg
return <div key={i}>
{unitFirst.has(i) && <div className="ss-label">🔗 {t('Superset')}</div>}
{unitFirst.has(i) && <div className="ss-label"><Icon name="link" />{t('Superset')}</div>}
<div className={'item' + (inSS.has(i) ? ' in-ss' : '')} onClick={() => {
exConfigSheet(ex, e, cfg => edit(x => { Object.assign(x[i], cfg) }), () => edit(x => { x.splice(i, 1); cleanupSg(x) }))
}}>
<Thumb ex={ex} />
<div className="grow"><div className="tt">{ex.n}</div><div className="ss">{isCardio(e.id) ? `${e.sets} × ${e.min || 20} min @ ${fmtNum(e.speed || 8)} km/h` : `${e.sets} × ${e.reps}${e.weight ? ' · ' + fmtNum(e.weight) + ' ' + S.unit : ''}`}</div></div>
<div className="grow"><div className="tt capitalize">{ex.n}</div><div className="ss">{isCardio(e.id) ? `${e.sets} × ${e.min || 20} min @ ${fmtNum(e.speed || 8)} km/h` : `${e.sets} × ${e.reps}${e.weight ? ' · ' + fmtNum(e.weight) + ' ' + S.unit : ''}`}</div></div>
<div style={{ display: 'flex', flexDirection: 'column', gap: 2, flex: 'none', alignItems: 'center' }}>
{i > 0 && <button className={'iconbtn' + (linkedPrev ? ' on-ss' : '')} title={t('Superset with exercise above')} style={{ width: 34, height: 28, fontSize: '.85rem' }} onClick={ev => { ev.stopPropagation(); toggleLink(i) }}>🔗</button>}
{i > 0 && <button className={'iconbtn' + (linkedPrev ? ' on-ss' : '')} title={t('Superset with exercise above')} style={{ width: 32, height: 28, borderRadius: 8, fontSize: 15 }} onClick={ev => { ev.stopPropagation(); toggleLink(i) }}><Icon name="link" /></button>}
<div style={{ display: 'flex', gap: 2 }}>
<button className="iconbtn" style={{ width: 28, height: 26, fontSize: '.7rem' }} onClick={ev => { ev.stopPropagation(); move(i, -1) }}>▲</button>
<button className="iconbtn" style={{ width: 28, height: 26, fontSize: '.7rem' }} onClick={ev => { ev.stopPropagation(); move(i, 1) }}>▼</button>
<button className="iconbtn" aria-label="Move up" style={{ width: 28, height: 24, borderRadius: 7, fontSize: 12 }} onClick={ev => { ev.stopPropagation(); move(i, -1) }}><Icon name="chevronUp" /></button>
<button className="iconbtn" aria-label="Move down" style={{ width: 28, height: 24, borderRadius: 7, fontSize: 12 }} onClick={ev => { ev.stopPropagation(); move(i, 1) }}><Icon name="chevronDown" /></button>
</div>
</div>
</div>
</div>
})}</div> : <div className="empty"><div className="ico">🏋️</div>{t('No exercises yet — add your first one.')}</div>}
})}</div> : <div className="empty"><div className="ico"><Icon name="dumbbell" /></div>{t('No exercises yet — add your first one.')}</div>}
<div className="small dim" style={{ margin: '10px 2px' }}>{t('Tip: tap 🔗 on an exercise to superset it with the one above — you’ll do them back-to-back.')}</div>
<button className="btn primary" onClick={() => exercisePicker(ex => exConfigSheet(ex, null, cfg => edit(x => { x.push({ id: ex.id, ...cfg }) })))}>+ {t('Add exercise')}</button>
<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 }) })))} icon="plus">{t('Add exercise')}</Button>
<div style={{ height: 10 }} />
<button className="btn danger" onClick={() => confirmSheet({
<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: () => {
update(s => {
@@ -75,6 +78,6 @@ export default function RoutineEdit() {
})
nav('/plan')
}
})}>{t('Delete routine')}</button>
})}>{t('Delete routine')}</Button>
</div>
}
+115 -93
View File
@@ -7,6 +7,8 @@ import { webauthnOK, passkeyLogin, passkeyRegister, IS_ANDROID } from '../lib/ap
import { pushSupported, enablePush, disablePush, sendTestPush } from '../lib/push.js'
import { t, LANGS, INSTR_LANGS } from '../lib/i18n.js'
import { loadStarterPlan, confirmSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
import { Section, Row, SelectRow, Switch, Segmented, Button, TextField } from '../components/ui.jsx'
export default function Settings() {
const nav = useNavigate()
@@ -19,7 +21,7 @@ export default function Settings() {
const doExport = () => {
const blob = new Blob([JSON.stringify(S, null, 2)], { type: 'application/json' })
const a = document.createElement('a'); a.href = URL.createObjectURL(blob); a.download = 'opengym-backup-' + todayISO() + '.json'; a.click(); URL.revokeObjectURL(a.href)
toast(t('Backup exported ✓'))
toast(t('Backup exported'))
}
const doImport = ev => {
const f = ev.target.files[0]; if (!f) return
@@ -28,86 +30,100 @@ export default function Settings() {
try {
const data = JSON.parse(rd.result)
if (!data.workouts || !data.routines) throw new Error('not an openGym backup')
confirmSheet({ title: t('Import backup?'), message: t('This replaces all current data with the backup file.'), confirmText: t('Import'), danger: true, onConfirm: () => { replaceState(Object.assign(JSON.parse(JSON.stringify(DEF)), data), true); toast(t('Backup imported ✓')) } })
confirmSheet({ title: t('Import backup?'), message: t('This replaces all current data with the backup file.'), confirmText: t('Import'), danger: true, onConfirm: () => { replaceState(Object.assign(JSON.parse(JSON.stringify(DEF)), data), true); toast(t('Backup imported')) } })
} catch (e) { toast(t('Import failed: {0}', e.message)) }
}
rd.readAsText(f)
}
const signInHere = async () => {
try { const u = await passkeyLogin(); setUser(u); await pullState(); toast(t('Welcome back, {0} 💪', u.name)) }
try { const u = await passkeyLogin(); setUser(u); await pullState(); toast(t('Welcome back, {0}', u.name)) }
catch (e) { if (e.name !== 'NotAllowedError' && e.name !== 'AbortError') toast(e.message || t('Sign-in failed')) }
}
const registerHere = () => useUI.getState().openSheet(close => <RegisterInline close={close} setUser={setUser} pushState={pushState} pullState={pullState} toast={toast} />)
return <div className="narrow">
<div className="hdr"><button className="iconbtn" onClick={() => nav('/home')}>‹</button><div style={{ flex: 1, marginLeft: 12 }}><h1>{t('Settings')}</h1></div></div>
<div className="hdr">
<button className="iconbtn" onClick={() => nav('/home')} aria-label={t('Home')}><Icon name="chevronLeft" /></button>
<div style={{ flex: 1, marginLeft: 10 }}><h1>{t('Settings')}</h1></div>
</div>
<div className="card">
<h2>{t('Account')}</h2>
{/* ---------- account ---------- */}
<Section title={t('Account')}>
{user ? <>
<div className="row between">
<div><b>{user.name}</b><div className="small muted">{t('Signed in with passkey — data syncs to this profile.')}</div></div>
<button className="btn sm danger" onClick={() => confirmSheet({ title: t('Sign out?'), message: t('Your data is synced to your profile first, then cleared from this device.'), confirmText: t('Sign out'), danger: true, onConfirm: () => { signOut(); nav('/home') } })}>{t('Sign out')}</button>
</div>
{user.admin && <><div style={{ height: 10 }} /><button className="btn sm" onClick={() => nav('/admin')}>🛠️ {t('Admin dashboard')}</button></>}
</> : <>
<div className="small muted" style={{ marginBottom: 10 }}>{t('Guest mode — data lives only in this browser. Create a passkey profile to keep it safe and separate per person.')}</div>
{webauthnOK() ? <>
<button className="btn primary" onClick={registerHere}>✨ {t('Create passkey profile')}</button>
<div style={{ height: 8 }} /><button className="btn" onClick={signInHere}>👤 {t('Sign in with passkey')}</button>
</> : <div className="small dim">{t('Passkeys not supported in this browser.')}</div>}
</>}
</div>
<Row icon="personCircle" iconTint="var(--grey)" title={user.name} subtitle={t('Signed in with passkey — data syncs to this profile.')} />
{user.admin && <Row icon="wrench" iconTint="var(--indigo)" title={t('Admin dashboard')} accessory="chevron" onClick={() => nav('/admin')} />}
<Row icon="signOut" iconTint="var(--red)" title={t('Sign out')} danger onClick={() => confirmSheet({ title: t('Sign out?'), message: t('Your data is synced to your profile first, then cleared from this device.'), confirmText: t('Sign out'), danger: true, onConfirm: () => { signOut(); nav('/home') } })} />
</> : webauthnOK() ? <>
<Row icon="sparkles" iconTint="var(--acc)" title={t('Create passkey profile')} subtitle={t('Keeps your data safe and separate per person.')} accessory="chevron" onClick={registerHere} />
<Row icon="person" iconTint="var(--blue)" title={t('Sign in with passkey')} accessory="chevron" onClick={signInHere} />
</> : (
<Row icon="lock" iconTint="var(--grey)" title={t('Passkeys not supported in this browser.')} />
)}
</Section>
{!user && <p className="sect-f" style={{ marginTop: -18, marginBottom: 22 }}>{t('Guest mode — data lives only in this browser.')}</p>}
<div className="card">
<h2>{t('Appearance')} <span className="dim" style={{ textTransform: 'none', letterSpacing: 0 }}>· {t('synced with your profile')}</span></h2>
<div className="row between" style={{ padding: '8px 0' }}>
<span>{t('Language')}</span>
<select className="input" style={{ width: 150 }} value={S.lang || 'en'} onChange={e => update(s => { s.lang = e.target.value })}>
{Object.entries(LANGS).map(([k, name]) => <option key={k} value={k}>{name}</option>)}
</select>
</div>
{!INSTR_LANGS.includes(S.lang || 'en') && <div className="small dim" style={{ marginBottom: 6 }}>{t("Exercise instructions aren't available in this language yet — they stay in English.")}</div>}
<div className="row between" style={{ padding: '8px 0' }}>
<span>{t('Theme')}</span>
<div className="chips">
<button className={'chip' + (S.theme !== 'light' ? ' on' : '')} onClick={() => update(s => { s.theme = 'dark' })}>🌙 {t('Dark')}</button>
<button className={'chip' + (S.theme === 'light' ? ' on' : '')} onClick={() => update(s => { s.theme = 'light' })}>☀️ {t('Light')}</button>
{/* ---------- appearance ---------- */}
<Section title={t('Appearance')} footer={t('synced with your profile')}>
<SelectRow
icon="globe" iconTint="var(--blue)" title={t('Language')}
value={S.lang || 'en'} onChange={v => update(s => { s.lang = v })}
options={Object.entries(LANGS).map(([k, name]) => ({
value: k, label: name,
subtitle: INSTR_LANGS.includes(k) ? null : t("Exercise instructions aren't available in this language yet — they stay in English."),
}))}
/>
<Row icon="moon" iconTint="var(--indigo)" title={t('Theme')}>
<Segmented
className="seg-inline"
options={[{ value: 'dark', icon: 'moon', label: t('Dark') }, { value: 'light', icon: 'sun', label: t('Light') }]}
value={S.theme === 'light' ? 'light' : 'dark'}
onChange={v => update(s => { s.theme = v })}
/>
</Row>
<div className="lrow" style={{ flexDirection: 'column', alignItems: 'stretch', gap: 12, paddingTop: 13, paddingBottom: 14 }}>
<span className="lrow-t">{t('Accent color')}</span>
<div className="swatches">
{Object.entries(ACCENTS).map(([k, c]) => (
<button key={k} className={'swatch' + ((S.accent || 'lime') === k ? ' on' : '')}
style={{ background: c }} onClick={() => update(s => { s.accent = k })} aria-label={k} />
))}
</div>
</div>
<div style={{ padding: '8px 0' }}>
<div style={{ marginBottom: 10 }}>{t('Accent color')}</div>
<div className="swatches">{Object.entries(ACCENTS).map(([k, c]) => <button key={k} className={'swatch' + ((S.accent || 'lime') === k ? ' on' : '')} style={{ background: c }} onClick={() => update(s => { s.accent = k })} />)}</div>
</div>
</div>
</Section>
<div className="card">
<h2>{t('Units & timer')}</h2>
<div className="row between" style={{ padding: '8px 0' }}><span>{t('Weight unit')}</span>
<div className="chips"><button className={'chip' + (S.unit === 'kg' ? ' on' : '')} onClick={() => update(s => { s.unit = 'kg' })}>kg</button>
<button className={'chip' + (S.unit === 'lb' ? ' on' : '')} onClick={() => update(s => { s.unit = 'lb' })}>lb</button></div></div>
<div className="row between" style={{ padding: '8px 0' }}><span>{t('Rest timer')}</span>
<select className="input" style={{ width: 120 }} value={S.restSec} onChange={e => update(s => { s.restSec = +e.target.value })}>
{[60, 90, 120, 150, 180].map(v => <option key={v} value={v}>{v}s</option>)}</select></div>
<div className="row between" style={{ padding: '8px 0' }}><span>{t('Sounds')}</span>
<button className={'chip' + (S.sound ? ' on' : '')} onClick={() => update(s => { s.sound = !s.sound })}>{S.sound ? t('On 🔔') : t('Off 🔕')}</button></div>
<div className="small dim" style={{ marginTop: 6 }}>{t('Note: switching units only changes the label — logged numbers are not converted.')}</div>
</div>
{/* ---------- units & timer ---------- */}
<Section title={t('Units & timer')} footer={t('Note: switching units only changes the label — logged numbers are not converted.')}>
<Row icon="scale" iconTint="var(--teal)" title={t('Weight unit')}>
<Segmented className="seg-inline"
options={[{ value: 'kg', label: 'kg' }, { value: 'lb', label: 'lb' }]}
value={S.unit} onChange={v => update(s => { s.unit = v })} />
</Row>
<SelectRow icon="timer" iconTint="var(--orange)" title={t('Rest timer')}
value={S.restSec} onChange={v => update(s => { s.restSec = v })}
options={[60, 90, 120, 150, 180].map(v => ({ value: v, label: v + 's' }))} />
<Row icon="bell" iconTint="var(--pink)" title={t('Sounds')}>
<Switch checked={!!S.sound} onChange={v => update(s => { s.sound = v })} />
</Row>
</Section>
{user && <NotificationsCard S={S} update={update} toast={toast} />}
<div className="card">
<h2>{t('Data')}</h2>
<button className="btn" onClick={doExport}>⬇️ {t('Export backup (JSON)')}</button>
<div style={{ height: 8 }} /><button className="btn" onClick={() => fileRef.current.click()}>⬆️ {t('Import backup')}</button>
<input ref={fileRef} type="file" accept=".json,application/json" style={{ display: 'none' }} onChange={doImport} />
<div style={{ height: 8 }} /><button className="btn" onClick={loadStarterPlan}>{t('Load starter plan (PPL)')}</button>
<div style={{ height: 8 }} /><button className="btn danger" onClick={() => confirmSheet({ title: t('Reset everything?'), message: t('Deletes your plan, workouts and body weight on this device. This cannot be undone.'), confirmText: t('Delete everything'), danger: true, onConfirm: () => { replaceState(JSON.parse(JSON.stringify(DEF)), true); nav('/home'); toast(t('All data reset')) } })}>{t('Reset everything')}</button>
</div>
{/* ---------- data ---------- */}
<Section title={t('Data')}>
<Row icon="download" iconTint="var(--blue)" title={t('Export backup (JSON)')} accessory="chevron" onClick={doExport} />
<Row icon="upload" iconTint="var(--blue)" title={t('Import backup')} accessory="chevron" onClick={() => fileRef.current.click()} />
<Row icon="sparkles" iconTint="var(--acc)" title={t('Load starter plan (PPL)')} accessory="chevron" onClick={loadStarterPlan} />
<Row icon="trash" iconTint="var(--red)" title={t('Reset everything')} danger onClick={() => confirmSheet({ title: t('Reset everything?'), message: t('Deletes your plan, workouts and body weight on this device. This cannot be undone.'), confirmText: t('Delete everything'), danger: true, onConfirm: () => { replaceState(JSON.parse(JSON.stringify(DEF)), true); nav('/home'); toast(t('All data reset')) } })} />
</Section>
<input ref={fileRef} type="file" accept=".json,application/json" style={{ display: 'none' }} onChange={doImport} />
<div className="card"><h2>{t('Tip')}</h2>
<div className="small muted" style={{ lineHeight: 1.5 }}>📱 {IS_ANDROID ? t('In Chrome: ⋮ menu → Add to Home screen') : t('In Safari: Share → Add to Home Screen')} {t('to install openGym as a full-screen app.')} {user ? t('Your data syncs with your profile — sign in anywhere to see it.') : t('Guest data stays on this device — export a backup now and then!')}</div></div>
<div className="dim small" style={{ textAlign: 'center', marginTop: 8, lineHeight: 1.6 }}>
<Section title={t('Tip')}>
<Row icon="lightbulb" iconTint="var(--yellow)"
title={IS_ANDROID ? t('In Chrome: ⋮ menu → Add to Home screen') : t('In Safari: Share → Add to Home Screen')}
subtitle={t('to install openGym as a full-screen app.') + ' ' + (user ? t('Your data syncs with your profile — sign in anywhere to see it.') : t('Guest data stays on this device — export a backup now and then!'))} />
</Section>
<div className="dim small" style={{ textAlign: 'center', marginTop: 4, lineHeight: 1.6 }}>
openGym · {t('free & open source (AGPL v3)')}<br />
<a href="https://github.com/DuarteSantos8/openGym" target="_blank" rel="noopener">source code</a> · exercise data: hasaneyldrm/exercises-dataset (CC)
</div>
@@ -124,11 +140,11 @@ function NotificationsCard({ S, update, toast }) {
navigator.serviceWorker.ready.then(reg => reg.pushManager.getSubscription()).then(sub => setOn(!!sub)).catch(() => {})
}, [supported])
const toggle = async () => {
const toggle = async v => {
setBusy(true)
try {
if (on) { await disablePush(); setOn(false); toast(t('Notifications off')) }
else { await enablePush(); setOn(true); toast(t('Notifications on 🔔')) }
if (!v) { await disablePush(); setOn(false); toast(t('Notifications off')) }
else { await enablePush(); setOn(true); toast(t('Notifications on')) }
} catch (e) { toast(e.message || t('Could not change notification settings')) }
setBusy(false)
}
@@ -137,31 +153,37 @@ function NotificationsCard({ S, update, toast }) {
catch (e) { toast(e.message || t('Test failed')) }
}
return <div className="card">
<h2>{t('Notifications')}</h2>
{!supported ? <div className="small dim">{t('Not supported in this browser.')}</div> : <>
<div className="row between" style={{ padding: '8px 0' }}>
<div><span>{t('Push notifications')}</span><div className="small muted">{t('Rest-timer alerts, even if openGym is closed.')}</div></div>
<button className={'chip' + (on ? ' on' : '')} disabled={busy} onClick={toggle}>{on ? t('On 🔔') : t('Off 🔕')}</button>
</div>
{on && <>
<div className="row between" style={{ padding: '8px 0' }}>
<span>{t('Workout day reminder')}</span>
<button className={'chip' + (S.reminder?.on ? ' on' : '')} onClick={() => update(s => { s.reminder = { ...(s.reminder || DEF.reminder), on: !s.reminder?.on, tz: localTZ() } })}>{S.reminder?.on ? t('On') : t('Off')}</button>
</div>
{S.reminder?.on && <div className="row between" style={{ padding: '8px 0' }}>
<span>{t('Reminder time')}</span>
<input type="time" className="input" style={{ width: 120 }} value={S.reminder?.time || DEF.reminder.time}
if (!supported) return (
<Section title={t('Notifications')}>
<Row icon="bellSlash" iconTint="var(--grey)" title={t('Not supported in this browser.')} />
</Section>
)
return <>
<Section
title={t('Notifications')}
footer={on && S.reminder?.on
? t("Only sent on days you have a routine planned and haven't logged a workout yet.") +
(S.reminder?.tz ? ' ' + t('Timezone: {0} (auto-detected, updates if you travel).', S.reminder.tz) : '')
: null}
>
<Row icon="bell" iconTint="var(--red)" title={t('Push notifications')} subtitle={t('Rest-timer alerts, even if openGym is closed.')}>
<Switch checked={on} disabled={busy} onChange={toggle} />
</Row>
{on && (
<Row icon="calendar" iconTint="var(--orange)" title={t('Workout day reminder')}>
<Switch checked={!!S.reminder?.on} onChange={() => update(s => { s.reminder = { ...(s.reminder || DEF.reminder), on: !s.reminder?.on, tz: localTZ() } })} />
</Row>
)}
{on && S.reminder?.on && (
<Row icon="clock" iconTint="var(--purple)" title={t('Reminder time')}>
<input type="time" className="timef" value={S.reminder?.time || DEF.reminder.time}
onChange={e => update(s => { s.reminder = { ...(s.reminder || DEF.reminder), time: e.target.value, tz: localTZ() } })} />
</div>}
<div className="small dim" style={{ margin: '6px 0' }}>
{t("Only sent on days you have a routine planned and haven't logged a workout yet.")}
{S.reminder?.on && S.reminder?.tz && <> {t('Timezone: {0} (auto-detected, updates if you travel).', S.reminder.tz)}</>}
</div>
<button className="btn sm" onClick={test}>{t('Send test notification')}</button>
</>}
</>}
</div>
</Row>
)}
</Section>
{on && <div style={{ marginTop: -12, marginBottom: 22 }}><Button size="sm" icon="bell" onClick={test}>{t('Send test notification')}</Button></div>}
</>
}
function RegisterInline({ close, setUser, pushState, pullState, toast }) {
@@ -171,14 +193,14 @@ function RegisterInline({ close, setUser, pushState, pullState, toast }) {
if (!n) { toast(t('Enter a name')); return }
try {
const u = await passkeyRegister(n); setUser(u); close()
if (hasData(useStore.getState().S)) { await pushState(); toast(t('Profile created — data moved into it ✓')) }
else { await pullState(); toast(t('Welcome, {0} 💪', u.name)) }
if (hasData(useStore.getState().S)) { await pushState(); toast(t('Profile created — data moved into it')) }
else { await pullState(); toast(t('Welcome, {0}', u.name)) }
} catch (e) { if (e.name !== 'NotAllowedError' && e.name !== 'AbortError') toast(e.message || t('Registration failed')) }
}
return <>
<h3>{t('Create your profile ✨')}</h3>
<h3>{t('Create your profile')}</h3>
<div className="muted small" style={{ marginBottom: 14 }}>{t('Pick a name, then confirm with your device.')}</div>
<input ref={nameRef} className="input" placeholder={t('Your name')} maxLength={40} />
<div style={{ height: 12 }} /><button className="btn primary" onClick={go}>{t('Create passkey')}</button>
<TextField ref={nameRef} placeholder={t('Your name')} maxLength={40} />
<div style={{ height: 12 }} /><Button variant="primary" onClick={go}>{t('Create passkey')}</Button>
</>
}
+18 -16
View File
@@ -8,6 +8,8 @@ import { t } from '../lib/i18n.js'
import { bwSheet, goalSheet, calendarSheet, workoutDetailSheet, WorkoutRow, bwDeltaColor } from '../sheets.jsx'
import LineChart from '../components/LineChart.jsx'
import Heatmap from '../components/Heatmap.jsx'
import Icon from '../components/Icon.jsx'
import { Button, Segmented, SelectRow } from '../components/ui.jsx'
// Stats = the analytics hub: all charts, progress and history live here.
export default function Stats() {
@@ -39,13 +41,13 @@ export default function Stats() {
return <>
<div className="hdr"><div><h1>{t('Stats')}</h1><div className="sub">{t('Progress & history')}</div></div>
<button className="iconbtn" onClick={() => nav('/history')}>🗂</button></div>
<button className="iconbtn" onClick={() => nav('/history')} aria-label={t('History')}><Icon name="history" /></button></div>
<div className="tiles">
<div className="tile"><div className="l">{t('Workouts')}</div><div className="v">{S.workouts.length}</div></div>
<div className="tile"><div className="l">{t('This month')}</div><div className="v">{monthW}</div></div>
<div className="tile"><div className="l">{t('Week streak')}</div><div className="v">{streakWeeks(S)} 🔥</div></div>
<div className="tile"><div className="l">{t('Weight 30d')}</div><div className="v" style={{ fontSize: '1.15rem', color: bwDelta30 === null ? 'inherit' : bwDeltaColor(bwDelta30, (lastBW(S) || {}).w || 0) }}>{bwDelta30 === null ? '—' : (bwDelta30 > 0 ? '+' : '') + fmtNum(bwDelta30) + ' ' + S.unit}</div></div>
<div className="tile"><div className="l"><Icon name="dumbbell" />{t('Workouts')}</div><div className="v">{S.workouts.length}</div></div>
<div className="tile"><div className="l"><Icon name="calendar" />{t('This month')}</div><div className="v">{monthW}</div></div>
<div className="tile"><div className="l"><Icon name="flame" />{t('Week streak')}</div><div className="v">{streakWeeks(S)}</div></div>
<div className="tile"><div className="l"><Icon name="scale" />{t('Weight 30d')}</div><div className="v" style={{ fontSize: 22, color: bwDelta30 === null ? 'inherit' : bwDeltaColor(bwDelta30, (lastBW(S) || {}).w || 0) }}>{bwDelta30 === null ? '—' : (bwDelta30 > 0 ? '+' : '') + fmtNum(bwDelta30) + ' ' + S.unit}</div></div>
</div>
<div className="card">
@@ -58,34 +60,34 @@ export default function Stats() {
<div className="row between" style={{ marginBottom: 8 }}>
<h2 style={{ margin: 0 }}>{t('Body weight')}</h2>
<div className="row" style={{ gap: 8 }}>
<button className="btn sm" style={S.targetW ? { color: 'var(--gold)' } : undefined} onClick={goalSheet}>🎯 {S.targetW ? fmtNum(S.targetW) : t('Goal')}</button>
<button className="btn sm" onClick={() => bwSheet()}>+ {t('Log')}</button>
<Button size="sm" icon="target" style={S.targetW ? { color: 'var(--yellow)' } : undefined} onClick={goalSheet}>{S.targetW ? fmtNum(S.targetW) : t('Goal')}</Button>
<Button size="sm" icon="plus" onClick={() => bwSheet()}>{t('Log')}</Button>
</div>
</div>
<div className="chips" style={{ marginBottom: 8 }}>
{[[30, '1M'], [90, '3M'], [365, '1Y'], [0, t('All')]].map(([d, l]) => <button key={l} className={'chip' + (range === d ? ' on' : '')} onClick={() => setRange(d)}>{l}</button>)}
</div>
<Segmented className="seg-range" value={range} onChange={setRange}
options={[{ value: 30, label: '1M' }, { value: 90, label: '3M' }, { value: 365, label: '1Y' }, { value: 0, label: t('All') }]} />
<div className="chart"><LineChart points={bwPts} h={160} unit={S.unit} goal={S.targetW} /></div>
</div>
<div className="card">
<h2>{t('Exercise progress')}</h2>
{exHist.length ? <>
<select className="input capitalize" style={{ marginBottom: 10 }} value={curEx} onChange={e => setExId(e.target.value)}>
{exHist.map(id => <option key={id} value={id}>{EXIDX[id].n}{isCardio(id) ? ' 🏃' : ''}</option>)}
</select>
<div className="sect-b" style={{ marginBottom: 10 }}>
<SelectRow title={t('Exercise')} sheetTitle={t('Exercise progress')} value={curEx} onChange={setExId}
options={exHist.map(id => ({ value: id, label: EXIDX[id].n }))} />
</div>
<div className="chart"><LineChart points={exPts.map(p => ({ t: p.t, y: p.y, d: p.d }))} h={150} unit={exUnit} color="var(--blue)" /></div>
<div style={{ marginTop: 8 }}>{exList.map((p, i) => <div key={i} className="row between small" style={{ padding: '6px 0', borderBottom: '1px solid var(--bg2)' }}>
<div style={{ marginTop: 8 }}>{exList.map((p, i) => <div key={i} className="row between small" style={{ padding: '6px 0', borderBottom: 'var(--hair) solid var(--sep)' }}>
<span className="muted">{fmtDate(p.d, true)}</span><span>{p.sets.map(s => setLabel(curEx, s)).join(' ')}</span></div>)}</div>
<div className="small dim" style={{ marginTop: 8 }}>{curCardio ? t('Top speed per workout') : t('Best set weight per workout')} · {t('Best:')} <b className="accent">{fmtNum(exBest)} {exUnit}</b></div>
</> : <div className="muted small">{t('Finish your first workout to see progress curves here. 📈')}</div>}
</> : <div className="muted small">{t('Finish your first workout to see progress curves here.')}</div>}
</div>
</div>
{S.workouts.length > 0 && <>
<div className="row between" style={{ marginBottom: 10 }}>
<h4 className="sec" style={{ margin: 0 }}>{t('Recent workouts')}</h4>
<button className="btn sm ghost accent" onClick={() => nav('/history')}>{t('All')} {S.workouts.length} ›</button>
<Button size="sm" variant="ghost" trailingIcon="chevronRight" onClick={() => nav('/history')}>{t('All')} {S.workouts.length}</Button>
</div>
<div className="list">{[...S.workouts].reverse().slice(0, 6).map(w => <WorkoutRow key={w.id} w={w} onClick={() => workoutDetailSheet(w)} />)}</div>
</>}
+33 -29
View File
@@ -9,8 +9,10 @@ import { beep, vibrate } from '../lib/sound.js'
import { t } from '../lib/i18n.js'
import { api } from '../lib/api.js'
import Media from '../components/Media.jsx'
import NumField from '../components/NumField.jsx'
import { startFlow, exercisePicker, exConfigSheet, exerciseDetailSheet, topWeightSheet, finishWorkout, workoutCompleteSheet, confirmSheet } from '../sheets.jsx'
import Icon from '../components/Icon.jsx'
import { Button, Check, NumberField } from '../components/ui.jsx'
import { glyphOf } from '../lib/glyphs.js'
/* ---------- start chooser (no active workout) ---------- */
function StartChooser() {
@@ -25,18 +27,18 @@ function StartChooser() {
<h2 className="accent">{t("Today's plan")}{todayOvr ? ' · ' + t('rescheduled') : ''}</h2>
<div className="row between" style={{ marginBottom: 12 }}>
<div><div className="big">{todayR.name}</div><div className="muted small">{t('{0} exercises', todayR.ex.length)}</div></div>
<div style={{ fontSize: '2rem' }}>{todayR.emoji || '💪'}</div>
<span className="lrow-i" style={{ width: 38, height: 38, borderRadius: 9, fontSize: 22 }}><Icon name={glyphOf(todayR.emoji)} /></span>
</div>
<button className="btn primary" onClick={() => startFlow(todayR.id)}>{t('Start {0} ▶', todayR.name)}</button>
<Button variant="primary" icon="play" onClick={() => startFlow(todayR.id)}>{t('Start {0}', todayR.name)}</Button>
</div>}
{others.length > 0 && <><h4 className="sec">{t('Other routines')}</h4>
<div className="list">{others.map(r => <div key={r.id} className="item" onClick={() => startFlow(r.id)}>
<div style={{ fontSize: '1.5rem', 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>
<span className="tag acc">{t('Start ▶')}</span></div>)}</div></>}
<span className="tag acc">{t('Start')}</span></div>)}</div></>}
<div style={{ height: 14 }} />
<button className="btn" onClick={() => startFlow(null)}>🎯 {t('Freestyle workout (pick as you go)')}</button>
{!S.routines.length && <><div style={{ height: 10 }} /><button className="btn primary" onClick={() => nav('/plan')}>{t('Build a plan first')}</button></>}
<Button icon="shuffle" onClick={() => startFlow(null)}>{t('Freestyle workout (pick as you go)')}</Button>
{!S.routines.length && <><div style={{ height: 10 }} /><Button variant="primary" onClick={() => nav('/plan')}>{t('Build a plan first')}</Button></>}
</div>
}
@@ -62,38 +64,40 @@ function ExerciseBlock({ entryIdx, compact, onToggle, onField, onBumpAll, onAddS
? Math.max(...last.sets.map(s => s.w)) + 2.5 : null
const col1 = cardio ? { f: 'min', step: 1, dec: false, hd: t('Duration (min)') } : { f: 'w', step: 2.5, dec: true, hd: t('Weight ({0})', S.unit) }
const col2 = cardio ? { f: 'speed', step: 0.5, dec: true, hd: t('Speed (km/h)') } : { f: 'r', step: 1, dec: false, hd: t('Reps') }
// Uses the shared stepper markup so a set row picks up the same control styling
// as every other +/- field in the app.
const cell = (s, i, col, cls) => (
<div className={'step ' + cls}>
<button onClick={() => onField(i, col.f, Math.max(0, Math.round(((s[col.f] || 0) - col.step) * 100) / 100))}>−</button>
<NumField decimal={col.dec} value={s[col.f] ?? ''} onChange={v => onField(i, col.f, v)} />
<button onClick={() => onField(i, col.f, Math.max(0, Math.round(((s[col.f] || 0) + col.step) * 100) / 100))}>+</button>
<div className={'stp ' + cls}>
<button aria-label="Decrease" onClick={() => onField(i, col.f, Math.max(0, Math.round(((s[col.f] || 0) - col.step) * 100) / 100))}><Icon name="minus" /></button>
<span className="val"><NumberField decimal={col.dec} value={s[col.f] ?? ''} onChange={v => onField(i, col.f, v)} /></span>
<button aria-label="Increase" onClick={() => onField(i, col.f, Math.max(0, Math.round(((s[col.f] || 0) + col.step) * 100) / 100))}><Icon name="plus" /></button>
</div>
)
return <>
<Media ex={ex} key={entry.id} compact={compact} minimizable />
<div className="row between" style={{ marginBottom: 6 }}>
<div style={{ fontSize: compact ? '1.05rem' : '1.2rem', fontWeight: 800, textTransform: 'capitalize', lineHeight: 1.2 }}>{ex.n}</div>
<button className="iconbtn" onClick={() => exerciseDetailSheet(ex)}>ℹ️</button>
<div style={{ fontSize: compact ? 17 : 20, fontWeight: 600, letterSpacing: '-.02em', textTransform: 'capitalize', lineHeight: 1.2 }}>{ex.n}</div>
<button className="iconbtn" aria-label={t('Details')} onClick={() => exerciseDetailSheet(ex)}><Icon name="info" /></button>
</div>
<div className="row" style={{ gap: 6, flexWrap: 'wrap', marginBottom: 8 }}>
{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>
{best > 0 && <span className="tag">{t('Best:')} {fmtNum(best)} {S.unit}</span>}
</div>
{last && <div className="small dim" style={{ marginBottom: 4 }}>{t('Last time')} ({fmtDate(last.d)}): {last.sets.map(s => setLabel(entry.id, s)).join(', ')}</div>}
{hint && <button className="tag acc" style={{ border: 'none' }} onClick={() => { onBumpAll('w', hint); useUI.getState().toast(t('Weights bumped to {0} 💪', fmtNum(hint) + ' ' + S.unit)) }}>💡 {t('Last time you hit all reps — try {0}', fmtNum(hint) + ' ' + S.unit)}</button>}
{hint && <button className="tag acc" style={{ border: 'none', textAlign: 'left' }} onClick={() => { onBumpAll('w', hint); useUI.getState().toast(t('Weights bumped to {0}', fmtNum(hint) + ' ' + S.unit)) }}><Icon name="lightbulb" />{t('Last time you hit all reps — try {0}', fmtNum(hint) + ' ' + S.unit)}</button>}
<div className="card" style={{ marginTop: 10, marginBottom: 0 }}>
<div className="sethead"><span className="n-sp" /><span className="w-sp">{col1.hd}</span><span className="r-sp">{col2.hd}</span><span className="ck-sp" /></div>
{entry.sets.map((s, i) => <div key={i} className={'setrow' + (s.done ? ' done' : '')}>
<div className="n">{i + 1}</div>
{cell(s, i, col1, 'w')}
{cell(s, i, col2, 'r')}
<button className={'ck' + (s.done ? ' on' : '')} onClick={() => onToggle(i)}><svg viewBox="0 0 24 24"><path d="m4.5 12.5 5 5 10-11" /></svg></button>
<Check checked={s.done} onChange={() => onToggle(i)} />
</div>)}
<div style={{ height: 8 }} />
<div className="row">
<button className="btn sm" disabled={entry.sets.length <= 1} onClick={onRemoveSet}>− {t('Remove set')}</button>
<button className="btn sm" onClick={onAddSet}>+ {t('Add set')}</button>
<Button size="sm" icon="minus" disabled={entry.sets.length <= 1} onClick={onRemoveSet}>{t('Remove set')}</Button>
<Button size="sm" icon="plus" onClick={onAddSet}>{t('Add set')}</Button>
</div>
</div>
</>
@@ -145,7 +149,7 @@ function ActiveWorkout() {
// cardio or already-confirmed: go straight to the prompt.
if (askTop) topWeightSheet(idx)
else if (workoutDone) workoutCompleteSheet()
else if (exJustDone && cardioEntry) useUI.getState().toast(t('Cardio logged 🏃'))
else if (exJustDone && cardioEntry) useUI.getState().toast(t('Cardio logged'))
}
// Live-presence heartbeat so the admin dashboard can show who's training now. Signed-in only —
@@ -177,9 +181,9 @@ function ActiveWorkout() {
return <div className="narrow">
<div className="hdr">
<button className="iconbtn" onClick={() => confirmSheet({ title: t('Discard workout?'), message: t('The sets you logged in this session will be lost.'), confirmText: t('Discard'), danger: true, onConfirm: () => { update(s => { s.active = null }); stopRest(); nav('/home') } })}>✕</button>
<div style={{ textAlign: 'center' }}><div style={{ fontWeight: 800 }}>{A.name}</div><div className="sub"><Elapsed start={A.start} /> · {t('{0} sets', done + '/' + total)}</div></div>
<button className="iconbtn" style={{ color: 'var(--acc)' }} onClick={finishWorkout}>✓</button>
<button className="iconbtn" aria-label={t('Discard')} onClick={() => confirmSheet({ title: t('Discard workout?'), message: t('The sets you logged in this session will be lost.'), confirmText: t('Discard'), danger: true, onConfirm: () => { update(s => { s.active = null }); stopRest(); nav('/home') } })}><Icon name="xmark" /></button>
<div style={{ textAlign: 'center' }}><div style={{ fontWeight: 600 }}>{A.name}</div><div className="sub"><Elapsed start={A.start} /> · {t('{0} sets', done + '/' + total)}</div></div>
<button className="iconbtn" style={{ color: 'var(--acc)' }} aria-label={t('Finish')} onClick={finishWorkout}><Icon name="check" /></button>
</div>
<div className="wprog"><i style={{ width: (total ? done / total * 100 : 0) + '%' }} /></div>
@@ -187,7 +191,7 @@ function ActiveWorkout() {
<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>
{isSuperset ? (
<div className="ss-card">
<div className="ss-hd">🔗 {t('Superset · do these back-to-back, rest after both')}</div>
<div className="ss-hd"><Icon name="link" />{t('Superset · do these back-to-back, rest after both')}</div>
{unit.map((idx, k) => <div key={idx} className="ss-ex">
{k > 0 && <div className="ss-amp">+</div>}
<ExerciseBlock entryIdx={idx} compact
@@ -197,24 +201,24 @@ function ActiveWorkout() {
) : (
<ExerciseBlock entryIdx={cur} onToggle={i => toggle(cur, i)} onField={(i, f, v) => setField(cur, i, f, v)} onBumpAll={(f, v) => bumpAll(cur, f, v)} onAddSet={() => addSet(cur)} onRemoveSet={() => removeSet(cur)} />
)}
</> : <div className="empty"><div className="ico">🎯</div>{t('Freestyle workout — add your first exercise.')}</div>}
</> : <div className="empty"><div className="ico"><Icon name="shuffle" /></div>{t('Freestyle workout — add your first exercise.')}</div>}
<div style={{ height: 12 }} />
<div className="row">
<button className="btn" disabled={unitIdx <= 0} onClick={() => update(s => { s.active.cur = units[unitIdx - 1][0] })}>‹ {t('Prev')}</button>
<button className="btn" 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={() => 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>
</div>
<div style={{ height: 10 }} />
<button className="btn" onClick={() => exercisePicker(ex => exConfigSheet(ex, null, cfg => update(s => {
<Button onClick={() => exercisePicker(ex => exConfigSheet(ex, null, cfg => update(s => {
s.active.entries.push({ id: ex.id, target: { ...cfg }, sets: buildSets(s, { ...cfg, id: ex.id }) })
s.active.cur = s.active.entries.length - 1
})))}>+ {t('Add exercise')}</button>
})))} icon="plus">{t('Add exercise')}</Button>
<div style={{ height: 10 }} />
{(() => {
const exDone = A.entries.filter(e => e.sets.length && e.sets.every(s => s.done)).length
const allDone = A.entries.length > 0 && exDone === A.entries.length
return <button className={allDone ? 'btn primary' : 'btn ghost dim'} onClick={finishWorkout}>
{allDone ? t('Finish workout 🏁') : t('Finish workout early · {0} exercises', exDone + '/' + A.entries.length)}
{allDone ? t('Finish workout') : t('Finish workout early · {0} exercises', exDone + '/' + A.entries.length)}
</button>
})()}
<div style={{ height: 40 }} />