From ab95bacaa1be65927d2400c1d8cb4e2d7fc03488 Mon Sep 17 00:00:00 2001 From: Sebastian G Date: Thu, 3 Sep 2026 10:00:53 +0200 Subject: [PATCH] improved RIR edit handling --- frontend/src/index.css | 54 +++++++++++++++++++++++----- frontend/src/sheets.jsx | 23 ++++++++---- frontend/src/views/Workout.jsx | 26 ++++++++++---- frontend/src/views/Workout.test.jsx | 56 ++++++++++++++++++++++++----- 4 files changed, 129 insertions(+), 30 deletions(-) diff --git a/frontend/src/index.css b/frontend/src/index.css index c9cbf40..5a478b1 100644 --- a/frontend/src/index.css +++ b/frontend/src/index.css @@ -662,14 +662,36 @@ h4.sec{ } .effcell:active{transform:scale(.94)} .effcell.is-empty{color:var(--label-2);font-weight:500;font-size:12px;letter-spacing:.02em} +/* a logged rating becomes a −/value/+ stepper, tinted by its effort band: the band colour + fills the cell at low opacity (set inline via color-mix), borders it, and colours the value. + the +/− buttons step 0.5 on the profile's scale; the value opens the picker. it carries the + same column flex as the plain .effcell so the row does not jump when a rating is added. */ +.setrow .effcell-stp,.setrow.eff3 .effcell-stp{ + height:44px;border-radius:10px;border:1.5px solid transparent; + transition:background var(--fast),border-color var(--fast); +} +.effcell-stp button{color:inherit} +.effcell-stp>button[aria-label="Decrease"], +.effcell-stp>button[aria-label="Increase"]{width:26px;height:44px;font-size:15px;opacity:.85} +.effcell-stp .val{ + flex:1;min-width:0;display:flex;align-items:center;justify-content:center; + font-size:15px;font-weight:600;letter-spacing:-.01em; + font-variant-numeric:tabular-nums;line-height:1;align-self:stretch;color:inherit; +} +.effcell-stp .val:active{background:var(--surface-3)} /* the effort cell needs less room now (one short value, no +/- buttons), so weight/reps keep more of the row on narrow phones than they did when three steppers had to share it */ +.setrow .effcell-stp,.setrow.eff3 .effcell-stp{flex:.8 1 0;min-width:0} +.setrow.eff3 .effcell-stp{flex:.7 1 0} .setrow.eff3,.sethead.eff3{gap:6px} .setrow.eff3 .stp.w,.sethead.eff3 .w-sp{flex:1.4} .setrow.eff3 .stp.r,.sethead.eff3 .r-sp{flex:1.1} .setrow.eff3 .effcell,.sethead.eff3 .eff-sp{flex:.7 1 0} .setrow.eff3 .stp.w button,.setrow.eff3 .stp.r button{width:26px} .setrow.eff3 .stp .num{font-size:14px} +.setrow.eff3 .effcell-stp>button[aria-label="Decrease"], +.setrow.eff3 .effcell-stp>button[aria-label="Increase"]{width:22px} +.setrow.eff3 .effcell-stp .val{font-size:14px} /* effort quick picker sheet: colour-coded preset buttons, hardest (purple) first */ .effpick{display:grid;grid-template-columns:repeat(2,1fr);gap:9px;margin-bottom:16px} .effpick-b{ @@ -683,20 +705,34 @@ h4.sec{ .effpick-b.on{background:color-mix(in srgb,var(--bc) 16%,var(--surface));border-color:var(--bc)} .effpick-n{font-size:20px;font-weight:700;color:var(--bc);line-height:1;font-variant-numeric:tabular-nums} .effpick-f{font-size:12px;color:var(--label-2);line-height:1.25} -/* the free field sits as a full-width row the same size as a preset button: its label on the - left, a large right-aligned input on the right, same padding and radius as .effpick-b */ +/* the free field sits as a full-width row the same size as a preset button: its "Exact RIR" + label on the left, a −/value/+ group in the middle, and the scale name on the right, same + padding and radius as .effpick-b. the whole row borders in the current band colour. */ .effpick-free{ - display:flex;align-items:center;justify-content:space-between;gap:12px; - padding:12px 14px;border-radius:13px;margin-top:2px; + display:flex;align-items:center;justify-content:space-between;gap:10px; + padding:10px 14px;border-radius:13px;margin-top:2px; background:var(--surface);border:1.5px solid var(--sep-op); + transition:border-color var(--fast); } -.effpick-free-l{font-size:14px;color:var(--label-2)} +.effpick-free-l{font-size:14px;color:var(--label-2);flex:none} +.effpick-free-unit{font-size:13px;font-weight:600;color:var(--label-3);flex:none} +/* the −/value/+ group: a rounded surface holding a big tappable number between two step + buttons. tinted (color:inherit) to the band colour when a value is set. */ +.effpick-step{ + display:flex;align-items:center;gap:2px;flex:none; + background:var(--surface-2);border-radius:10px;overflow:hidden; +} +.effpick-step button{ + width:38px;height:40px;flex:none;color:currentColor;font-size:16px;--icon-stroke:2.2; + display:flex;align-items:center;justify-content:center;transition:background var(--fast); +} +.effpick-step button:active{background:var(--surface-3)} /* the `.num` base styling (transparent bg, no border) is scoped to `.stp .num`; this input is - not in a stepper, so it must set its own or the browser paints a native white field. */ + not in a `.stp`, so it must set its own or the browser paints a native white field. */ .effpick-free-in.num{ - flex:none;width:90px;text-align:right;padding:0; - background:none;border:none;outline:none; - font-size:20px;font-weight:700;color:var(--label); + flex:none;width:64px;text-align:center;padding:0;height:40px; + background:none;border:none;outline:none;color:currentColor; + font-size:20px;font-weight:700;font-variant-numeric:tabular-nums; -moz-appearance:textfield;appearance:textfield; } .effpick-free-in.num::-webkit-inner-spin-button{display:none} diff --git a/frontend/src/sheets.jsx b/frontend/src/sheets.jsx index e47d214..0f5fcf4 100644 --- a/frontend/src/sheets.jsx +++ b/frontend/src/sheets.jsx @@ -4,7 +4,7 @@ import { useUI } from './store/useUI.js' import { EXDB, EXIDX, BODYPARTS, isCardio, isBodyweightEq, allExercises, equipmentOf, smOf, matchExercise, exOr } from './lib/exercises.js' import { activeProfile, exAvailable, ALL_EQUIPMENT, newProfile } from './lib/equipment.js' import { fmtDate, fmtNum, fmtVol, fmtDur, durPart, todayISO, isoOf, uid, exCount, DAYN, DAYS, weekOrder, weekStartOf, weekDayOffset, MONTHS_LONG, ACCENTS } from './lib/format.js' -import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, EFFORT, capEffort, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js' +import { lastEntryFor, bestWeightFor, buildSets, effectiveRoutineId, workoutVolume, setsDone, setsDoneActive, lastBW, supersetUnits, unitOf, setLabel, defaultConfig, cleanupSg, modeOf, effortOf, EFFORT, capEffort, stepEffort, isBw, isPerSide, sideReps, workSetsDone, applyIntensifierPlan, MAX_PLANNED_WARMUPS, NOTE_MAX } from './lib/history.js' import { usesBar, barWeightFor, defaultBarWeight, hasBarOverride } from './lib/bar.js' import { toScale, rirOf, EFFORT_PRESETS, effortColor } from './lib/effort.js' import { beep, vibrate } from './lib/sound.js' @@ -1205,6 +1205,9 @@ function EffortPicker({ kind, value, onPick, close }) { // RIR so the highlighted preset is right on either scale, and so a typed RPE colours the // same as the RIR it equals. const curRir = rirOf(kind === 'rpe' ? { rpe: v } : { rir: v }) + // The band colour for the value currently on the field, so the exact-value row is tinted the + // same way the presets and the workout row cell are — null (nothing typed) stays neutral. + const curColor = effortColor(curRir) const commit = nv => { close(); onPick(nv) } const pick = rir => commit(toScale(kind, rir)) return <> @@ -1225,12 +1228,20 @@ function EffortPicker({ kind, value, onPick, close }) { {/* The free field keeps the flexibility the stepper had: a value between two presets, in the profile's own scale, capped to the top of it (there is no RPE 12). Sized like a - preset so it reads as the seventh option — "or type your own" — not an afterthought. */} -