diff --git a/frontend/src/index.css b/frontend/src/index.css index 53be7c3..a07a9f4 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -329,3 +329,12 @@ h4.sec{font-size:.8rem;text-transform:uppercase;letter-spacing:.08em;color:var(- .today-row .lbl2{font-size:.62rem;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--dim)} .today-row .ttl{font-weight:700;font-size:.98rem;line-height:1.2;text-transform:capitalize; white-space:nowrap;overflow:hidden;text-overflow:ellipsis} + +/* ---------- body-weight slider + stepper input ---------- */ +.bwstep{display:flex;align-items:center;justify-content:center;gap:16px;margin:18px 0 10px} +.bw-pm{width:54px;height:54px;border-radius:50%;background:var(--card);border:1px solid var(--line); + font-size:1.7rem;font-weight:700;color:var(--acc);flex:none} +.bw-pm:active{background:var(--card2);transform:scale(.94)} +.bw-read{font-size:2.9rem;font-weight:800;letter-spacing:-.02em;min-width:160px;text-align:center;font-variant-numeric:tabular-nums} +.bw-read .u{font-size:1.1rem;color:var(--mut);font-weight:600} +.bw-slider{width:100%;height:30px;accent-color:var(--acc);cursor:pointer} diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx index df3ad1d..a00692e 100644 --- a/frontend/src/sheets.jsx +++ b/frontend/src/sheets.jsx @@ -30,31 +30,59 @@ export function loadStarterPlan() { /* ============================ body weight ============================ */ function BwSheet({ required, onDone, close }) { - const bw = lastBW(S()) - const [v, setV] = useState(bw ? String(bw.w) : '') - const ref = useRef(null) - useEffect(() => { setTimeout(() => { ref.current?.focus(); ref.current?.select() }, 250) }, []) + const st = useStore(s => s.S) + const unit = st.unit + const bw = lastBW(st) + const start = bw ? bw.w : 70 + const [v, setV] = useState(start) + const clamp = x => Math.max(20, Math.min(300, Math.round((x || 0) * 10) / 10)) + const set = x => setV(clamp(x)) // absolute (slider) + const step = d => setV(p => clamp(p + d)) // relative (buttons/chips) — safe for rapid taps + // fixed slider window around the starting value (buttons/quick chips can go beyond) + const lo = Math.max(30, Math.round(start - 20)) + const hi = Math.min(250, Math.round(start + 20)) const save = () => { - const n = parseFloat(v) - if (!n || n <= 0 || n > 400) { toast('Enter a valid weight'); return } - update(st => { + const n = clamp(v) + if (!n || n <= 0) { toast('Enter a valid weight'); return } + update(s => { const iso = todayISO() - const ex = st.bodyweight.find(b => b.d === iso) - if (ex) { ex.w = n; ex.t = Date.now() } else st.bodyweight.push({ d: iso, w: n, t: Date.now() }) - st.bodyweight.sort((a, b) => (a.d < b.d ? -1 : 1)) + const ex = s.bodyweight.find(b => b.d === iso) + if (ex) { ex.w = n; ex.t = Date.now() } else s.bodyweight.push({ d: iso, w: n, t: Date.now() }) + s.bodyweight.sort((a, b) => (a.d < b.d ? -1 : 1)) }) close() if (onDone) onDone(n); else toast('Weight saved ✓') } + const recent = [...st.bodyweight].reverse().slice(0, 6) + const delEntry = d => update(s => { s.bodyweight = s.bodyweight.filter(b => b.d !== d) }) return <>