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.
HTML ai-promptsanimationcss-animationsfrontendgithub-pagesjavascriptmicrointeractionsmotion-designno-dependenciesreferencescroll-animationui-animationweb-animationweb-developmentwebgl
fix: a player bar with the reduced-motion note keeps the full row from 761px, and the stylesheet test takes each media block with its braces matched
matin49b7942c15a1
diff --git a/assets/css/demo-page.css b/assets/css/demo-page.cssindex 11969169..5f6e9c2e 100644--- a/assets/css/demo-page.css+++ b/assets/css/demo-page.css@@ -271,19 +271,20 @@ textarea.hb-text{min-height:88px;padding:10px 12px;resize:vertical}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 (anote 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, or with the note that reduced motion adds, has no room to spare: it 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. */+ 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):not(:has(> .hb-player > :nth-child(3))){grid-template-columns:auto minmax(0,1fr) auto}- .hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3))) > .hb-step-head{grid-column:1/3}- .hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3))) > .hb-modes{grid-column:3}- .hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3))) > .hb-player{grid-column:1;align-self:start}- .hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3))) > .hb-mode-notes{grid-column:2/-1;align-self:center}+ .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}}/* 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) */diff --git a/tests/pages.test.js b/tests/pages.test.jsindex 7aba5ba6..a4a55ed5 100644--- a/tests/pages.test.js+++ b/tests/pages.test.js@@ -20,6 +20,17 @@ const between = (s, from, to) => {const end = s.indexOf(to, start + from.length);return s.slice(start, end < 0 ? undefined : end);};+// The text inside the braces of the first block that starts with `header` (which ends with the block's opening brace), the braces+// matched, so a rule after the block's closing brace is not part of it ('' when there is no such block).+const blockOf = (s, header) => {+ const start = s.indexOf(header);+ if (start < 0) return '';+ for (let i = start + header.length, depth = 1; i < s.length; i++) {+ if (s[i] === '{') depth++;+ else if (s[i] === '}' && --depth === 0) return s.slice(start + header.length, i);+ }+ return '';+};const decode = s => s.replace(/"/g, '"').replace(/'/g, "'").replace(/</g, '<').replace(/>/g, '>').replace(/&/g, '&');// The rules of a stylesheet as { selector, body }: comments removed, rules inside @media and @supports included.const cssRules = css => [...css.replace(/\/\*[\s\S]*?\*\//g, '').matchAll(/([^{}]+)\{([^{}]*)\}/g)]@@ -554,11 +565,14 @@ test('the shared stylesheet draws the mode switch beside the Watch heading and t// From 761px a player bar with one or two controls leaves room beside it, so the note for the mode in view sits next to the bar,// under the switch, and is on a laptop's first screen: three columns (the player bar's own width, the room left over, the switch's// width); the heading spans the first two, 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 (or the note that reduced- // motion adds) keeps the two columns, the full row and the note under it. Up to 760px the note stays under the player bar: no- // other rule places it.- const wide = between(css, '@media(min-width:761px){', '@media(max-width:760px)');- const SHORT = '.hb-watch:has(> .hb-modes):not(:has(> .hb-player > :nth-child(3)))';+ // not the bar, so the bar does not move) and the note spans the other two. A bar with a third control, or with the note that+ // reduced motion adds (looked for itself: a bar with one control and that note has only two children), keeps the two columns,+ // the full row and the note under it. Up to 760px the note stays under the player bar: no other rule places it. The blocks+ // are taken with their braces matched, so a rule after a block's closing brace is not counted as inside it.+ const bare = css.replace(/\/\*[\s\S]*?\*\//g, '');+ const wide = blockOf(bare, '@media(min-width:761px){');+ const phones = blockOf(bare, '@media(max-width:760px){');+ 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}`],@@ -567,7 +581,11 @@ test('the shared stylesheet draws the mode switch beside the Watch heading and t['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.equal(count(css, '> .hb-mode-notes{'), 1, 'one rule places the note beside the player bar, and it is in the 761px block (phones keep the note under the bar)');+ 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.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');assert.match(css, /@media\(min-width:601px\)\{\s*\.hb-head:has\(> \.hb-lesson\)\{display:grid/, 'from 601px the lesson line shares the category row');});