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: home search: a word also finds the cards that use another word for it (bounce, spring, elastic; click, press, tap; …), so the search box's own example puts Button Press Scale first
matin50f5d4ea0ea7
diff --git a/docs/superpowers/specs/2026-09-30-home-page-redesign-design.md b/docs/superpowers/specs/2026-09-30-home-page-redesign-design.mdindex d4e64980..db4ce4ed 100644--- a/docs/superpowers/specs/2026-09-30-home-page-redesign-design.md+++ b/docs/superpowers/specs/2026-09-30-home-page-redesign-design.md@@ -92,8 +92,14 @@ match "bounce" (a typed word drops the first of the endings "ies", "ing", "ed",letters with a vowel, but not the last "s" of "ss"; after "ing" or "ed", a doubled last letter other than l, s, f or zloses one letter while three remain: "snapping" finds "snap", "ring" stays whole). An animation matches when at leastone word matches; results are ordered by how well they match (a word in the name counts 3, in a place name 2, in the-description 1), ties in home order. "a button that bounces when clicked" therefore puts Click / Tap Ripple, Bounce In-and the other button animations at the top.+description 1).+A short list of everyday words that mean the same here lets a word find a card that uses another word for it: bounce,+spring, elastic; click, press, tap; parallax, depth; mouse, pointer; shake, wobble, wiggle, jiggle; loader, loading;+popup, modal, dialog. A card that does not have the typed word but has another word of its group gets a third of what+the typed word would count, once, in the best place it is found, so for a single word it comes after every card that+has the word itself. Ties go to the animation with more of the typed words themselves, then to home order. "a button+that bounces when clicked" therefore puts Button Press Scale first (it "springs back" as you "press" it), then Magnetic+Button, Click / Tap Ripple and the other button animations, with Bounce In on the first page of results.The "/" key focuses the search and Escape clears it, as today.## Cardsdiff --git a/index.html b/index.htmlindex 9abc0303..394d9eb2 100644--- a/index.html+++ b/index.html@@ -2380,20 +2380,30 @@ function stem(w){return w;}function queryWords(text){return [...new Set(keyWords(text).map(stem))];}+// Everyday words that mean the same here, each written as the start of its words (bounc: bounce, bouncy, bouncing). A typed+// word that starts with one of them also finds the cards that use another word of its group, so "a button that bounces when+// clicked" finds Button Press Scale, which "springs back" as you "press" it.+const SAME=[['bounc','spring','elastic'],['click','press','tap'],['parallax','depth'],['mouse','pointer'],+ ['shak','wobbl','wiggl','jiggl'],['loader','loading'],['popup','modal','dialog']];// A word counts 3 in the name, 2 in a place name, 1 in the description or category; each is matched by the start of a word.+// A card without the typed word but with another word of its group gets a third of that, once, where it counts most, so for+// one word it never passes a card that has the word itself. The score is kept in thirds, so it stays a whole number; own is+// the score of the typed words alone, and breaks ties.function score(e,words){- let s=0;+ const lists=[[e.nameW,3],[e.placeW,2],[e.descW,1]];+ let s=0,own=0;for(const w of words){- if(e.nameW.some(x=>x.startsWith(w)))s+=3;- if(e.placeW.some(x=>x.startsWith(w)))s+=2;- if(e.descW.some(x=>x.startsWith(w)))s+=1;+ const word=lists.reduce((n,[list,k])=>n+(list.some(x=>x.startsWith(w))?k:0),0);+ const group=SAME.filter(g=>g.some(start=>w.startsWith(start))).flat();+ s+=word?3*word:Math.max(0,...lists.map(([list,k])=>list.some(x=>group.some(start=>x.startsWith(start)))?k:0));+ own+=word;}- return s;+ return {s,own};}function search(text){const words=queryWords(text);if(!words.length)return [];- return ALL.map(e=>({e,s:score(e,words)})).filter(x=>x.s>0).sort((a,b)=>b.s-a.s||a.e.order-b.e.order).map(x=>x.e);+ return ALL.map(e=>({e,...score(e,words)})).filter(x=>x.s>0).sort((a,b)=>b.s-a.s||b.own-a.own||a.e.order-b.e.order).map(x=>x.e);}// All animations: a plain section per group, headed by an h3 (a section with no name adds no landmark). The card titles are// h3 too, so here they are set a level below the group headings; showCards() takes that away again.diff --git a/tests/pages.test.js b/tests/pages.test.jsindex 5564790d..2c51a68e 100644--- a/tests/pages.test.js+++ b/tests/pages.test.js@@ -555,6 +555,62 @@ test('a typed word loses its ending by the rule in the spec', () => {assert.deepEqual(Object.fromEntries(Object.keys(want).map(word => [word, stem(word)])), want);});+// The home page's search as the page runs it: the cards and their word lists built by the page's own code (from PLACE_LIST+// up to BY_SLUG), then its search functions, in one context with the page's CATS, PLACES and SAME.+function homeSearch() {+ const at = marker => { const i = HOME.indexOf(marker); assert.ok(i >= 0, `${marker} in index.html`); return i; };+ const context = vm.createContext({ CATS: homeConst('CATS'), PLACES: homeConst('PLACES'), SAME: homeConst('SAME') });+ vm.runInContext(HOME.slice(at('const PLACE_LIST=['), at('const BY_SLUG=')), context);+ for (const name of ['stem', 'queryWords', 'score', 'search']) {+ const start = at(`function ${name}(`);+ vm.runInContext(HOME.slice(start, blockEnd(HOME.indexOf('{', start)) + 1), context);+ }+ return context;+}++test('the search finds what a visitor describes, and each Popular suggestion keeps its first result', () => {+ const page = homeSearch(), names = text => page.search(text).map(e => e.name);+ const shown = Number(HOME.match(/const PAGE=(\d+);/)[1]);+ // The search box's own example: a button that springs back as it is pressed comes first, and Bounce In is on the first page.+ const example = HOME.match(/<input id="q"[^>]* placeholder="For example: ([^"]+)">/)[1];+ const found = names(example);+ assert.equal(found[0], 'Button Press Scale', `"${example}": ${found.slice(0, shown).join(', ')}`);+ assert.ok(found.slice(0, shown).includes('Bounce In'), `"${example}" shows Bounce In on the first page: ${found.slice(0, shown).join(', ')}`);+ const first = { 'text that types itself': 'Typewriter Effect', 'loading spinner': 'Loading Spinner', 'background with moving stars': 'Starfield / Space Particles',+ 'confetti when done': 'Success Confetti', 'menu that slides in': 'Drawer / Panel Slide', fade: 'Fade In / Fade Out' };+ for (const [text, name] of Object.entries(first)) assert.equal(names(text)[0], name, `"${text}": ${names(text).slice(0, 5).join(', ')}`);+ // A Parallax card first, and the two cards that fake depth without the word parallax come too.+ const parallax = names('parallax');+ assert.match(parallax[0], /Parallax/, `"parallax": ${parallax.join(', ')}`);+ for (const name of ['2.5D / Pseudo-3D', 'Depth-Map Photo']) assert.ok(parallax.includes(name), `"parallax" finds ${name}: ${parallax.join(', ')}`);+ const change = page.search('page change animation')[0];+ assert.equal(change.cat.name, 'Page Transitions', `"page change animation": ${change.name} first`);+ // The Popular suggestions, in the hero and in the Nothing-found panel, each with the first result it had before SAME.+ const popular = { 'fade in': 'Fade In / Fade Out', 'typing text': 'Kinetic Typography', 'loading spinner': 'Loading Spinner', parallax: 'Parallax Depth-of-Field',+ confetti: 'Success Confetti' };+ for (const panel of [between(HOME, '<p class="pop"><span>Popular:</span>', '</p>'), between(HOME, '<div class="empty" id="empty"', '</div>')]) {+ assert.deepEqual([...panel.matchAll(/data-q="([^"]*)"/g)].map(m => m[1]), Object.keys(popular), 'the Popular suggestions');+ }+ for (const [text, name] of Object.entries(popular)) assert.equal(names(text)[0], name, `"${text}": ${names(text).slice(0, 5).join(', ')}`);+});++test('a typed word also finds the cards that use another word of its group, after every card that has the word itself', () => {+ const page = homeSearch(), names = text => page.search(text).map(e => e.name);+ // Words a visitor may type that no card uses.+ for (const [text, name] of [['wobble', 'Error Shake'], ['popup', 'Modal Expand'], ['mouse', 'Cursor Follower'], ['loader', 'Loading Spinner']]) {+ assert.ok(names(text).includes(name), `"${text}" finds ${name}: ${names(text).join(', ')}`);+ }+ // Each word of every group, typed alone: the cards with the typed word itself come first, then the ones found through the group.+ for (const text of homeConst('SAME').flat()) {+ const [word] = page.queryWords(text), has = e => [...e.nameW, ...e.placeW, ...e.descW].some(x => x.startsWith(word));+ const found = page.search(text), others = found.findIndex(e => !has(e));+ assert.ok(others < 0 || found.slice(others).every(e => !has(e)), `"${text}": ${found.map(e => e.name + (has(e) ? '' : ' (group)')).join(', ')}`);+ }+ for (const [text, name] of [['tap', 'Click / Tap Ripple'], ['click', 'Click / Tap Ripple'], ['elastic', 'Elastic Transition'], ['springy', 'Bounce In']]) {+ assert.equal(names(text)[0], name, `"${text}": ${names(text).join(', ')}`);+ }+});+test('every place has one tile, one phone-bar chip and one count, and the markup names no other place', () => {// The opening tags of the page's markup: scripts, styles and comments left out.const tags = HOME.replace(/<script\b[\s\S]*?<\/script>|<style\b[\s\S]*?<\/style>|<!--[\s\S]*?-->/g, '').match(/<[a-z][^>]*>/g);