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: add the shared demo layout and fonts, and convert Bounce In
matin9579a4237f56
diff --git a/animations/02-entrance-and-exit/bounce-in/index.html b/animations/02-entrance-and-exit/bounce-in/index.htmlindex 197bbd7c..aa9b1898 100644--- a/animations/02-entrance-and-exit/bounce-in/index.html+++ b/animations/02-entrance-and-exit/bounce-in/index.html@@ -21,11 +21,7 @@<meta name="twitter:image" content="https://matinmonshizadeh.github.io/animation-handbook/og-image.png"><script type="application/ld+json">{"@context": "https://schema.org", "@type": "TechArticle", "headline": "Bounce In", "name": "Bounce In", "description": "Overshoots final position then springs back — implemented with explicit @keyframes waypoints, not easing alone.", "url": "https://matinmonshizadeh.github.io/animation-handbook/animations/02-entrance-and-exit/bounce-in/", "inLanguage": "en", "articleSection": "Entrance & Exit", "isPartOf": {"@type": "WebSite", "name": "Animation Handbook", "url": "https://matinmonshizadeh.github.io/animation-handbook/"}, "author": {"@type": "Person", "name": "matinmonshizadeh"}, "keywords": "web animation, CSS animation, Entrance & Exit, Bounce In"}</script><style>- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-700.woff2') format('woff2');font-weight:700;font-display:swap}- @font-face{font-family:'Bricolage';src:url('../../../assets/fonts/brico-800.woff2') format('woff2');font-weight:800;font-display:swap}- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-400.woff2') format('woff2');font-weight:400;font-display:swap}- @font-face{font-family:'PlexMono';src:url('../../../assets/fonts/plex-500.woff2') format('woff2');font-weight:500;font-display:swap}- :root{--bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-accent:#5fd88a;--ui-text:#f4f4f2;--ui-muted:#77777e;--disp:'Bricolage','Arial Narrow',sans-serif;--mono:'PlexMono',ui-monospace,Menlo,Consolas,monospace;--stage-h:620px;--dur:1100ms}+ :root{--bg:#0b0b0d;--ui-bg:#111114;--ui-border:rgba(255,255,255,.09);--ui-accent:#5fd88a;--ui-text:#f4f4f2;--ui-muted:#77777e;--stage-h:620px;--dur:1100ms}*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}body{background:var(--bg);color:var(--ui-text);font-family:var(--mono);-webkit-font-smoothing:antialiased;padding:clamp(12px,3vw,24px)}header{margin-bottom:20px}@@ -65,27 +61,12 @@@media(max-width:600px){.layout{flex-direction:column}.stage{flex:none;width:100%}aside{width:100%}:root{--stage-h:480px}}</style><style id="kf-style"></style>-<style id="ah-inject">-:root{--ah-bg:rgba(17,17,20,.82);--ah-line:rgba(255,255,255,.1);--ah-ink:#f4f4f2;--ah-muted:#9a9aa2;--ah-accent:#6ea8ff}-body{padding-top:46px}-.ah-bar{position:fixed;top:0;left:0;right:0;height:46px;z-index:2147483000;display:flex;align-items:center;justify-content:space-between;gap:10px;padding:0 clamp(10px,3vw,18px);background:var(--ah-bg);backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);border-bottom:1px solid var(--ah-line);font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12px;box-sizing:border-box}-.ah-bar a,.ah-bar button{color:var(--ah-muted);text-decoration:none;background:none;border:0;font:inherit;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-height:34px;padding:0 7px;border-radius:6px;transition:color .18s,background .18s;white-space:nowrap}-.ah-bar a:hover,.ah-bar button:hover{color:var(--ah-ink)}-.ah-home{color:var(--ah-ink);font-weight:600}-.ah-actions{display:flex;align-items:center;gap:2px}-.ah-sep{width:1px;height:16px;background:var(--ah-line);margin:0 4px}-.ah-copied{color:var(--ah-accent)!important}-@media(max-width:600px){.ah-bar .ah-hideSm{display:none}}-@media print{.ah-bar{display:none}body{padding-top:0}}-</style>+<link rel="stylesheet" href="../../../assets/css/handbook.css">+<script src="../../../assets/js/handbook.js" defer></script></head>-<body>-<div class="ah-bar" role="navigation" aria-label="Animation Handbook"><a class="ah-home" href="../../../">← Animation Handbook</a><span class="ah-actions"><a class="ah-hideSm" href="../flip-in/" rel="prev" title="Previous">‹ Prev</a><a class="ah-hideSm" href="../rotate-in/" rel="next" title="Next">Next ›</a><span class="ah-sep ah-hideSm"></span><button type="button" id="ah-copy" class="ah-hideSm">Copy source</button><a class="ah-hideSm" href="https://github.com/matinmonshizadeh/animation-handbook/blob/main/animations/02-entrance-and-exit/bounce-in/index.html" target="_blank" rel="noopener noreferrer">Source ↗</a></span></div>-<header>- <h1>Bounce In</h1>- <p>Overshoots final position then springs back — implemented with explicit @keyframes waypoints, not easing alone.</p>-</header>-<div class="layout">+<body class="hb" data-hb-autoplay>+<nav class="hb-bar" aria-label="Animation Handbook"><a class="hb-home" href="../../../">← <span>Animation Handbook</span></a><span class="hb-pager"><a href="../flip-in/" rel="prev" aria-label="Previous: Flip In">‹ <span class="hb-name">Flip In</span></a><a href="../rotate-in/" rel="next" aria-label="Next: Rotate In"><span class="hb-name">Rotate In</span> ›</a></span></nav>+<main class="hb-view"><div class="stage"><div class="card" id="card"><div class="card-icon">◈</div>@@ -93,8 +74,14 @@ body{padding-top:46px}<div class="card-sub">Real bounce is more complex than a single cubic-bezier curve. Hand-tuned keyframe waypoints give precise control over each phase.</div></div></div>- <aside>- <p class="note">Bounce-in uses explicit keyframe waypoints rather than cubic-bezier easing. The right number of bounces is almost always 1 — multiple bounces feel cartoonish.</p>+ <aside class="hb-side">+ <header class="hb-head">+ <p class="hb-cat">02.12 · Entrance & Exit</p>+ <h1>Bounce In</h1>+ <p class="hb-lede">Overshoots its final size and position, then springs back to rest.</p>+ </header>+ <section class="hb-settings" aria-label="Settings">+ <h2 class="hb-label">Settings</h2><div class="lbl">State</div><div class="kv"><span>Status</span><span class="v" id="st">hidden</span></div><div class="div"></div>@@ -111,18 +98,23 @@ body{padding-top:46px}<button data-b="3">3× Triple</button></div><label class="tog" for="fade-tog"><input type="checkbox" id="fade-tog" checked><span>Combine with fade</span></label>+ <div class="kf-block" id="kf-display" hidden>@keyframes bounce-in { ... }</div><div class="div"></div>- <div class="lbl">Live keyframes</div>- <div class="kf-block" id="kf-display">@keyframes bounce-in { ... }</div>- <div class="div"></div>- <label class="tog" for="loop-tog"><input type="checkbox" id="loop-tog"><span>Auto-loop</span></label>+ <label class="tog" for="loop-tog"><input type="checkbox" id="loop-tog" data-hb-skip data-hb-loop><span>Auto-loop</span></label><div class="btn-row">- <button class="act pri" id="btn-in" aria-label="Play bounce in">Play in</button>+ <button class="act pri" id="btn-in" data-hb-replay aria-label="Play bounce in">Play in</button><button class="act" id="btn-out" aria-label="Play out">Play out</button>- <button class="act" id="btn-rst" aria-label="Reset">Reset</button>+ <button class="act" id="btn-rst" data-hb-reset aria-label="Reset">Reset</button>+ </div>+ </section>+ <div class="hb-take">+ <section class="hb-prompt-box" aria-labelledby="hb-prompt-title">+ <h2 class="hb-label" id="hb-prompt-title">Prompt</h2>+ <p class="hb-prompt">Add a bounce-in entrance to [the element you want to animate]. When it appears, it should start small and a little below its final spot, grow slightly past full size, dip just under it, then settle, as if it landed with a small spring. Each bounce is smaller than the one before, like energy running out, and one bounce usually looks best. Unless the settings turn it off, fade it in at the same time. Animate only its position, size and opacity so it stays smooth. If the visitor has reduced motion turned on, show the element without the bounce. Match the settings listed below.</p>+ </section></div></aside>-</div>+</main><script>const card=document.getElementById('card');const stEl=document.getElementById('st');@@ -197,6 +189,5 @@ body{padding-top:46px}fadeTog.addEventListener('change',()=>buildKF(+ovSl.value,bounces));buildKF(60,1);</script>-<script>(function(){var b=document.getElementById("ah-copy");if(!b)return;b.addEventListener("click",function(){fetch(location.href).then(function(r){return r.text();}).catch(function(){return document.documentElement.outerHTML;}).then(function(t){return navigator.clipboard.writeText(t);}).then(function(){b.textContent="Copied!";b.classList.add("ah-copied");setTimeout(function(){b.textContent="Copy source";b.classList.remove("ah-copied");},1500);}).catch(function(){b.textContent="Copy failed";setTimeout(function(){b.textContent="Copy source";},1500);});});})();</script></body></html>diff --git a/assets/css/handbook.css b/assets/css/handbook.cssnew file mode 100644index 00000000..deac3b7d--- /dev/null+++ b/assets/css/handbook.css@@ -0,0 +1,130 @@+/* Animation Handbook — shared page chrome for the demo pages.+ Linked after each demo's own <style>, so these rules win where they overlap.+ The animation itself keeps its own styles; only the layout around it lives here. */++@font-face{font-family:'Schibsted Grotesk';src:url('../fonts/schibsted-latin-ext.woff2') format('woff2');font-weight:400 900;font-style:normal;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('../fonts/schibsted-latin.woff2') format('woff2');font-weight:400 900;font-style:normal;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}++:root{+ --hb-font:'Schibsted Grotesk',system-ui,-apple-system,'Segoe UI',sans-serif;+ --disp:var(--hb-font);--mono:var(--hb-font);+ --hb-bg:#0b0b0d;--hb-panel:#111114;--hb-panel-2:#0d0d10;+ --hb-ink:#f4f4f2;--hb-dim:#adadb2;--hb-muted:#77777e;--hb-line:rgba(255,255,255,.085);+ --hb-accent:var(--ui-accent,#6ea8ff);--hb-bar:48px;+}++body.hb{margin:0;padding:0;background:var(--hb-bg);color:var(--hb-ink);font-family:var(--hb-font);-webkit-font-smoothing:antialiased}+body.hb :focus-visible{outline:2px solid var(--hb-accent);outline-offset:2px}++/* Top bar */+.hb-bar{position:sticky;top:0;z-index:50;height:var(--hb-bar);display:flex;align-items:center;justify-content:space-between;gap:8px;+ padding:0 clamp(6px,1.6vw,16px);background:rgba(11,11,13,.88);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);+ border-bottom:1px solid var(--hb-line);font:500 11px/1 var(--hb-font);letter-spacing:.1em;text-transform:uppercase}+.hb-bar a{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:44px;min-width:44px;padding:0 8px;+ border-radius:6px;color:var(--hb-muted);text-decoration:none}+.hb-bar a:hover{color:var(--hb-ink)}+.hb-bar .hb-home{color:var(--hb-ink)}+.hb-pager{display:flex}++/* First screen: the stage fills the view, the side column sits beside it */+.hb-view{display:grid;grid-template-columns:minmax(0,1fr) clamp(300px,27vw,370px);grid-template-rows:minmax(0,1fr);+ grid-template-areas:"stage side";gap:clamp(10px,1.2vw,16px);padding:clamp(10px,1.2vw,16px);box-sizing:border-box;+ height:calc(100vh - var(--hb-bar));height:calc(100dvh - var(--hb-bar));min-height:560px}+.hb-view>.stage{grid-area:stage;width:auto;height:auto;min-width:0;min-height:0;flex:none;margin:0}+.hb-replay{grid-area:stage;align-self:end;justify-self:end;position:relative;z-index:3;margin:12px;min-height:44px;padding:0 16px;+ border:1px solid var(--hb-line);border-radius:999px;background:rgba(17,17,20,.85);color:var(--hb-dim);font:500 12px/1 var(--hb-font);cursor:pointer}+.hb-replay:hover{color:var(--hb-ink);border-color:rgba(255,255,255,.25)}++.hb-view>.hb-side{grid-area:side;width:auto;min-width:0;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:18px;+ padding:18px 18px 0;background:var(--hb-panel);border:1px solid var(--hb-line);border-radius:10px}+.hb-head{margin:0}+.hb-cat{margin:0;font:500 11px/1.3 var(--hb-font);letter-spacing:.14em;text-transform:uppercase;color:var(--hb-accent)}+.hb-side .hb-head h1{margin:8px 0 0;font:800 clamp(28px,2.6vw,36px)/1 var(--hb-font);letter-spacing:-.03em;color:var(--hb-ink)}+.hb-side .hb-lede{margin:8px 0 0;font:400 13px/1.6 var(--hb-font);color:var(--hb-dim)}+.hb-label{margin:0 0 8px;font:500 11px/1 var(--hb-font);letter-spacing:.14em;text-transform:uppercase;color:var(--hb-muted)}++/* Settings: the demo's own controls, restyled compactly */+.hb-settings{display:flex;flex-direction:column;gap:10px}+.hb-settings .lbl{margin:0;font:500 12px/1.3 var(--hb-font);letter-spacing:0;text-transform:none;color:var(--hb-dim)}+.hb-settings div:has(>.sr){display:grid;grid-template-columns:1fr auto;grid-template-areas:"label value" "slider slider";column-gap:10px}+.hb-settings div:has(>.sr)>.lbl{grid-area:label}+.hb-settings .sr{display:contents}+.hb-settings .sr input[type=range]{grid-area:slider;width:100%;min-height:30px;margin:0;accent-color:var(--hb-accent);cursor:pointer}+.hb-settings .sv{grid-area:value;width:auto;font:500 12px/1.3 var(--hb-font);color:var(--hb-ink);text-align:right}+.hb-settings div:has(>select){display:flex;align-items:center;justify-content:space-between;gap:10px}+.hb-settings select,.hb-settings input[type=text],.hb-settings textarea{min-height:32px;padding:6px 8px;border:1px solid var(--hb-line);+ border-radius:6px;background:var(--hb-panel-2);color:var(--hb-ink);font:500 12px/1.4 var(--hb-font)}+.hb-settings input[type=text],.hb-settings textarea{width:100%;font-weight:400}+.hb-settings .seg{display:flex;flex-wrap:wrap;gap:4px}+.hb-settings .seg button{flex:1 1 0;min-width:0;min-height:36px;padding:6px 4px;border:1px solid var(--hb-line);border-radius:6px;+ background:none;color:var(--hb-muted);font:500 12px/1.2 var(--hb-font);cursor:pointer}+.hb-settings .seg button.on{border-color:var(--hb-accent);color:var(--hb-accent);background:color-mix(in srgb,var(--hb-accent) 12%,transparent)}+.hb-settings .tog{display:flex;flex-direction:row-reverse;align-items:center;justify-content:space-between;gap:10px;min-height:36px;+ font:500 12px/1.3 var(--hb-font);color:var(--hb-dim);cursor:pointer}+.hb-settings .tog input{appearance:none;-webkit-appearance:none;flex:none;width:36px;height:20px;margin:0;border-radius:999px;cursor:pointer;+ background:radial-gradient(circle at 10px 50%,var(--hb-ink) 6.5px,transparent 7px) #2a2a30}+.hb-settings .tog input:checked{background:radial-gradient(circle at 26px 50%,#0b0b0d 6.5px,transparent 7px) var(--hb-accent)}+.hb-settings .kv{display:flex;justify-content:space-between;gap:10px;font:400 12px/1.4 var(--hb-font);color:var(--hb-muted)}+.hb-settings .kv .v{color:var(--hb-ink)}+.hb-settings .div{height:1px;margin:2px 0;background:var(--hb-line)}+.hb-settings .btn-row{display:flex;gap:6px}+.hb-settings .act{flex:1;min-height:36px;padding:0 6px;border:1px solid var(--hb-line);border-radius:6px;background:none;+ color:var(--hb-ink);font:500 12px/1 var(--hb-font);cursor:pointer}+.hb-settings .act.pri{border-color:var(--hb-accent);color:var(--hb-accent)}++/* Prompt box and Read more stay visible at the bottom of the column */+.hb-take{margin-top:auto;position:sticky;bottom:0;display:flex;flex-direction:column;gap:10px;padding:12px 0 18px;background:var(--hb-panel)}+.hb-prompt-box{padding:12px;border:1px solid var(--hb-line);border-radius:8px;background:var(--hb-panel-2)}+.hb-prompt{margin:0;font:400 13px/1.6 var(--hb-font);color:var(--hb-ink)}+.hb-clamp{display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}+.hb-set{margin:8px 0 0;font:500 12px/1.5 var(--hb-font);color:var(--hb-accent)}+.hb-copy{display:block;width:100%;margin-top:10px;min-height:44px;border:0;border-radius:6px;background:var(--hb-ink);color:#0b0b0d;+ font:600 12px/1 var(--hb-font);letter-spacing:.04em;cursor:pointer}+.hb-copy:hover{background:#fff}+.hb-more{width:100%;min-height:44px;border:1px solid var(--hb-line);border-radius:6px;background:none;color:var(--hb-dim);+ font:500 12px/1 var(--hb-font);cursor:pointer}+.hb-more:hover{color:var(--hb-ink);border-color:rgba(255,255,255,.25)}++/* Read more: the explanation below the first screen */+.hb-details{border-top:1px solid var(--hb-line);scroll-margin-top:var(--hb-bar)}+.hb-details-in{max-width:1120px;margin:0 auto;padding:clamp(20px,3vw,40px) clamp(16px,3vw,32px) 96px;display:grid;+ grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);gap:clamp(20px,4vw,56px)}+.hb-details .hb-back{grid-column:1/-1;justify-self:start;display:inline-flex;align-items:center;min-height:44px;color:var(--hb-muted);+ text-decoration:none;font:500 11px/1 var(--hb-font);letter-spacing:.1em;text-transform:uppercase}+.hb-details .hb-back:hover{color:var(--hb-ink)}+.hb-details h2{margin:0 0 10px;font:700 20px/1.2 var(--hb-font);letter-spacing:-.01em;color:var(--hb-ink)}+.hb-details section+section{margin-top:34px}+.hb-details p,.hb-details li,.hb-details dd{margin:0;font:400 14px/1.75 var(--hb-font);color:var(--hb-dim)}+.hb-details p+p{margin-top:10px}+.hb-details ul{margin:0;padding:0;list-style:none}+.hb-details li{position:relative;padding-left:18px}+.hb-details li+li{margin-top:4px}+.hb-details li::before{content:"–";position:absolute;left:0;color:var(--hb-accent)}+.hb-details a{color:var(--hb-ink)}+.hb-details dl{margin:0;display:grid;grid-template-columns:minmax(120px,auto) 1fr;gap:12px 20px}+.hb-details dt{font:500 14px/1.5 var(--hb-font);color:var(--hb-ink)}+.hb-details dt small{display:block;font:400 12px/1.4 var(--hb-font);color:var(--hb-muted)}+.hb-full{padding:16px;border:1px solid var(--hb-line);border-radius:10px;background:var(--hb-panel)}+.hb-details .hb-full-text{color:var(--hb-ink);line-height:1.7}+.hb-details .hb-set{margin-top:8px;font:500 12px/1.5 var(--hb-font);color:var(--hb-accent)}+.hb-rel{display:flex;justify-content:space-between;align-items:center;gap:12px;padding:12px 14px;border:1px solid var(--hb-line);+ border-radius:8px;text-decoration:none}+.hb-rel+.hb-rel{margin-top:8px}+.hb-rel:hover{border-color:rgba(255,255,255,.25)}+.hb-rel b{display:block;font:700 16px/1.3 var(--hb-font);color:var(--hb-ink)}+.hb-rel small{display:block;margin-top:2px;font:400 12px/1.5 var(--hb-font);color:var(--hb-muted)}+.hb-rel i{font-style:normal;color:var(--hb-muted)}+.hb-details .hb-note{color:var(--hb-muted)}++@media(max-width:1024px){.hb-view{grid-template-columns:minmax(0,1fr) 300px}}+@media(max-width:760px){.hb-details-in{grid-template-columns:1fr}}+@media(max-width:600px){+ .hb-bar .hb-name{display:none}+ .hb-view{grid-template-columns:minmax(0,1fr);grid-template-rows:auto auto;grid-template-areas:"stage" "side";height:auto;min-height:0}+ .hb-view>.stage{height:calc(100vh * .56);height:calc(100svh * .56);min-height:320px}+ .hb-view>.hb-side{overflow:visible}+ .hb-take{position:static}+ .hb-settings .sr input[type=range],.hb-settings .seg button,.hb-settings .act,.hb-settings .tog,.hb-settings select{min-height:44px}+}diff --git a/assets/fonts/schibsted-latin-ext.woff2 b/assets/fonts/schibsted-latin-ext.woff2new file mode 100644index 00000000..041da55dBinary files /dev/null and b/assets/fonts/schibsted-latin-ext.woff2 differdiff --git a/assets/fonts/schibsted-latin.woff2 b/assets/fonts/schibsted-latin.woff2new file mode 100644index 00000000..ea0f36f0Binary files /dev/null and b/assets/fonts/schibsted-latin.woff2 differdiff --git a/tests/pages.test.js b/tests/pages.test.jsnew file mode 100644index 00000000..004b9ba6--- /dev/null+++ b/tests/pages.test.js@@ -0,0 +1,52 @@+// Static checks for demo pages that use the shared layout, their READMEs and the home page.+// Run from the repo root: node --test "tests/*.test.js"+const test = require('node:test');+const assert = require('node:assert/strict');+const fs = require('node:fs');+const path = require('node:path');++const ROOT = path.resolve(__dirname, '..');+const ANIM = path.join(ROOT, 'animations');+const read = f => fs.readFileSync(f, 'utf8');+const count = (s, sub) => s.split(sub).length - 1;+const words = s => s.trim().split(/\s+/).length;+const isDemoDir = dir => fs.existsSync(path.join(dir, 'index.html'));++const demos = fs.readdirSync(ANIM, { withFileTypes: true }).filter(c => c.isDirectory()).flatMap(c =>+ fs.readdirSync(path.join(ANIM, c.name), { withFileTypes: true }).filter(d => d.isDirectory())+ .map(d => ({ cat: c.name, slug: d.name, dir: path.join(ANIM, c.name, d.name) })));+const converted = demos.filter(d => read(path.join(d.dir, 'index.html')).includes('<main class="hb-view">'));++const PILOT = '02-entrance-and-exit';+const PILOT_AUTOPLAY = new Set(['fade-in-out', 'slide-in', 'slide-up-reveal', 'scale-in', 'clip-path-reveal',+ 'split-text-reveal', 'letter-by-letter-stagger', 'word-by-word-reveal', 'blur-in', 'flip-in', 'bounce-in', 'rotate-in']);++test('Bounce In uses the shared layout', () => {+ assert.ok(converted.some(d => d.cat === PILOT && d.slug === 'bounce-in'));+});++for (const d of converted) {+ test(`${d.cat}/${d.slug} uses the shared layout correctly`, () => {+ const html = read(path.join(d.dir, 'index.html'));+ assert.ok(html.includes('<link rel="stylesheet" href="../../../assets/css/handbook.css">'), 'shared stylesheet');+ assert.ok(html.includes('<script src="../../../assets/js/handbook.js" defer></script>'), 'shared script');+ assert.match(html, /<body class="hb"( data-hb-autoplay)?>/);+ for (const legacy of ['ah-bar', 'ah-copy', 'ah-inject', 'Copy source', 'Bricolage', 'PlexMono', 'class="note"', 'class="layout"']) {+ assert.ok(!html.includes(legacy), `legacy markup left: ${legacy}`);+ }+ for (const part of ['<nav class="hb-bar"', '<main class="hb-view">', '<aside class="hb-side">', '<section class="hb-settings"', '<p class="hb-prompt">']) {+ assert.equal(count(html, part), 1, `exactly one ${part}`);+ }+ assert.match(html, /<p class="hb-cat">\d{2}\.\d{2} · [^<]+<\/p>/);+ const prompt = html.match(/<p class="hb-prompt">([^<]*)<\/p>/)[1];+ assert.ok(words(prompt) >= 60 && words(prompt) <= 130, `prompt has ${words(prompt)} words`);+ assert.ok(prompt.trim().endsWith('Match the settings listed below.'), 'prompt ending');+ assert.ok(!prompt.includes('`'), 'prompt contains no code');+ assert.equal(count(html, 'data-hb-replay'), 1, 'one replay control');+ assert.ok(count(html, 'data-hb-reset') <= 1, 'at most one reset control');+ if (d.cat === PILOT) assert.equal(html.includes('data-hb-autoplay'), PILOT_AUTOPLAY.has(d.slug), 'autoplay flag');+ for (const [, href] of html.matchAll(/<a href="([^"]+)" rel="(?:prev|next)"/g)) {+ assert.ok(isDemoDir(path.resolve(d.dir, href)), `pager link ${href}`);+ }+ });+}diff --git a/tools/migrations/02-entrance-and-exit.json b/tools/migrations/02-entrance-and-exit.jsonnew file mode 100644index 00000000..b5728c8a--- /dev/null+++ b/tools/migrations/02-entrance-and-exit.json@@ -0,0 +1,19 @@+{+ "category": "02-entrance-and-exit",+ "name": "Entrance & Exit",+ "demos": [+ {+ "slug": "bounce-in",+ "number": "02.12",+ "prev": { "href": "../flip-in/", "name": "Flip In" },+ "next": { "href": "../rotate-in/", "name": "Rotate In" },+ "autoplay": true,+ "attrs": { "btn-in": "data-hb-replay", "btn-rst": "data-hb-reset", "loop-tog": "data-hb-skip data-hb-loop" },+ "edits": [+ [" <div class=\"div\"></div>\n <div class=\"lbl\">Live keyframes</div>\n <div class=\"kf-block\" id=\"kf-display\">", " <div class=\"kf-block\" id=\"kf-display\" hidden>"]+ ],+ "lede": "Overshoots its final size and position, then springs back to rest.",+ "prompt": "Add a bounce-in entrance to [the element you want to animate]. When it appears, it should start small and a little below its final spot, grow slightly past full size, dip just under it, then settle, as if it landed with a small spring. Each bounce is smaller than the one before, like energy running out, and one bounce usually looks best. Unless the settings turn it off, fade it in at the same time. Animate only its position, size and opacity so it stays smooth. If the visitor has reduced motion turned on, show the element without the bounce. Match the settings listed below."+ }+ ]+}