Touch and scroll polish: chip rows own the horizontal axis, sheets lock an axis before following the finger and close on a flick, the slider drags relative to the knob, steppers repeat on hold, back-navigation restores the scroll position, a dropped row is tappable at once, the picker search stays above the keyboard, tappable rows work from the keyboard, bigger hit areas in the set row
This commit is contained in:
1 parent
e1fadadadb
commit
60df0cf0dd
19 files changed
+574
-88
No files matched your search
@@ -8,6 +8,7 @@ import { bwSheet, goalSheet, dayOverrideSheet, calendarSheet, startFlow, loadSta
|
||||
import LineChart from '../components/LineChart.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
import { Button } from '../components/ui.jsx'
|
||||
import { tappable } from '../lib/use-sheet-keyboard.js'
|
||||
import { glyphOf } from '../lib/glyphs.js'
|
||||
|
||||
// Home = what to do now + a quick glance. Deep charts & history live in Stats.
|
||||
@@ -35,7 +36,7 @@ export default function Home() {
|
||||
const iso = isoOf(d)
|
||||
const eff = effectiveRoutineId(S, iso), ovr = S.dayPlan[iso] !== undefined, done = doneDays.has(iso)
|
||||
const dot = done ? ' done' : ovr && eff ? ' ovr' : eff ? ' plan' : ''
|
||||
strip.push(<div key={i} className={'wday' + (iso === todayISO() ? ' today' : '')} onClick={() => dayOverrideSheet(iso)}>
|
||||
strip.push(<div key={i} className={'wday' + (iso === todayISO() ? ' today' : '')} {...tappable(() => dayOverrideSheet(iso))}>
|
||||
<div className="lbl">{t(DAYS[d.getDay()])}</div><div className="num">{d.getDate()}</div><div className={'dot' + dot} /></div>)
|
||||
}
|
||||
const sunday = new Date(monday); sunday.setDate(monday.getDate() + 6)
|
||||
@@ -66,7 +67,7 @@ export default function Home() {
|
||||
routine name behind a green Start tag and read as still outstanding (issue #4).
|
||||
An in-progress session still wins — that one is happening right now. Tapping the
|
||||
row keeps working, so a second session in one day is a tap away, just not urged. */}
|
||||
<div className="today-row" onClick={onToday}>
|
||||
<div className="today-row" {...tappable(onToday)}>
|
||||
<div className="row" style={{ gap: 9, minWidth: 0 }}>
|
||||
<span className="lrow-i" style={{ background: S.active ? 'var(--orange)' : doneToday ? 'var(--surface-3)' : routine ? 'var(--acc)' : 'var(--surface-3)' }}>
|
||||
<Icon name={S.active ? 'timer' : doneToday ? 'checkCircle' : routine ? glyphOf(routine.emoji) : 'moon'}
|
||||
@@ -128,7 +129,7 @@ export default function Home() {
|
||||
</> : <div className="muted small">{t("No entries yet — log your weight to start the curve. It's also asked before every workout.")}</div>}
|
||||
</div>
|
||||
|
||||
<div className="card tappable" style={{ cursor: 'pointer' }} onClick={() => calendarSheet()}>
|
||||
<div className="card tappable" style={{ cursor: 'pointer' }} {...tappable(() => calendarSheet())}>
|
||||
<div className="row between">
|
||||
<div>
|
||||
<div className="row" style={{ gap: 7, fontSize: 22, fontWeight: 600, letterSpacing: '-.021em' }}>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState } from 'react'
|
||||
import { useRef, useState } from 'react'
|
||||
import { useStore } from '../store/useStore.js'
|
||||
import { EXDB, BODYPARTS, allExercises, equipmentOf, matchExercise } from '../lib/exercises.js'
|
||||
import { activeProfile, exAvailable } from '../lib/equipment.js'
|
||||
@@ -9,6 +9,7 @@ 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'
|
||||
import { tappable, useRevealActiveChip } from '../lib/use-sheet-keyboard.js'
|
||||
|
||||
export default function Library() {
|
||||
const S = useStore(s => s.S)
|
||||
@@ -17,6 +18,7 @@ export default function Library() {
|
||||
const [eq, setEq] = useState('')
|
||||
const [showAll, setShowAll] = useState(false) // ignore the active equipment profile for this session
|
||||
const [shown, setShown] = useState(40)
|
||||
const bpStrip = useRef(null), eqStrip = useRef(null)
|
||||
const profile = activeProfile(S)
|
||||
const base = allExercises(S).filter(e => (!bp || e.bp === bp) && matchExercise(e, q))
|
||||
const eqFiltered = (profile && !showAll) ? base.filter(e => exAvailable(S, e)) : base
|
||||
@@ -24,6 +26,8 @@ export default function Library() {
|
||||
// Drop the equipment filter if the search narrowed it away, so you never hit a dead end.
|
||||
const eqOn = eqOpts.includes(eq) ? eq : ''
|
||||
const f = eqOn ? eqFiltered.filter(e => e.eq === eqOn) : eqFiltered
|
||||
useRevealActiveChip(bpStrip, bp)
|
||||
useRevealActiveChip(eqStrip, eqOn)
|
||||
|
||||
return <>
|
||||
<div className="hdr"><div><h1>{t('Exercises')}</h1><div className="sub">{t('{0} exercises with animations', EXDB.length)}</div></div></div>
|
||||
@@ -36,22 +40,22 @@ export default function Library() {
|
||||
{showAll ? t('Filter by "{0}"', profile.name) : t('Show all equipment')}
|
||||
</button>
|
||||
</div>}
|
||||
<div className="chips" style={{ marginBottom: eqOpts.length > 1 ? 8 : 12 }}>
|
||||
<div className="chips" ref={bpStrip} style={{ marginBottom: eqOpts.length > 1 ? 8 : 12 }}>
|
||||
<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 }}>
|
||||
{eqOpts.length > 1 && <div className="chips" ref={eqStrip} style={{ marginBottom: 12 }}>
|
||||
<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="item" {...tappable(() => customExSheet(null, ex => exerciseDetailSheet(ex), q.trim()))}>
|
||||
<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)}>
|
||||
return <div key={e.id} className="item" {...tappable(() => exerciseDetailSheet(e))}>
|
||||
<Thumb ex={e} />
|
||||
<div className="grow"><div className="tt capitalize">{exerciseNameFor(e)}</div><div className="ss capitalize">{t(e.tg || e.bp)} · {t(e.eq)}</div></div>
|
||||
{best > 0 && <span className="tag acc">{fmtNum(best)}</span>}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { t } from '../lib/i18n.js'
|
||||
import { dayAssignSheet, loadStarterPlan, planToolsSheet } from '../sheets.jsx'
|
||||
import Icon from '../components/Icon.jsx'
|
||||
import { Button } from '../components/ui.jsx'
|
||||
import { tappable } from '../lib/use-sheet-keyboard.js'
|
||||
import { glyphOf, DEFAULT_GLYPH } from '../lib/glyphs.js'
|
||||
|
||||
export default function Plan() {
|
||||
@@ -28,7 +29,7 @@ export default function Plan() {
|
||||
<div className="list" style={{ display: 'flex', flexDirection: 'column' }}>
|
||||
{[1, 2, 3, 4, 5, 6, 0].map(d => {
|
||||
const r = S.routines.find(x => x.id === S.week[d])
|
||||
return <div key={d} className="item" onClick={() => dayAssignSheet(d)}>
|
||||
return <div key={d} className="item" {...tappable(() => dayAssignSheet(d))}>
|
||||
<div className="grow"><div className="tt">{t(DAYN[d])}</div></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>
|
||||
@@ -39,7 +40,7 @@ export default function Plan() {
|
||||
<h4 className="sec" style={{ margin: 0 }}>{t('Routines')}</h4>
|
||||
<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)}>
|
||||
{S.routines.length ? <div className="list">{S.routines.map(r => <div key={r.id} className="item" {...tappable(() => nav('/plan/r/' + r.id))}>
|
||||
<span className="lrow-i"><Icon name={glyphOf(r.emoji)} /></span>
|
||||
<div className="grow"><div className="tt">{r.name}</div><div className="ss">{exCount(r.ex.length)}</div></div>
|
||||
<Icon name="chevronRight" className="chev" /></div>)}</div> : <>
|
||||
|
||||
@@ -166,6 +166,36 @@ describe('routine long-press reorder', () => {
|
||||
expect(sheets.exConfigSheet).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('lets a real tap shortly after a drop open the row again', () => {
|
||||
const layout = mount([configured('a'), configured('b'), configured('c')])
|
||||
const item = rows()[0].querySelector('.item')
|
||||
lift(rows()[0], layout.centers[0])
|
||||
pointer(item, 'pointermove', { y: layout.centers[2] + 1 })
|
||||
pointer(item, 'pointerup', { y: layout.centers[2] + 1 })
|
||||
expect(exercises().map(e => e.id)).toEqual(['b', 'c', 'a'])
|
||||
|
||||
act(() => vi.advanceTimersByTime(200))
|
||||
const target = rows()[1].querySelector('.item')
|
||||
pointer(target, 'pointerdown', { y: layout.centers[1] })
|
||||
pointer(target, 'pointerup', { y: layout.centers[1] })
|
||||
act(() => target.click())
|
||||
expect(sheets.exConfigSheet).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('never eats a tap that starts with its own pointerdown, even right after a drop', () => {
|
||||
const layout = mount([configured('a'), configured('b'), configured('c')])
|
||||
const item = rows()[0].querySelector('.item')
|
||||
lift(rows()[0], layout.centers[0])
|
||||
pointer(item, 'pointermove', { y: layout.centers[2] + 1 })
|
||||
pointer(item, 'pointerup', { y: layout.centers[2] + 1 })
|
||||
|
||||
const target = rows()[1].querySelector('.item')
|
||||
pointer(target, 'pointerdown', { y: layout.centers[1] })
|
||||
pointer(target, 'pointerup', { y: layout.centers[1] })
|
||||
act(() => target.click())
|
||||
expect(sheets.exConfigSheet).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('moves a whole grouped unit, never splits another group, and preserves every occurrence payload', () => {
|
||||
const pairA = configured('dup', { sg: 'pair', weight: 11, note: 'first', future: { a: 1 } })
|
||||
const pairB = configured('dup', { sg: 'pair', weight: 22, note: 'second', future: { b: 2 } })
|
||||
|
||||
@@ -129,7 +129,9 @@ function useRoutineReorder(routineIdentity, exercises, onDrop) {
|
||||
releaseCapture(gesture)
|
||||
suppressClickRef.current = true
|
||||
window.clearTimeout(suppressTimerRef.current)
|
||||
suppressTimerRef.current = window.setTimeout(() => { suppressClickRef.current = false }, 500)
|
||||
// The compatibility click lands synchronously after pointerup; anything
|
||||
// later is a real tap, so the guard only needs to outlive that one event.
|
||||
suppressTimerRef.current = window.setTimeout(() => { suppressClickRef.current = false }, 150)
|
||||
setDrag(null)
|
||||
const rect = list.getBoundingClientRect()
|
||||
const inside = x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom
|
||||
@@ -194,6 +196,9 @@ function useRoutineReorder(routineIdentity, exercises, onDrop) {
|
||||
updateDrag(gesture, gesture.lastX, gesture.lastY)
|
||||
}
|
||||
const onPointerDown = event => {
|
||||
// a new touch is intentional — never let the post-drop guard eat its click
|
||||
suppressClickRef.current = false
|
||||
window.clearTimeout(suppressTimerRef.current)
|
||||
const current = gestureRef.current
|
||||
if (current) {
|
||||
if (event.pointerId !== current.pointerId) finish(current, false)
|
||||
|
||||
@@ -20,6 +20,7 @@ import {
|
||||
effortHistogram, isHardSet, HARD_RIR
|
||||
} from '../lib/effort.js'
|
||||
import { Button, Segmented, SelectRow } from '../components/ui.jsx'
|
||||
import { tappable } from '../lib/use-sheet-keyboard.js'
|
||||
import { isWarmupRow } from '../lib/workout-model.js'
|
||||
|
||||
// Which muscles the training in a window actually hit — and, the point of the card,
|
||||
@@ -189,7 +190,7 @@ function MuscleBalance({ S }) {
|
||||
{sel && <>
|
||||
<h4 className="sec" style={{ marginTop: 14 }}>{t('Exercises')} · {t(MUSCLE_NAME[sel])}</h4>
|
||||
{muscleExercises.length ? muscleExercises.map(row => (
|
||||
<div key={row.id} className="mrow" style={{ minHeight: 48, alignItems: 'stretch', cursor: 'pointer' }} onClick={() => onExercise && onExercise(row.id)}>
|
||||
<div key={row.id} className="mrow" style={{ minHeight: 48, alignItems: 'stretch', cursor: 'pointer' }} {...tappable(() => onExercise && onExercise(row.id))}>
|
||||
<span className="nm" style={{ whiteSpace: 'normal', lineHeight: 1.35, display: 'flex', flexDirection: 'column', justifyContent: 'center' }}>
|
||||
<span style={{ display: 'block', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||
{row.name}
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('Stats mixed-entry metric contract', () => {
|
||||
|
||||
it('renders one clickable muscle exercise list rather than a duplicate non-clickable copy', () => {
|
||||
expect((source.match(/muscleExercises\.length \? muscleExercises\.map\(row =>/g) || []).length).toBe(1)
|
||||
expect(source).toContain('onClick={() => onExercise && onExercise(row.id)}')
|
||||
expect(source).toContain('{...tappable(() => onExercise && onExercise(row.id))}')
|
||||
})
|
||||
|
||||
it('uses the shared metric mode and row helpers rather than entryMode as a chart gate', () => {
|
||||
|
||||
Reference in new issue
Block a user