Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

fix: from 761px the Watch help line runs the full width under the heading and the switch, and the switch is as tall as the heading line, so the stage and the player bar stay where they are without the switch

matinf25806e71f2c
diff --git a/assets/css/demo-page.css b/assets/css/demo-page.css
index b8813c86..339b3675 100644
--- a/assets/css/demo-page.css
+++ b/assets/css/demo-page.css
@@ -239,26 +239,42 @@ textarea.hb-text{min-height:88px;padding:10px 12px;resize:vertical}
.hb-bar{gap:4px;padding:0 8px}
.hb-bar .hb-home{font-size:15px}
}
-/* From 761px the mode switch sits at the right end of the Watch step's heading row (two columns: the heading, the switch). A player
- bar with one or two controls leaves room beside it, so there the note for the mode in view sits next to the bar, under the switch,
- and is on a laptop's first screen too. Three columns then: the player bar's own width, the room left over and the switch's width.
- The heading spans the first two (the room it had before), the stage spans all three, the player bar keeps the start of its row (a
- note taller than the bar grows the row, not the bar, so the bar does not move) and the note spans the other two. A bar with a
- third control has no room to spare, and neither has one with the note that reduced motion adds: the note is looked for itself
- (a bar with one control and that note has only two children), and either way the bar keeps the full row and the note stays
- under it. An empty notes box is taken out of the flow (above), so it takes no room here either. Up to 760px the note stays
- under the player bar. */
+/* From 761px the mode switch sits at the right end of the Watch step's heading row (two columns: the heading, the switch), and the
+ help line runs under that row across the whole step, as wide as on a page without the switch. The step is a grid. The heading box
+ and the box around the heading and the help line give way (display: contents: both are plain boxes, so the heading and the help
+ line keep their meaning for screen readers, and the reading order is the page's), and the number, the heading and the help line
+ take places on the grid themselves: the number in the first column over the first two rows, the heading in the first row up to
+ the switch's column, the help line in the second row across every column, both 46px in (the number's 32px and the heading box's
+ 14px gap). Nothing in the heading row is taller than the heading line, so the stage stays where it is on a page without the
+ switch: the switch is stretched to that line (its buttons drop the 44px minimum here; up to 760px, in a row of their own, they
+ keep it), and the number reaches into the help line's row, as it does there. The help line keeps its 4px under the heading: it
+ is pulled up by the gap between the step's rows less 4px (16px less 4px; on a short laptop screen 12px less 4px, below).
+ A player bar with one or two controls leaves room beside it, so there the note for the mode in view sits next to the bar, under
+ the switch, and is on a laptop's first screen too. Three columns then: the player bar's own width, the room left over and the
+ switch's width. The heading spans the first two (the room it had before), the stage spans all three, the player bar keeps the
+ start of its row (a note taller than the bar grows the row, not the bar, so the bar does not move) and the note spans the other
+ two. A bar with a third control has no room to spare, and neither has one with the note that reduced motion adds: the note is
+ looked for itself (a bar with one control and that note has only two children), and either way the bar keeps the full row and
+ the note stays under it. An empty notes box is taken out of the flow (above), so it takes no room here either. Up to 760px the
+ note stays under the player bar. */
@media(min-width:761px){
.hb-watch:has(> .hb-modes){display:grid;grid-template-columns:minmax(0,1fr) auto;column-gap:20px;align-items:end}
.hb-watch:has(> .hb-modes) > *{grid-column:1/-1}
- .hb-watch:has(> .hb-modes) > .hb-step-head{grid-column:1}
- .hb-watch:has(> .hb-modes) > .hb-modes{grid-column:2;flex-wrap:nowrap}
+ .hb-watch:has(> .hb-modes) > .hb-step-head,.hb-watch:has(> .hb-modes) > .hb-step-head > div{display:contents}
+ .hb-watch:has(> .hb-modes) > .hb-step-head > .hb-num{grid-row:1/span 2;grid-column:1;align-self:start}
+ .hb-watch:has(> .hb-modes) > .hb-step-head > div > h2{grid-row:1;grid-column:1/-2;margin-left:46px}
+ .hb-watch:has(> .hb-modes) > .hb-step-head > div > p{grid-row:2;grid-column:1/-1;margin:-12px 0 0 46px}
+ .hb-watch:has(> .hb-modes) > .hb-modes{grid-row:1;grid-column:2;flex-wrap:nowrap;align-self:stretch}
+ .hb-watch:has(> .hb-modes) > .hb-modes button{min-height:0}
.hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3), > .hb-player > .hb-player-note)){grid-template-columns:auto minmax(0,1fr) auto}
- .hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3), > .hb-player > .hb-player-note)) > .hb-step-head{grid-column:1/3}
.hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3), > .hb-player > .hb-player-note)) > .hb-modes{grid-column:3}
.hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3), > .hb-player > .hb-player-note)) > .hb-player{grid-column:1;align-self:start}
.hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3), > .hb-player > .hb-player-note)) > .hb-mode-notes{grid-column:2/-1;align-self:center}
}
+/* A short laptop screen puts 12px between the Watch step's rows (below), so there the help line is pulled up by 12px less 4px */
+@media(min-width:761px) and (max-height:760px){
+ .hb-watch:has(> .hb-modes) > .hb-step-head > div > p{margin-top:-8px}
+}
/* Up to 760px the switch has a row of its own above the stage, its three buttons sharing it equally (.seg.hb-modes outranks the
.seg button rule for phones further down) */
@media(max-width:760px){
diff --git a/tests/pages.test.js b/tests/pages.test.js
index 52e7c4f1..83a1a3a3 100644
--- a/tests/pages.test.js
+++ b/tests/pages.test.js
@@ -675,19 +675,75 @@ test('the shared stylesheet draws the mode switch beside the Watch heading and t
const SHORT = '.hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3), > .hb-player > .hb-player-note))';
for (const [what, text] of [
['three columns: the player bar, the room left over, the switch', `${SHORT}{grid-template-columns:auto minmax(0,1fr) auto}`],
- ['the heading spans the first two columns', `${SHORT} > .hb-step-head{grid-column:1/3}`],
+ ['the heading runs up to the switch\'s column (the first two of three)', '.hb-watch:has(> .hb-modes) > .hb-step-head > div > h2{grid-row:1;grid-column:1/-2;'],
['the switch is in the third column', `${SHORT} > .hb-modes{grid-column:3}`],
['the player bar starts its row and stays at the start of it when the row grows', `${SHORT} > .hb-player{grid-column:1;align-self:start}`],
['the note spans the other two columns', `${SHORT} > .hb-mode-notes{grid-column:2/-1;`],
['a bar with a third control keeps the two columns (the switch beside the heading, the rest on the full row)', '.hb-watch:has(> .hb-modes){display:grid;grid-template-columns:minmax(0,1fr) auto;']
]) assert.ok(wide.includes(text), `from 761px: ${what}`);
- assert.ok(wide.includes('.hb-watch:has(> .hb-modes) > .hb-modes{grid-column:2;flex-wrap:nowrap}'), 'the 761px block is the one that has the switch beside the heading');
+ assert.ok(wide.includes('.hb-watch:has(> .hb-modes) > .hb-modes{grid-row:1;grid-column:2;flex-wrap:nowrap;'), 'the 761px block is the one that has the switch beside the heading');
assert.equal(count(wide, '> .hb-mode-notes{'), 1, 'one rule places the note beside the player bar, and it is in the 761px block');
assert.equal(count(css, '> .hb-mode-notes{'), 1, 'no other rule places the note, so phones keep it under the player bar');
assert.ok(phones.includes('.hb-page .seg.hb-modes button{flex:1 1 0'), 'the block up to 760px is found (it holds the equal mode buttons)');
assert.ok(!/\.hb-watch|\.hb-mode-notes|\.hb-player/.test(phones), 'up to 760px nothing makes the Watch step a grid or places the note or the player bar');
});
+test('from 761px the help line runs under the heading and the switch, as wide as without the switch, and the heading row is no taller than the heading line', () => {
+ // The Watch step's heading box and the box around its heading and help line give way (display: contents), so the number, the
+ // heading and the help line take places on the step's grid: the heading in the first row up to the switch's column, the help line
+ // in the second row across every column, as wide as on a page without the switch, both as far in as the number and the heading
+ // box's gap put them there. Only those two plain boxes give way: no heading, paragraph or section loses its box, so nothing loses
+ // its meaning for screen readers. The heading row is no taller than the heading line, so the stage and the player bar stay where
+ // they are on a page without the switch: the switch is stretched to that line (from 761px its buttons drop the 44px minimum they
+ // keep up to 760px), the number spans both rows (it reaches into the help line's row there too), and the help line is pulled up
+ // by the gap between the step's rows less its own 4px, with the short laptop screens' smaller gap too. The values are read from
+ // the rules they follow, so a change to one of those fails here. Every rule from 761px is for a Watch step that has the switch, so
+ // a page without it is drawn as before.
+ const bare = read(path.join(ROOT, 'assets', 'css', 'demo-page.css')).replace(/\/\*[\s\S]*?\*\//g, '');
+ const wide = blockOf(bare, '@media(min-width:761px){');
+ const shortWide = blockOf(bare, '@media(min-width:761px) and (max-height:760px){');
+ const shortLaptop = blockOf(bare, '@media(min-width:601px) and (max-height:760px){');
+ const outside = bare.replace(/@media[^{]*\{(?:[^{}]*\{[^{}]*\})*[^{}]*\}/g, ''); // the rules outside every @media block
+ // The first px value of a property in the one rule written for exactly this selector
+ const px = (css, selector, prop) => {
+ const found = cssRules(css).filter(r => r.selector === selector && new RegExp(`(^|;)\\s*${prop}:`).test(r.body));
+ assert.equal(found.length, 1, `one ${selector} rule sets ${prop}`);
+ return Number(found[0].body.match(new RegExp(`(?:^|;)\\s*${prop}:\\s*(-?[\\d.]+)px`))[1]);
+ };
+ const indent = px(outside, '.hb-num', 'width') + px(outside, '.hb-step-head', 'gap');
+ const own = px(outside, '.hb-step-head p', 'margin');
+ const pull = own - px(outside, '.hb-watch', 'gap');
+ const shortPull = own - px(shortLaptop, '.hb-watch', 'gap');
+ const W = '.hb-watch:has(> .hb-modes)';
+ for (const [what, text] of [
+ ['the heading box and the box inside it give way', `${W} > .hb-step-head,${W} > .hb-step-head > div{display:contents}`],
+ ['the number is in the first column over the heading row and the help line row, at the top', `${W} > .hb-step-head > .hb-num{grid-row:1/span 2;grid-column:1;align-self:start}`],
+ [`the heading is in the first row up to the switch's column, ${indent}px in`, `${W} > .hb-step-head > div > h2{grid-row:1;grid-column:1/-2;margin-left:${indent}px}`],
+ [`the help line is in the second row across every column, ${indent}px in, pulled up ${-pull}px`, `${W} > .hb-step-head > div > p{grid-row:2;grid-column:1/-1;margin:${pull}px 0 0 ${indent}px}`],
+ ['the switch is in the heading row, stretched to the heading line', `${W} > .hb-modes{grid-row:1;grid-column:2;flex-wrap:nowrap;align-self:stretch}`],
+ ['its buttons drop the 44px minimum', `${W} > .hb-modes button{min-height:0}`]
+ ]) assert.ok(wide.includes(text), `from 761px: ${what}`);
+ assert.ok(shortWide.includes(`${W} > .hb-step-head > div > p{margin-top:${shortPull}px}`), `on a short laptop screen the help line is pulled up ${-shortPull}px`);
+ // The selectors of a selector list (commas inside brackets, as in :has(a, b), do not split it)
+ const selectorsOf = list => {
+ const out = [];
+ let depth = 0, from = 0;
+ for (let i = 0; i < list.length; i++) {
+ if (list[i] === '(') depth++;
+ else if (list[i] === ')') depth--;
+ else if (list[i] === ',' && depth === 0) { out.push(list.slice(from, i).trim()); from = i + 1; }
+ }
+ return [...out, list.slice(from).trim()];
+ };
+ const contents = cssRules(bare).filter(r => /(^|;)\s*display:\s*contents\s*(;|$)/.test(r.body)).flatMap(r => selectorsOf(r.selector));
+ assert.deepEqual(contents, [`${W} > .hb-step-head`, `${W} > .hb-step-head > div`], 'only the two plain boxes give way');
+ assert.equal(count(bare, '.hb-modes button{min-height:0}'), 1, 'only from 761px do the mode buttons drop the 44px minimum');
+ assert.equal(px(outside, '.hb-page .seg button', 'min-height'), 44, 'up to 760px the mode buttons keep the 44px minimum of choice buttons');
+ for (const css of [wide, shortWide]) {
+ for (const rule of cssRules(css)) for (const sel of selectorsOf(rule.selector)) assert.ok(sel.startsWith(W), `for a Watch step with the switch: ${sel}`);
+ }
+});
+
// The learning path and the idea lessons wait on feat/learn-pilot (docs/superpowers/specs/2026-10-13-see-inside-compare-rollout-design.md,
// section 5): no tracked page links into learn/ and the shared stylesheet keeps none of their rules. Delete this test when the
// learning path resumes (its first step reverts the clean-up commit, which takes this test away too).