Rest timer: take 15 seconds off, not only add them

addRest now accepts a negative step, and taking off more than is left finishes the
rest instead of counting into the negative -- which also kept a negative duration out
of the progress bar and out of the server-side push schedule.

Three controls and the clock do not fit one line on a phone: at 360px the bar was
left with about 30px and stopped saying anything. The rest variant stacks -- clock and
bar on top, controls beneath, -15 and +15 together in number-line order, Skip pushed
to the far edge so the button that ends the rest is not next to the one you tap to buy
more time. Scoped to #timer.rest, so the work timer keeps its single row. Back to one
line at >=1000px, and the card is nearly opaque now -- the set rows underneath were
reading through it.
This commit is contained in:
Duarte Santos committed 2026-07-31 15:35:27 +02:00
1 parent 248da53dca
commit c5e131f81c
3 files changed
+34 -8

No files matched your search

+14 -5
View File
@@ -34,12 +34,21 @@ export default function RestTimer() {
<Button size="sm" variant="primary" icon="check" onClick={finishWorkEarly}>{t('Done')}</Button>
</div>
)
// Three controls plus the clock don't fit one line on a phone — at 360px the bar is left
// with about 30px and stops saying anything. So the rest variant stacks: clock and bar
// read at a glance, controls get their own row. −15 and +15 sit together in number-line
// order; Skip is pushed to the far edge, away from the button you tap to buy more time.
return (
<div id="timer">
<div className="t">{clock(timer.left)}</div>
<div className="bar"><i style={{ width: pct + '%' }} /></div>
<Button size="sm" icon="plus" onClick={() => addRest(15)}>15s</Button>
<Button size="sm" variant="primary" onClick={stopRest}>{t('Skip')}</Button>
<div id="timer" className="rest">
<div className="head">
<div className="t">{clock(timer.left)}</div>
<div className="bar"><i style={{ width: pct + '%' }} /></div>
</div>
<div className="acts">
<Button size="sm" icon="minus" onClick={() => addRest(-15)}>15s</Button>
<Button size="sm" icon="plus" onClick={() => addRest(15)}>15s</Button>
<Button size="sm" variant="primary" className="skip" onClick={stopRest}>{t('Skip')}</Button>
</div>
</div>
)
}
+17 -3
View File
@@ -165,8 +165,9 @@ button,.chip,.tile,.item,.wday,.cal-d,.swatch,.hm-c,.lrow,.seg button,.stp butto
padding:calc(var(--sat) + 8px) var(--pad) calc(128px + var(--sab));
max-width:560px;margin:0 auto;
}
/* while the rest timer floats above the tab bar, keep its height scrollable-past */
body.resting #app{padding-bottom:calc(206px + var(--sab))}
/* while the rest timer floats above the tab bar, keep its height scrollable-past
(the rest variant is two rows tall — ~44px more than the single-row work timer) */
body.resting #app{padding-bottom:calc(250px + var(--sab))}
@keyframes viewfade{from{opacity:0;transform:translateY(4px)}to{opacity:1;transform:none}}
#app.vfade{animation:viewfade var(--med) var(--ease)}
@@ -603,7 +604,9 @@ h4.sec{
/* --- rest timer --- */
#timer{
position:fixed;left:12px;right:12px;bottom:calc(88px + var(--sab));z-index:60;
background:color-mix(in srgb,var(--surface) 82%,transparent);
/* nearly opaque: the set rows underneath were reading through the old 82% and made the
clock hard to pick out mid-set. The blur stays, so it still sits above the page. */
background:color-mix(in srgb,var(--surface) 97%,transparent);
backdrop-filter:saturate(180%) blur(24px);-webkit-backdrop-filter:saturate(180%) blur(24px);
border-radius:var(--r-lg);padding:12px 14px;
display:flex;align-items:center;gap:12px;
@@ -614,6 +617,14 @@ h4.sec{
#timer .t{font-size:26px;font-weight:600;letter-spacing:-.026em;font-variant-numeric:tabular-nums;min-width:66px}
#timer .bar{flex:1;height:4px;background:var(--surface-3);border-radius:99px;overflow:hidden}
#timer .bar i{display:block;height:100%;background:var(--acc);transition:width 1s linear}
/* rest variant: −15/+15/Skip and the clock won't share one line on a phone, so the clock and
bar take the top row and the controls take their own. The work timer keeps a single row —
it only ever has two buttons. */
#timer.rest{flex-direction:column;align-items:stretch;gap:10px}
#timer.rest .head{display:flex;align-items:center;gap:12px}
#timer.rest .acts{display:flex;align-items:center;gap:8px}
#timer.rest .acts .btn{padding-top:11px;padding-bottom:11px} /* sweaty hands, mid-set */
#timer.rest .acts .skip{margin-left:auto;min-width:84px}
/* work timer (issue #16): the same bar doing the opposite job — outlined and tinted so a
glance tells "you are holding this" apart from "you are recovering". */
#timer.working{border:var(--hair) solid var(--acc)}
@@ -893,6 +904,9 @@ h4.sec{
.sheet{left:50%;right:auto;margin-left:-320px;width:640px;border-radius:var(--r-xl) var(--r-xl) 0 0}
.center{width:340px}
#timer{left:50%;right:auto;margin-left:-260px;width:520px;bottom:112px}
/* 520px fits the clock, the bar and all three controls on one line again */
#timer.rest{flex-direction:row;align-items:center;gap:14px}
#timer.rest .head{flex:1;min-width:0}
.exmedia img{height:380px}
.hm-wrap{display:flex;flex-direction:column;align-items:center}
}
+3
View File
@@ -63,6 +63,9 @@ export const useUI = create((set, get) => ({
const tm = get().timer
if (!tm) return
const left = tm.left + sec
// taking off more than is left means "I'm ready now" — same as skipping, and it keeps a
// negative duration out of both the progress bar and the server-side push schedule
if (left <= 0) { get().stopRest(); return }
set({ timer: { ...tm, left, total: tm.total + sec, endsAt: tm.endsAt + sec * 1000 } })
pushRestTimer(left)
},