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
feat: a 404 page in the site's look sends a mistyped address on its way: capitals to the lowercase path, a category folder to Browse all, and anything else to the search with its words filled in
matinf3560698d0fe
diff --git a/404.html b/404.htmlnew file mode 100644index 00000000..8f18ef86--- /dev/null+++ b/404.html@@ -0,0 +1,126 @@+<!DOCTYPE html>+<html lang="en">+<head>+<meta charset="UTF-8">+<meta name="viewport" content="width=device-width, initial-scale=1.0">+<title>Page not found — Animation Handbook</title>+<meta name="robots" content="noindex">+<meta name="theme-color" content="#f8f7f4">+<!-- GitHub Pages serves this page at every address it has no file for, at any depth, so every address here is absolute. -->+<link rel="icon" type="image/png" sizes="96x96" href="/animation-handbook/favicon.png">+<link rel="icon" type="image/svg+xml" href="/animation-handbook/favicon.svg">+<link rel="apple-touch-icon" href="/animation-handbook/apple-touch-icon.png">+<script>+// The theme is the visitor's own pick on the home page (ah-theme), else the system's, as on the home page.+(function(){var t=matchMedia('(prefers-color-scheme: light)').matches?'light':'dark';+ try{var s=localStorage.getItem('ah-theme');if(s==='light'||s==='dark')t=s;}catch(e){}+ document.documentElement.dataset.theme=t;document.querySelector('meta[name="theme-color"]').content=t==='dark'?'#0e0e11':'#f8f7f4';})();+// Where a missing address leads: {go} to move on at once, else {words} for the search box. rest is the address's query+// and fragment. GitHub Pages tells capital letters from small ones, so an address with capitals moves to its lowercase+// path (percent escapes keep their case, so a lowercase path never moves again). /animations/ and a category folder have+// no page of their own: they open Browse all. Any other address offers the words of its last part ("rotate-inn" gives+// "rotate inn"), skipping an index or readme file; a part with no letters offers none.+function whereTo(path,rest){+ var lower=path.replace(/%[0-9A-Fa-f]{2}|[A-Z]+/g,function(s){return s.charAt(0)==='%'?s:s.toLowerCase();});+ if(/^\/animation-handbook\/animations(\/\d\d-[a-z0-9-]+)?(\/(index\.html?)?)?$/.test(lower))return {go:'/animation-handbook/?view=all#results'};+ if(lower!==path)return {go:lower+(rest||'')};+ var parts=path.split('/').filter(Boolean);+ if(parts[0]==='animation-handbook')parts.shift();+ var last=parts.pop()||'';+ if(/^(index|readme)(\.[a-z]+)?$/i.test(last))last=parts.pop()||'';+ try{last=decodeURIComponent(last);}catch(e){}+ var words=last.replace(/\.[a-z]+$/i,'').replace(/[-_+.\s]+/g,' ').trim().slice(0,80);+ return {words:/[^\d\s]/.test(words)?words:''};+}+var to=whereTo(location.pathname,location.search+location.hash);+if(to.go)location.replace(to.go);+else document.addEventListener('DOMContentLoaded',function(){var q=document.getElementById('q');if(to.words&&!q.value)q.value=to.words;});+</script>+<style>+@font-face{font-family:'Schibsted Grotesk';src:url('/animation-handbook/assets/fonts/schibsted-latin-ext.woff2') format('woff2');font-weight:400 900;font-display:swap;unicode-range:U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF}+@font-face{font-family:'Schibsted Grotesk';src:url('/animation-handbook/assets/fonts/schibsted-latin.woff2') format('woff2');font-weight:400 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD}++/* the home page's colors: light, then dark by the system's setting (no script) or by data-theme */+:root{+ --bg:#f8f7f4;--surface:#ffffff;--ink:#16161b;--ink-2:#45454f;--muted:#676771;--line:#e5e3dc;--brand:#2f5bea;+ --shadow:0 1px 2px rgba(22,22,27,.04),0 8px 24px rgba(22,22,27,.06);+ --text:'Schibsted Grotesk',system-ui,-apple-system,'Segoe UI',sans-serif;--gut:clamp(16px,4vw,40px);+ color-scheme:light;+}+@media(prefers-color-scheme:dark){:root:not([data-theme="light"]){+ --bg:#0e0e11;--surface:#17171c;--ink:#f4f4f2;--ink-2:#c6c6cc;--muted:#9c9ca5;--line:rgba(255,255,255,.13);--brand:#86a8ff;+ --shadow:0 1px 2px rgba(0,0,0,.3),0 8px 24px rgba(0,0,0,.25);color-scheme:dark;+}}+:root[data-theme="dark"]{+ --bg:#0e0e11;--surface:#17171c;--ink:#f4f4f2;--ink-2:#c6c6cc;--muted:#9c9ca5;--line:rgba(255,255,255,.13);--brand:#86a8ff;+ --shadow:0 1px 2px rgba(0,0,0,.3),0 8px 24px rgba(0,0,0,.25);color-scheme:dark;+}+*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}+html,body{background:var(--bg);color:var(--ink)}+body{display:flex;flex-direction:column;min-height:100vh;min-height:100svh;font-family:var(--text);font-size:16px;line-height:1.5;-webkit-font-smoothing:antialiased}+a{color:inherit}+button,input{font:inherit;color:inherit}+:focus-visible{outline:3px solid var(--brand);outline-offset:3px}+.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}+.i{width:18px;height:18px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}+.wrap{width:min(1280px,calc(100% - 2 * var(--gut)));margin-inline:auto}++/* top bar */+.top{display:flex;align-items:center;min-height:76px}+.brand{display:inline-flex;align-items:center;gap:12px;min-height:44px;text-decoration:none;font-size:17px;font-weight:800;letter-spacing:-.015em;white-space:nowrap}+.mark{width:30px;height:30px;flex:none}+.mark .ring{fill:var(--bg);stroke:currentColor;stroke-width:1.8}+.mark .ball{fill:currentColor}++/* the message, the search and the ways back */+.lost{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:clamp(24px,6vw,64px) 0 clamp(48px,10vw,112px);text-align:center}+.pill{padding:8px 16px;border-radius:999px;background:var(--surface);border:1px solid var(--line);font-size:14px;font-weight:600;color:var(--ink-2)}+.h1{margin-top:22px;font-size:clamp(32px,5.2vw,56px);font-weight:800;line-height:1.06;letter-spacing:-.035em}+.sub{margin-top:16px;max-width:560px;font-size:clamp(16px,1.4vw,19px);line-height:1.55;color:var(--ink-2);text-wrap:pretty}+.search{display:flex;align-items:center;width:min(640px,100%);margin-top:clamp(20px,3vw,32px);padding:8px 8px 8px 24px;border-radius:999px;background:var(--surface);border:1px solid var(--line);box-shadow:var(--shadow)}+.search:focus-within{border-color:var(--brand);box-shadow:0 0 0 3px color-mix(in srgb,var(--brand) 22%,transparent),var(--shadow)}+.search>.i{width:22px;height:22px;color:var(--muted)}+#q{flex:1;min-width:0;min-height:48px;margin-left:12px;border:0;background:none;font-size:17px;text-overflow:ellipsis;outline:none;-webkit-appearance:none;appearance:none}+#q::placeholder{color:var(--muted)}+#q:focus-visible{outline:none}+.go{display:inline-flex;align-items:center;justify-content:center;flex:none;min-height:48px;padding:0 26px;border-radius:999px;border:0;background:var(--ink);color:var(--bg);font-size:16px;font-weight:700;cursor:pointer}+.go .i{display:none}+.ways{display:flex;flex-wrap:wrap;justify-content:center;gap:12px;margin-top:24px}+.way{display:inline-flex;align-items:center;justify-content:center;min-height:48px;padding:0 22px;border-radius:999px;border:1px solid var(--line);background:var(--surface);font-size:16px;font-weight:700;text-decoration:none}+@media(hover:hover){.way:hover{border-color:var(--ink)}}++/* phone */+@media(max-width:600px){+ .top{min-height:60px}+ .brand{gap:10px;font-size:15px}+ .mark{width:28px;height:28px}+ .search{padding:5px 5px 5px 18px}+ #q{min-height:44px;margin-left:10px;font-size:16px}+ .go{width:44px;min-height:44px;padding:0}+ .go-l{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap} /* hidden from sight, still read out */+ .go .i{display:block}+ .ways{flex-direction:column;align-self:stretch}+}+</style>+</head>+<body>+<header class="wrap top">+ <a class="brand" href="/animation-handbook/"><svg class="mark" viewBox="0 0 32 32" aria-hidden="true"><circle class="ring" cx="11.16" cy="20.84" r="6.1"/><circle class="ring" cx="15.12" cy="16.88" r="6.1"/><circle class="ring" cx="18.51" cy="13.49" r="6.1"/><circle class="ball" cx="21.2" cy="10.8" r="6.6"/></svg><span>Animation Handbook</span></a>+</header>+<main class="wrap lost">+ <p class="pill">Error 404</p>+ <h1 class="h1">This page isn't here</h1>+ <p class="sub">The link may be old or mistyped. Search for the animation you were after, or browse them all.</p>+ <form class="search" role="search" action="/animation-handbook/#results" method="get">+ <label class="sr" for="q">Describe the animation you want</label>+ <svg class="i" viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7"/><path d="M20 20l-3.5-3.5"/></svg>+ <input id="q" name="q" type="search" enterkeyhint="search" autocomplete="off" spellcheck="false" placeholder="For example: a button that bounces when clicked">+ <button type="submit" class="go"><span class="go-l">Search</span><svg class="i" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6"/></svg></button>+ </form>+ <nav class="ways" aria-label="Ways back">+ <a class="way" href="/animation-handbook/">Go to the home page</a>+ <a class="way" href="/animation-handbook/?view=all#results">Browse all 166 animations</a>+ </nav>+</main>+</body>+</html>diff --git a/tests/pages.test.js b/tests/pages.test.jsindex ea88eb16..3b701ef8 100644--- a/tests/pages.test.js+++ b/tests/pages.test.js@@ -474,15 +474,28 @@ test('the counts written in the root README match the cards', () => {}});-test('the counts written in the issue template and the sitemap match the cards', () => {+test('the counts written in the issue template, the 404 page and the sitemap match the cards', () => {const cards = totalCards();const 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 one URL more than the total: the home page.const urls = count(read(path.join(ROOT, 'sitemap.xml')), '<url>');assert.equal(urls, cards + 1, 'sitemap.xml lists the home page and every animation');});+// GitHub Pages serves 404.html at every address it has no file for, at any depth, so a relative address in it would+// point somewhere else from every one: each link, icon, font and the search form use an absolute one.+test('the 404 page stays out of search results and every address in it works at any depth', () => {+ const file = path.join(ROOT, '404.html');+ assert.ok(fs.existsSync(file), '404.html is at the root');+ const html = read(file);+ assert.ok(html.includes('<meta name="robots" content="noindex">'), 'noindex');+ const addresses = [...html.matchAll(/\s(?:href|src|action)="([^"]*)"/g), ...html.matchAll(/url\(\s*['"]?([^'")\s]+)/g)].map(m => m[1]);+ assert.ok(addresses.length > 0, 'the page has addresses to check');+ for (const address of addresses) assert.match(address, /^(?:\/animation-handbook\/|https:\/\/|#)/, address);+});+// Where the bracket that opens at HOME[from] ('[' or '{') is closed. It steps over strings and // comments, so a quote or bracket// inside either does not count.function blockEnd(from) {