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: Famous effects polish from the task reviews: YouTube's entry keeps Skeleton Loader alone, ChatGPT's says a short status word, pink-red and the year of each Seen on line never break apart, the top bar fits from 601px to 640px, the phone jump row leaves room for the focus ring, a jump adds a history step only for another entry, and Copy prompt tries the animation pages' hidden text box before asking for the copy keys; make-famous refuses a doubled end marker, a test builds every home card but the eight known refusals, the famous check fails on a hidden not-connected line, and the dates, pill, sitemap and llms.txt tests are stricter
matind9e47e0f01dd
diff --git a/famous/index.html b/famous/index.htmlindex de895626..fe00d146 100644--- a/famous/index.html+++ b/famous/index.html@@ -95,7 +95,7 @@ button{font:inherit;color:inherit}/* an entry: seen on, the title, what you see, the cards, the prompt and Copy prompt */.fx{margin-top:clamp(36px,5vw,56px);padding-top:clamp(36px,5vw,56px);border-top:1px solid var(--line);scroll-margin-top:16px}-.fx-seen{display:flex;flex-wrap:wrap;align-items:center;column-gap:.35em;font-size:15px;color:var(--muted)}+.fx-seen{font-size:15px;color:var(--muted)} /* a line breaks before the link or before "in", never before the year: a no-break space joins them */.fx-seen a{display:inline-flex;align-items:center;min-width:44px;min-height:44px;color:var(--ink);font-weight:700;text-decoration:underline;text-decoration-color:var(--line);text-underline-offset:5px}.fx h2{font-size:clamp(26px,3.2vw,36px);font-weight:800;line-height:1.1;letter-spacing:-.025em}.fx-what{margin-top:14px;max-width:68ch;font-size:17px;line-height:1.65;color:var(--ink-2)}@@ -157,7 +157,7 @@ button{font:inherit;color:inherit}.brand{gap:10px;font-size:15px}.mark{width:28px;height:28px}.pill{padding:7px 13px;font-size:13px}- .fx-jump{flex-wrap:nowrap;justify-content:flex-start;width:calc(100% + 2 * var(--gut));margin-inline:calc(-1 * var(--gut));padding-inline:var(--gut);overflow-x:auto;scrollbar-width:none}+ .fx-jump{flex-wrap:nowrap;justify-content:flex-start;width:calc(100% + 2 * var(--gut));margin-inline:calc(-1 * var(--gut));padding-inline:var(--gut);overflow-x:auto;scrollbar-width:none;padding-block:6px;margin-block:18px -6px} /* the row scrolls, so it keeps 6px above and below its links for the focus ring; its margins (24px less those 6px) leave everything where it was */.fx-jump a{flex:none}.fx-what{font-size:16px;line-height:1.6}.fx-what a{padding-block:14px} /* a link inside a sentence: its touch area grows to 44px without moving the lines */@@ -176,6 +176,7 @@ button{font:inherit;color:inherit}.fx-suggest{width:100%}.foot{flex-direction:column;align-items:flex-start}}+@media(min-width:601px) and (max-width:640px){.top .nav .lnk{padding:0 6px}} /* the two text links come back at 601px: up to 640px they are narrower, so the bar fits beside the logo */@media(max-width:360px){.tag{left:5px;top:5px;max-width:calc(100% - 10px);padding:3px 6px;font-size:10px}}@media(max-width:359px){.gh{display:none}}/* reduced motion: the cards do not lift and the message fades in place (the previews hold still: see the block below) */@@ -417,7 +418,7 @@ button{font:inherit;color:inherit}</nav><section class="fx" id="stripe-ribbon" aria-labelledby="stripe-ribbon-t" data-fx-site="Stripe" data-fx-start="loop">- <p class="fx-seen">Seen on <a href="https://stripe.com/" target="_blank" rel="noopener">stripe.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://stripe.com/" target="_blank" rel="noopener">stripe.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="stripe-ribbon-t" tabindex="-1">The twisting ribbon of light</h2><p class="fx-what">Behind the headline, a wide ribbon made of fine strands of glowing color slowly twists in depth, some strands sharp and others soft, as if filmed by a camera, under a fine grain. Before 2026 the same place held a flat band of blended colors that flowed like slow paint, the look <a href="../animations/07-ambient-background/mesh-gradient/">Mesh Gradient Animation</a> makes.</p><h3 class="fx-sub">Made with these animations</h3>@@ -432,7 +433,7 @@ button{font:inherit;color:inherit}</section><section class="fx" id="apple-scroll" aria-labelledby="apple-scroll-t" data-fx-site="Apple" data-fx-start="scroll">- <p class="fx-seen">Seen on <a href="https://www.apple.com/apple-vision-pro/" target="_blank" rel="noopener">apple.com/apple-vision-pro<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://www.apple.com/apple-vision-pro/" target="_blank" rel="noopener">apple.com/apple-vision-pro<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="apple-scroll-t" tabindex="-1">The headset that comes apart as you scroll</h2><p class="fx-what">About two thirds of the way down the page, the headset stays in the middle of the screen while you scroll: its parts rise out of it layer by layer, then it tips up to show its lenses, and scrolling back puts it together.</p><h3 class="fx-sub">Made with these animations</h3>@@ -446,7 +447,7 @@ button{font:inherit;color:inherit}</section><section class="fx" id="landonorris-reveal" aria-labelledby="landonorris-reveal-t" data-fx-site="Lando Norris" data-fx-start="hover">- <p class="fx-seen">Seen on <a href="https://landonorris.com/" target="_blank" rel="noopener">landonorris.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://landonorris.com/" target="_blank" rel="noopener">landonorris.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="landonorris-reveal-t" tabindex="-1">The liquid reveal under the pointer</h2><p class="fx-what">A large portrait stands in the middle of the screen. Wherever the pointer moves across his head, a soft, liquid-looking blob shows a second picture through it, his racing helmet, as if the portrait were being wiped away.</p><h3 class="fx-sub">Made with these animations</h3>@@ -461,7 +462,7 @@ button{font:inherit;color:inherit}</section><section class="fx" id="linear-intro" aria-labelledby="linear-intro-t" data-fx-site="Linear" data-fx-start="load">- <p class="fx-seen">Seen on <a href="https://linear.app/" target="_blank" rel="noopener">linear.app<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://linear.app/" target="_blank" rel="noopener">linear.app<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="linear-intro-t" tabindex="-1">The headline that comes into focus</h2><p class="fx-what">As the page opens, the headline comes in line by line, each line fading in while it rises a little and sharpens out of a soft blur; the short line under it and a small link follow the same way, then a large flat picture of the app fades in below.</p><h3 class="fx-sub">Made with these animations</h3>@@ -476,7 +477,7 @@ button{font:inherit;color:inherit}</section><section class="fx" id="apple-menu" aria-labelledby="apple-menu-t" data-fx-site="Apple" data-fx-start="press">- <p class="fx-seen">Seen on <a href="https://www.apple.com/" target="_blank" rel="noopener">apple.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://www.apple.com/" target="_blank" rel="noopener">apple.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="apple-menu-t" tabindex="-1">The menu that drops in, link by link</h2><p class="fx-what">On a phone, the two-line menu button folds into an X while the menu fills the screen and its links drop into place one after another. On a computer, pointing at a top item opens a panel that grows down from the bar, its links appearing in turn, while the page behind blurs.</p><h3 class="fx-sub">Made with these animations</h3>@@ -491,7 +492,7 @@ button{font:inherit;color:inherit}</section><section class="fx" id="wikipedia-previews" aria-labelledby="wikipedia-previews-t" data-fx-site="Wikipedia" data-fx-start="hover">- <p class="fx-seen">Seen on <a href="https://en.wikipedia.org/wiki/Animation" target="_blank" rel="noopener">en.wikipedia.org/wiki/Animation<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://en.wikipedia.org/wiki/Animation" target="_blank" rel="noopener">en.wikipedia.org/wiki/Animation<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="wikipedia-previews-t" tabindex="-1">Link previews</h2><p class="fx-what">On any article, rest the pointer on a link and, after a short pause, a small card with the linked article's first lines and picture fades in under the link, rising slightly into place; move away and it fades out.</p><h3 class="fx-sub">Made with these animations</h3>@@ -505,9 +506,9 @@ button{font:inherit;color:inherit}</section><section class="fx" id="chatgpt-reply" aria-labelledby="chatgpt-reply-t" data-fx-site="ChatGPT" data-fx-start="load">- <p class="fx-seen">Seen on <a href="https://chatgpt.com/" target="_blank" rel="noopener">chatgpt.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-14">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://chatgpt.com/" target="_blank" rel="noopener">chatgpt.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-14">2026</time></p><h2 id="chatgpt-reply-t" tabindex="-1">The answer that writes itself</h2>- <p class="fx-what">After you send a question, a small dot pulses until the reply starts; a model that works longer shows the word “Thinking” with a band of light sweeping across its letters. Then the answer arrives a few words at a time, as if typed live.</p>+ <p class="fx-what">After you send a question, a small dot pulses until the reply starts; a model that works longer shows a short status word with a band of light sweeping across its letters. Then the answer arrives a few words at a time, as if typed live.</p><h3 class="fx-sub">Made with these animations</h3><div class="fx-cards"><article class="card c7" data-slug="breathing-glow"><div class="stage"><div class="pv" aria-hidden="true"></div><span class="tag">The waiting dot</span></div><div class="meta"><h4 class="title"><a href="../animations/07-ambient-background/breathing-glow/">Breathing / Pulsing Glow</a></h4><p class="desc">A soft glow slowly grows and shrinks, like calm breathing. Best for idle states.</p></div></article>@@ -520,9 +521,9 @@ button{font:inherit;color:inherit}</section><section class="fx" id="x-heart" aria-labelledby="x-heart-t" data-fx-site="X" data-fx-start="press">- <p class="fx-seen">Seen on <a href="https://x.com/" target="_blank" rel="noopener">x.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-14">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://x.com/" target="_blank" rel="noopener">x.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-14">2026</time></p><h2 id="x-heart-t" tabindex="-1">The heart that bursts</h2>- <p class="fx-what">Press the heart and it shrinks for an instant, pops back a little too big and settles in pink-red, while a circle of color swells into a thin ring and small colored dots burst out and fade, all within about a second.</p>+ <p class="fx-what">Press the heart and it shrinks for an instant, pops back a little too big and settles in pink-⁠red, while a circle of color swells into a thin ring and small colored dots burst out and fade, all within about a second.</p><h3 class="fx-sub">Made with these animations</h3><div class="fx-cards"><article class="card c4" data-slug="heart-burst"><div class="stage"><div class="pv" aria-hidden="true"></div><span class="tag">Pop and dots</span></div><div class="meta"><h4 class="title"><a href="../animations/04-micro-interactions/heart-burst/">Heart / Like Burst</a></h4><p class="desc">The heart pops and fills as small hearts burst out. Best for like buttons.</p></div></article>@@ -534,7 +535,7 @@ button{font:inherit;color:inherit}</section><section class="fx" id="spotify-cards" aria-labelledby="spotify-cards-t" data-fx-site="Spotify" data-fx-start="hover">- <p class="fx-seen">Seen on <a href="https://open.spotify.com/" target="_blank" rel="noopener">open.spotify.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://open.spotify.com/" target="_blank" rel="noopener">open.spotify.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="spotify-cards-t" tabindex="-1">The play button that rises</h2><p class="fx-what">Point at an album or playlist card and the card lightens a shade while a round green play button fades in, rising a few pixels into the cover's bottom corner.</p><h3 class="fx-sub">Made with these animations</h3>@@ -548,13 +549,12 @@ button{font:inherit;color:inherit}</section><section class="fx" id="youtube-loading" aria-labelledby="youtube-loading-t" data-fx-site="YouTube" data-fx-start="load">- <p class="fx-seen">Seen on <a href="https://www.youtube.com/" target="_blank" rel="noopener">youtube.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://www.youtube.com/" target="_blank" rel="noopener">youtube.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="youtube-loading-t" tabindex="-1">Gray shapes while it loads</h2><p class="fx-what">Before the videos appear, gray boxes and bars in the shapes of thumbnails, round channel pictures and titles fill the page; then the real content takes their places.</p><h3 class="fx-sub">Made with these animations</h3><div class="fx-cards"><article class="card c4" data-slug="skeleton-loader"><div class="stage"><div class="pv" aria-hidden="true"></div><span class="tag">Gray shapes</span></div><div class="meta"><h4 class="title"><a href="../animations/04-micro-interactions/skeleton-loader/">Skeleton Loader</a></h4><p class="desc">Gray shapes hold the place of content while it loads. Best for feeds and cards.</p></div></article>- <article class="card c2" data-slug="fade-in-out"><div class="stage"><div class="pv" aria-hidden="true"></div><span class="tag">Content arrives</span></div><div class="meta"><h4 class="title"><a href="../animations/02-entrance-and-exit/fade-in-out/">Fade In / Fade Out</a></h4><p class="desc">Fades in to appear and fades out to leave. Best for pop-ups and tooltips.</p></div></article></div><h3 class="fx-sub">A prompt to build something similar</h3><div class="fx-pbox"><p class="fx-prompt">Add a loading state to <mark>[the grid or feed whose content loads]</mark>. While the content loads, show gray shapes in the sizes of what is coming, such as a picture box, a round avatar and two lines of text, and let them pulse gently between lighter and darker. When the content arrives, put it exactly where the shapes were and fade it in, so nothing on the page jumps. Show only as many shapes as fit the screen, fewer on phones, and stop the pulse as soon as the content is in. Tell screen readers that the content is loading. If the visitor has reduced motion turned on, keep the shapes still.</p></div>@@ -562,7 +562,7 @@ button{font:inherit;color:inherit}</section><section class="fx" id="pudding-chart" aria-labelledby="pudding-chart-t" data-fx-site="The Pudding" data-fx-start="scroll">- <p class="fx-seen">Seen on <a href="https://pudding.cool/2025/11/democracy/" target="_blank" rel="noopener">pudding.cool/2025/11/democracy<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://pudding.cool/2025/11/democracy/" target="_blank" rel="noopener">pudding.cool/2025/11/democracy<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="pudding-chart-t" tabindex="-1">The chart that changes as you read</h2><p class="fx-what">A chart of dots stays on screen while short paragraphs scroll past. As you scroll, the years go by and each year's dots pile up into the chart, the ones the story is about in bright color, and at some paragraphs the dots slide into a new chart; scrolling back undoes each step.</p><h3 class="fx-sub">Made with these animations</h3>@@ -576,7 +576,7 @@ button{font:inherit;color:inherit}</section><section class="fx" id="medium-top-bar" aria-labelledby="medium-top-bar-t" data-fx-site="Medium" data-fx-start="scroll">- <p class="fx-seen">Seen on <a href="https://medium.com/" target="_blank" rel="noopener">medium.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p>+ <p class="fx-seen">Seen on <a href="https://medium.com/" target="_blank" rel="noopener">medium.com<span class="sr"> (opens in a new tab)</span></a> in <time datetime="2026-10-13">2026</time></p><h2 id="medium-top-bar-t" tabindex="-1">The top bar that hides while you read</h2><p class="fx-what">On a phone, scroll down into an article and the top bar moves up out of the way with the text; scroll up a little and it comes back down.</p><h3 class="fx-sub">Made with these animations</h3>@@ -680,7 +680,8 @@ document.querySelectorAll('.fx .card[data-slug]').forEach(card=>{});// A link to an entry (the jump row, the skip link) brings the entry into view and gives its heading keyboard focus; under-// reduced motion it jumps instead of gliding. A click with Ctrl, Cmd, Shift or Alt, or another button, is left to the browser.+// reduced motion it jumps instead of gliding. The address names the entry, with a step in the history only when it named+// another one. A click with Ctrl, Cmd, Shift or Alt, or another button, is left to the browser.document.addEventListener('click',e=>{const a=e.target.closest('a[href^="#"]');if(!a||e.button||e.ctrlKey||e.metaKey||e.shiftKey||e.altKey)return;@@ -689,7 +690,7 @@ document.addEventListener('click',e=>{e.preventDefault();entry.scrollIntoView({behavior:reduce?'auto':'smooth',block:'start'});entry.querySelector('h2').focus({preventScroll:true});- try{history.pushState(null,'','#'+entry.id);}catch(err){}+ if(location.hash!=='#'+entry.id)try{history.pushState(null,'','#'+entry.id);}catch(err){}});// The prompts: on phones each shows five lines and "Show the full prompt", as on the animation pages.@@ -705,7 +706,8 @@ document.querySelectorAll('.fx-prompt').forEach(p=>{});// Copy prompt copies the prompt as shown, brackets included. It reads "Copied" for about two seconds and the home page's-// message shows; where the browser refuses the clipboard, the prompt is selected and the button asks for the copy keys.+// message shows. Where the browser refuses the clipboard or has none, a hidden text box copies it, as on the animation pages;+// only when that fails too is the prompt selected and the button asks for the copy keys.// Only the icon and the label's words change: the label is a live region, so a screen reader announces the change, and the// button's name always starts with what it shows and names its entry.const ICON_COPY='<svg class="i" viewBox="0 0 24 24" aria-hidden="true"><rect x="9" y="9" width="11" height="11" rx="2"/><path d="M5 15V5a2 2 0 0 1 2-2h10"/></svg>';@@ -728,21 +730,43 @@ function copyState(btn,kind){btn.setAttribute('aria-label',kind==='done'?'Copied the prompt for '+title:kind==='keys'?KEYS+': the prompt for '+title+' is selected':'Copy prompt for '+title);if(kind)btn._timer=setTimeout(()=>copyState(btn,''),kind==='done'?2000:4000);}+// The hidden text box of the animation pages' shared script: it holds the text, is selected and copied, then goes, and+// keyboard focus returns to the button. True when the browser copied.+function copyThroughTextBox(text,btn){+ const box=document.createElement('textarea');+ box.value=text;+ box.setAttribute('readonly','');+ box.style.position='fixed';+ box.style.top='-1000px';+ box.style.opacity='0';+ document.body.appendChild(box);+ box.focus({preventScroll:true});+ box.select();+ box.setSelectionRange(0,box.value.length);+ let copied=false;+ try{copied=document.execCommand('copy');}catch(err){copied=false;}+ box.remove();+ btn.focus({preventScroll:true});+ return copied;+}document.querySelectorAll('.fx .copy').forEach(btn=>btn.addEventListener('click',()=>{const prompt=btn.closest('section.fx').querySelector('.fx-prompt');const text=prompt.textContent.replace(/\s+/g,' ').trim();- const clip=navigator.clipboard;- (clip&&clip.writeText?clip.writeText(text):Promise.reject(new Error('no clipboard'))).then(()=>{+ const copied=()=>{copyState(btn,'done');toast('Prompt copied. Paste it into your AI assistant.');- },()=>{+ };+ const fallback=()=>{+ if(copyThroughTextBox(text,btn)){copied();return;}const range=document.createRange();range.selectNodeContents(prompt);const sel=getSelection();sel.removeAllRanges();sel.addRange(range);copyState(btn,'keys');- });+ };+ const clip=navigator.clipboard;+ if(clip&&clip.writeText)clip.writeText(text).then(copied,fallback);else fallback();}));</script></body>diff --git a/tests/famous.test.js b/tests/famous.test.jsindex e8f91ac3..a51b9364 100644--- a/tests/famous.test.js+++ b/tests/famous.test.js@@ -93,6 +93,9 @@ test('make-famous: the blocks go between their marker lines, a second run changeassert.ok(!once.includes('old css'), 'what was between the markers is gone');assert.throws(() => replaceBetween('no markers here', CSS_START, CSS_END, 'x'), /must each be there once/);assert.throws(() => replaceBetween(CSS_START + CSS_END + CSS_START, CSS_START, CSS_END, 'x'), /must each be there once/);+ assert.throws(() => replaceBetween(CSS_START + CSS_END + CSS_END, CSS_START, CSS_END, 'x'), /must each be there once/, 'an end marker written twice');+ assert.throws(() => replaceBetween(CSS_END + CSS_START + CSS_END, CSS_START, CSS_END, 'x'), /must each be there once/, 'an end marker before the start too');+ assert.throws(() => replaceBetween(CSS_END + CSS_START, CSS_START, CSS_END, 'x'), /must each be there once/, 'the end before the start');});// ---------- The page: its frame ----------@@ -223,6 +226,8 @@ test('the page script copies, falls back to the copy keys, shortens prompts on passert.ok(shared.includes(`'${words}'`), `as the animation pages do: "${words}"`);}assert.ok(script.includes("toast('Prompt copied. Paste it into your AI assistant.')") && HOME.includes("toast('Prompt copied. Paste it into your AI assistant.')"), 'the home page\'s message');+ assert.ok(script.includes("document.execCommand('copy')") && shared.includes("doc.execCommand('copy')"), 'where the clipboard is refused or missing, a hidden text box copies, as on the animation pages');+ assert.ok(script.indexOf("document.execCommand('copy')") < script.indexOf("copyState(btn,'keys')"), 'before the button asks for the copy keys');for (const words of ["'Copy prompt'", "'Copied'"]) assert.ok(script.includes(words), words);assert.ok(PAGE.includes('<div class="toast" id="toast" role="status" aria-live="polite">'), 'the message box');});@@ -242,6 +247,22 @@ test('the two preview blocks are what tools/make-famous.mjs writes from the homeassert.ok(buildFamous(ROOT)['famous/index.html'] === PAGE, `famous/index.html is out of date: run ${TOOL}`);});+// The cards of the home page whose previews this page cannot show: drawn by a script engine, or animated in SVG. Every other+// card builds, so a change to the home page that the tool cannot read (a card, a preview, its rules) fails here at once,+// before a card on this page needs it.+const REFUSED = ['counter-animation', 'scramble-text', 'text-on-path', 'canvas-particle-effect', 'gpgpu-particle-system', 'starfield', 'particle-constellation', 'flow-field'];+test('make-famous: on the real home page every card builds, but the eight whose previews need a script or animate in SVG', async () => {+ const { previewBlocks, homeConst } = await tool();+ const slugs = homeConst(HOME, 'CATS').flatMap(cat => cat.entries.map(([slug]) => slug));+ for (const slug of REFUSED) {+ assert.ok(slugs.includes(slug), `${slug} is a card on the home page`);+ assert.throws(() => previewBlocks(HOME, [slug]), /needs a script engine|animates in SVG/, `${slug} is refused`);+ }+ const rest = [...slugs.filter(slug => !REFUSED.includes(slug))]; // a plain array: CATS comes from the tool's vm context+ const { data } = previewBlocks(HOME, rest); // it throws when a card is not found, or a preview's markup or rules+ assert.deepEqual(data.split('\n').slice(1, -1).map(line => JSON.parse(line.match(/^("[a-z0-9-]+"):/)[1])), rest, 'one preview for every other card, in order');+});+// ---------- The page: entries, cards and prompts ----------const STARTS = ['loop', 'load', 'scroll', 'hover', 'press'];const words = s => s.split(/\s+/).filter(Boolean).length;@@ -268,8 +289,8 @@ test('every entry is written as the template says, so the tests below see it', (for (const e of ENTRIES) {test(`${e.id}: seen on its site in the year it was checked, a heading, what you see in 25 to 70 words and what starts it`, () => {- const seen = e.body.match(/<p class="fx-seen">Seen on <a href="(https:\/\/[^"]+)" target="_blank" rel="noopener">([^<]+)<span class="sr"> \(opens in a new tab\)<\/span><\/a> in <time datetime="((\d{4})-\d{2}-\d{2})">(\d{4})<\/time><\/p>/);- assert.ok(seen, 'Seen on: the site\'s address as a link that opens a new tab, then the year in a <time>');+ const seen = e.body.match(/<p class="fx-seen">Seen on <a href="(https:\/\/[^"]+)" target="_blank" rel="noopener">([^<]+)<span class="sr"> \(opens in a new tab\)<\/span><\/a> in <time datetime="((\d{4})-\d{2}-\d{2})">(\d{4})<\/time><\/p>/);+ assert.ok(seen, 'Seen on: the site\'s address as a link that opens a new tab, then "in", a no-break space (the year never starts a line) and the year in a <time>');const [, href, label, day, year, shown] = seen;assert.equal(label, href.replace(/^https:\/\//, '').replace(/^www\./, '').replace(/\/$/, ''), 'the link shows the address without https:// or www.');assert.equal(shown, year, 'the year shown is the year of the day checked');@@ -281,6 +302,7 @@ for (const e of ENTRIES) {assert.ok(what, 'what you see');const n = words(textOf(what[1]));assert.ok(n >= 25 && n <= 70, `what you see has ${n} words, not 25 to 70`);+ assert.ok(!/["“”]/.test(textOf(what[1])), 'what you see quotes no words: it says what shows in our own words');assert.ok(STARTS.includes(e.start), `data-fx-start "${e.start}" is one of ${STARTS.join(', ')}`);assert.ok(e.site.trim(), 'data-fx-site names the site');assert.ok(e.body.includes('<h3 class="fx-sub">Made with these animations</h3>') && e.body.includes('<h3 class="fx-sub">A prompt to build something similar</h3>'), 'its two parts');@@ -380,10 +402,23 @@ test('no visible text of the page holds a name or slogan the live check saw on atest(`each entry the live check covered is dated ${CHECKED_DAY}, the day it was checked`, () => {const present = ENTRIES.filter(e => CHECKED_IDS.includes(e.id));assert.ok(present.length > 0, 'the page holds some of the checked entries');- for (const e of present) assert.ok(e.body.includes(`<time datetime="${CHECKED_DAY}">`), `${e.id}: not dated ${CHECKED_DAY}`);+ for (const e of present) {+ const seen = e.body.match(/<p class="fx-seen">[\s\S]*?<\/p>/);+ assert.ok(seen, `${e.id}: a Seen on line`);+ const days = [...seen[0].matchAll(/<time datetime="([^"]*)">/g)].map(m => m[1]);+ assert.deepEqual(days, [CHECKED_DAY], `${e.id}: its Seen on line is dated ${CHECKED_DAY}`);+ }});-test('the page holds 10 to 12 entries, and its pill counts them', () => {+test('the page holds 10 to 12 entries, and its one pill counts them', () => {assert.ok(ENTRIES.length >= 10 && ENTRIES.length <= 12, `${ENTRIES.length} entries, not 10 to 12`);- assert.ok(PAGE.includes(`<p class="pill">${ENTRIES.length} effects from well-known websites</p>`), 'the pill gives the number of entries');+ assert.equal(count(MARKUP, 'class="pill"'), 1, 'one pill');+ assert.ok(MARKUP.includes(`<p class="pill">${ENTRIES.length} effects from well-known websites</p>`), 'the pill gives the number of entries');+});++test('from 601px to 640px the top bar\'s two text links are narrower, so the bar fits beside the logo', () => {+ const band = PAGE.match(/@media\(min-width:601px\) and \(max-width:640px\)\{([^{}]*)\{([^{}]*)\}\}/);+ assert.ok(band, 'a rule for that band');+ assert.equal(band[1], '.top .nav .lnk', 'for the two text links');+ assert.match(band[2], /^padding:0 \d+px$/, 'with less padding');});diff --git a/tests/pages.test.js b/tests/pages.test.jsindex 7c56a524..a29f4d0e 100644--- a/tests/pages.test.js+++ b/tests/pages.test.js@@ -642,11 +642,16 @@ test('the counts written in the issue template, the 404 page and the sitemap matconst template = read(path.join(ROOT, '.github/ISSUE_TEMPLATE/config.yml'));assert.equal(numberIn(template, /See all (\d+) techniques/), cards, 'config.yml: the link to the live handbook');assert.equal(numberIn(read(path.join(ROOT, '404.html')), />Browse all (\d+) animations</), cards, '404.html: the Browse all link');- // The sitemap lists two URLs more than the total: the home page and the Famous effects page, first and in that order.+ // The sitemap lists two URLs more than the total: the home page and the Famous effects page, first and in that order, each+ // address once.const sitemap = read(path.join(ROOT, 'sitemap.xml'));assert.equal(count(sitemap, '<url>'), cards + 2, 'sitemap.xml lists the home page, the Famous effects page and every animation');const LIVE = 'https://matinmonshizadeh.github.io/animation-handbook/';- assert.deepEqual([...sitemap.matchAll(/<loc>([^<]*)<\/loc>/g)].slice(0, 2).map(m => m[1]), [LIVE, `${LIVE}famous/`], 'the home page, then Famous effects');+ const locs = [...sitemap.matchAll(/<loc>([^<]*)<\/loc>/g)].map(m => m[1]);+ assert.deepEqual(locs.slice(0, 2), [LIVE, `${LIVE}famous/`], 'the home page, then Famous effects');+ assert.equal(new Set(locs).size, locs.length, 'each address once');+ const famousLine = sitemap.split('\n').find(line => line.includes(`<loc>${LIVE}famous/</loc>`)) || '';+ assert.match(famousLine, /<\/loc><lastmod>\d{4}-\d{2}-\d{2}<\/lastmod><changefreq>monthly<\/changefreq><priority>0\.8<\/priority><\/url>\s*$/, 'Famous effects: monthly, priority 0.8');});// GitHub Pages serves 404.html at every address it has no file for, at any depth, so a relative address in it woulddiff --git a/tests/skill.test.js b/tests/skill.test.jsindex 84ede1ca..65b4db2d 100644--- a/tests/skill.test.js+++ b/tests/skill.test.js@@ -195,7 +195,8 @@ test('llms.txt lists every card once, in the order of CATS, with its live addrestest('llms.txt links the Famous effects page with the page\'s own description, after the categories and before the skill files', () => {const text = read(path.join(ROOT, 'llms.txt'));- const lede = decode(read(path.join(ROOT, 'famous', 'index.html')).match(/<meta name="description" content="([^"]+)">/)[1]);+ // White space squeezed, as the tool writes it: a description written over two lines is still one line of llms.txt.+ const lede = decode(read(path.join(ROOT, 'famous', 'index.html')).match(/<meta name="description" content="([^"]+)">/)[1]).replace(/\s+/g, ' ').trim();const line = `- [Famous effects](${LIVE}famous/): ${lede}`;assert.equal(text.split('\n').filter(l => l === line).length, 1, `llms.txt has the line ${line}`);assert.ok(text.includes(`## Famous effects\n\n${line}\n`), 'under its own heading');diff --git a/tools/check-pages.mjs b/tools/check-pages.mjsindex 3373de75..836109cb 100644--- a/tools/check-pages.mjs+++ b/tools/check-pages.mjs@@ -8,10 +8,12 @@// also tries the tiles, the search and Show all and compares Copy prompt with every page's own; the phone run tries a// tile, the slim bar and long words; the reduced-motion run checks that nothing moves.// node tools/check-pages.mjs famous checks the Famous effects page (famous/) at the same six setups: overflow, small-// targets on phones (every link, chip, card and button), and the title, the lede and the not-connected line on the first-// screen. The desktop run also presses each jump link, watches each entry's previews move and presses each Copy prompt,-// once more with the clipboard refused; the reduced-motion run checks that nothing moves, that every preview holds a still-// frame that shows something and that a jump does not glide. Like home, it stores a star count first.+// targets on phones (every link, chip, card and button), room for the focus ring in the scrolling jump row, and the title,+// the lede and the not-connected line shown, and on the first screen. The desktop run also presses each jump link (the last+// one twice), watches each entry's previews move and presses each Copy prompt, then twice more with the clipboard refused+// or missing (the hidden text box copies; when it fails too, the prompt is selected); the reduced-motion run checks that+// nothing moves, that every preview holds a still frame that shows something and that a jump does not glide. Like home, it+// stores a star count first.// A folder with no index.html of its own stands for the page folders inside it. Each page is loaded at six screen// setups and prints one line for each (ok or FAIL); problems are printed and screenshots saved, by default into// a folder of its own in the temp folder, whose path is printed. Console warnings count as problems too (the page@@ -143,9 +145,11 @@ const homeCheck = firstScreen => `(() => {})()`;// Runs inside the Famous effects page (famous/). Returns its problems: overflow, small targets on phones (every link, chip,-// card and button, the site links and the link inside a sentence too), and the title, the lede and the not-connected line on-// the first screen (the setups marked firstScreen: 1280×800 and 375×812). A page with no entries is a problem of its own, so-// the desktop steps never pass on an empty page.+// card and button, the site links and the link inside a sentence too), a jump row that scrolls sideways (phones) with less+// than 6px above or below its links, where their focus ring (3px, 3px out) would be cut off, and the title, the lede and the+// not-connected line shown at every setup (hidden is a problem: the not-connected line is a legal requirement) and on the+// first screen (the setups marked firstScreen: 1280×800 and 375×812). A page with no entries is a problem of its own, so the+// desktop steps never pass on an empty page.const famousCheck = firstScreen => `(() => {const r = el => el.getBoundingClientRect();const phone = innerWidth <= 600;@@ -159,8 +163,14 @@ const famousCheck = firstScreen => `(() => {.map(el => el.tagName.toLowerCase() + (el.getAttribute('class') ? '.' + el.getAttribute('class').split(' ')[0] : '') + ' ' + Math.round(r(el).width) + 'x' + Math.round(r(el).height));if (small.length) problems.push('small targets: ' + small.join(', '));}+ const jump = document.querySelector('.fx-jump'), chip = jump && jump.querySelector('a');+ if (chip && getComputedStyle(jump).overflowX !== 'visible') {+ const room = [r(chip).top - r(jump).top, r(jump).bottom - r(chip).bottom].map(Math.round);+ if (Math.min(...room) < 6) problems.push('the jump row scrolls but leaves ' + room.join('px above and ') + 'px below its links: their focus ring is cut off');+ }for (const [what, el] of [['title', document.querySelector('h1')], ['lede', document.querySelector('.fx-lede')], ['not-connected line', document.querySelector('.fx-legal')]]) {if (!el) problems.push('no ' + what);+ else if (!el.getClientRects().length || !r(el).width || !r(el).height) problems.push('the ' + what + ' is hidden');else if (${firstScreen} && r(el).bottom > innerHeight) problems.push('the ' + what + ' is below the first screen');}return { problems };@@ -946,7 +956,7 @@ const scrollSettled = () => evaluate(`new Promise(done => { let last = scrollY,// Famous effects, desktop run: each link of the jump row, pressed as the keyboard presses it (focus, then activate) from the// top of the page, brings its entry's heading fully into the window, gives that heading keyboard focus and names the entry in-// the address.+// the address. Pressed again while the address names its entry, the last link adds no step to the history.async function famousJumpProblems() {const hrefs = await evaluate(`[...document.querySelectorAll('.fx-jump a')].map(a => a.getAttribute('href'))`);if (!hrefs.length) return ['no links in the jump row'];@@ -961,6 +971,11 @@ async function famousJumpProblems() {if (!got) problems.push(`jump to ${href}: no entry with that id, or no heading in it`);else if (!got.shown || !got.focus || got.hash !== href) problems.push(`jump to ${href}: ${JSON.stringify(got)}`);}+ const last = hrefs[hrefs.length - 1];+ const again = await evaluate(`(() => { const before = history.length, a = document.querySelector('.fx-jump a[href="${last}"]'); a.focus(); a.click();+ return { hash: location.hash, before, after: history.length }; })()`);+ await scrollSettled();+ if (again.hash !== last || again.after !== again.before) problems.push(`jump to ${last} again: ${JSON.stringify(again)} (expected the address ${last} and the same number of history steps)`);return problems;}@@ -1002,7 +1017,9 @@ async function famousPreviewProblems() {// Famous effects, desktop run: each entry's Copy prompt, pressed for real at its center (scrolled into view, the pointer moved// onto it, then a mouse press and release), puts exactly that entry's prompt on the clipboard (stubbed: a headless run cannot// grant it), reads "Copied", says so in its name and shows the message. Then the browser refuses the clipboard: the first-// entry's press selects its prompt and the button asks for Ctrl+C.+// entry's press copies through the hidden text box (its copy command stubbed to report what is selected), so the button reads+// "Copied" with the message, the text box is gone and keyboard focus is back on the button. Last, with no clipboard and the+// copy command failing, the second entry's press (the first's again on a page of one) selects its prompt and asks for Ctrl+C.async function famousCopyProblems() {const ids = await evaluate(`[...document.querySelectorAll('section.fx')].map(s => s.id)`);if (!ids.length) return ['no entries to copy'];@@ -1034,14 +1051,40 @@ async function famousCopyProblems() {})()`);if (!got.same || got.label !== 'Copied' || !got.named || !got.toast) problems.push(`${id}: Copy prompt ${JSON.stringify(got)}`);}- await evaluate(`(() => { navigator.clipboard.writeText = async () => { throw new DOMException('denied', 'NotAllowedError'); }; getSelection().removeAllRanges(); })()`);+ // Before each of the two presses below, the button is back to "Copy prompt" (its "Copied" lasts about two seconds) and the+ // message is put away, so the press has to bring its own.+ const idle = id => evaluate(`(async () => { const btn = document.querySelector('#${id} .copy');+ for (let i = 0; i < 100 && btn.textContent.trim() !== 'Copy prompt'; i++) await new Promise(r => setTimeout(r, 50));+ const t = document.getElementById('toast'); t.classList.remove('show'); t.querySelector('.toast-t').textContent = ''; getSelection().removeAllRanges(); })()`);+ await evaluate(`(() => { navigator.clipboard.writeText = async () => { throw new DOMException('denied', 'NotAllowedError'); };+ window.__boxGot = null;+ document.execCommand = command => { const el = document.activeElement;+ if (command === 'copy' && el && el.tagName === 'TEXTAREA') window.__boxGot = el.value.slice(el.selectionStart, el.selectionEnd);+ return command === 'copy'; }; })()`);+ await idle(ids[0]);const trouble = await press(ids[0]);if (trouble) problems.push(`${ids[0]}, clipboard refused: ${trouble}`);else {- const refused = await evaluate(`(async () => { const btn = document.querySelector('#${ids[0]} .copy');+ const boxed = await evaluate(`(async () => { const btn = document.querySelector('#${ids[0]} .copy'), title = document.querySelector('#${ids[0]} h2').textContent;+ for (let i = 0; i < 60 && window.__boxGot === null; i++) await new Promise(r => setTimeout(r, 50));+ await new Promise(r => setTimeout(r, 50));+ return { same: window.__boxGot === ${prompt(ids[0])}, label: btn.textContent.trim(), named: (btn.getAttribute('aria-label') || '') === 'Copied the prompt for ' + title,+ toast: document.getElementById('toast').classList.contains('show') && document.querySelector('#toast .toast-t').textContent === 'Prompt copied. Paste it into your AI assistant.',+ boxGone: !document.querySelector('textarea'), focus: document.activeElement === btn }; })()`);+ if (!boxed.same || boxed.label !== 'Copied' || !boxed.named || !boxed.toast || !boxed.boxGone || !boxed.focus) {+ problems.push(`${ids[0]}, clipboard refused: ${JSON.stringify(boxed)} (expected the hidden text box to copy the prompt, "Copied" and the message)`);+ }+ }+ const last = ids[1] || ids[0];+ await evaluate(`(() => { Object.defineProperty(navigator, 'clipboard', { value: undefined, configurable: true }); document.execCommand = () => false; })()`);+ await idle(last);+ const trouble2 = await press(last);+ if (trouble2) problems.push(`${last}, no clipboard: ${trouble2}`);+ else {+ const keys = await evaluate(`(async () => { const btn = document.querySelector('#${last} .copy');for (let i = 0; i < 60 && !btn.textContent.includes('Ctrl+C'); i++) await new Promise(r => setTimeout(r, 50));- return { label: btn.textContent.trim(), selected: getSelection().toString().replace(/\\s+/g, ' ').trim() === ${prompt(ids[0])} }; })()`);- if (refused.label !== 'Press Ctrl+C to copy' || !refused.selected) problems.push(`${ids[0]}, clipboard refused: ${JSON.stringify(refused)} (expected "Press Ctrl+C to copy" and the prompt selected)`);+ return { label: btn.textContent.trim(), selected: getSelection().toString().replace(/\\s+/g, ' ').trim() === ${prompt(last)} }; })()`);+ if (keys.label !== 'Press Ctrl+C to copy' || !keys.selected) problems.push(`${last}, no clipboard and the text box failing: ${JSON.stringify(keys)} (expected "Press Ctrl+C to copy" and the prompt selected)`);}return problems;}diff --git a/tools/make-famous.mjs b/tools/make-famous.mjsindex bafb1d7e..fc692a07 100644--- a/tools/make-famous.mjs+++ b/tools/make-famous.mjs@@ -189,8 +189,9 @@ export function previewBlocks(home, slugs) {// The text with what lies between the start and end marker lines replaced by inner (each marker there once, in that order).export function replaceBetween(text, start, end, inner) {- const a = text.indexOf(start), b = a < 0 ? -1 : text.indexOf(end, a + start.length);- if (a < 0 || b < 0 || text.indexOf(start, a + start.length) >= 0) throw new Error(`famous/index.html: the lines "${start}" and "${end}" must each be there once, in that order`);+ const once = marker => text.indexOf(marker) >= 0 && text.indexOf(marker) === text.lastIndexOf(marker);+ const a = text.indexOf(start), b = text.indexOf(end);+ if (!once(start) || !once(end) || b < a + start.length) throw new Error(`famous/index.html: the lines "${start}" and "${end}" must each be there once, in that order`);return text.slice(0, a + start.length) + '\n' + inner + '\n' + text.slice(b);}// The slugs of the page's cards, in page order.diff --git a/tools/make-skill.mjs b/tools/make-skill.mjsindex 8f032b30..a07b4ac1 100644--- a/tools/make-skill.mjs+++ b/tools/make-skill.mjs@@ -14,8 +14,9 @@// a note. From the page's README.md it reads the Key parameters table (name | default | effect): each setting's line// ends with the effect of the row named like the setting on the page, and a page without settings lists every row, the// demo's own values.-// It also reads the Famous effects page's description (the meta description of famous/index.html): llms.txt lists that-// page after the categories.+// It also reads the Famous effects page's description (the meta description of famous/index.html, entities decoded and+// white space squeezed, so a description written over two lines stays one line): llms.txt lists that page after the+// categories.// It writes skills/animation-handbook/SKILL.md, skills/animation-handbook/references/catalog.md, one// skills/animation-handbook/references/<category folder>.md per category, and llms.txt at the root. Each is written with// LF line endings, and only when its text changed; it prints every file with its size. Running it twice changes@@ -418,7 +419,7 @@ export function buildSkill(root) {...cat.entries.map(([slug, name, desc]) => `- [${name}](${base}${cat.folder.replace(/\/$/, '')}/${slug}/): ${desc}`), '']),// The Famous effects page: effects seen on well-known websites, each with the animations that make something similar.'## Famous effects', '',- `- [Famous effects](${base}famous/): ${decode(famousLede, 'famous/index.html')}`, '',+ `- [Famous effects](${base}famous/): ${squeeze(decode(famousLede, 'famous/index.html'))}`, '',// The skill's own files, which the site serves as they are: every prompt and setting, as Markdown.'## Skill files', '',`- [SKILL.md](${base}${SKILL}/SKILL.md): how to find a technique, choose its settings for the user's page and build it, with the rules for real pages`,