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 direct finder address shows only the top bar until the finder is drawn, no longer the start page's results and How it works first, and the page still shows if its script fails
matin6db427e9551d
diff --git a/index.html b/index.htmlindex 0cf6543b..158c28bb 100644--- a/index.html+++ b/index.html@@ -51,9 +51,10 @@// throws, and the system's setting must still count. The browser's bar (theme-color) takes the page's background of the theme.function setTheme(t){document.documentElement.dataset.theme=t;document.querySelector('meta[name="theme-color"]').content=t==='dark'?'#0e0e11':'#f8f7f4';}(function(){var t=matchMedia('(prefers-color-scheme: light)').matches?'light':'dark';try{t=localStorage.getItem('ah-theme')||t;}catch(e){}setTheme(t);})();-// An address that opens the finder (?view=find, and no ?q= or ?place=, which win) hides the hero and the place tiles until the page's-// script has drawn the view, so the start page is not painted first.-(function(){var p=new URLSearchParams(location.search);if(p.get('view')==='find'&&!(p.get('q')||'').trim()&&!p.get('place'))document.documentElement.classList.add('fd-direct');})();</script>+// An address that opens the finder (?view=find, and no ?q= or ?place=, which win) shows only the top bar until the page's script+// has drawn the finder, so the start page is not painted first. Once the page is read the class goes in any case: if the script+// failed, the start page still shows.+(function(){var p=new URLSearchParams(location.search);if(p.get('view')!=='find'||(p.get('q')||'').trim()||p.get('place'))return;var h=document.documentElement;h.classList.add('fd-direct');addEventListener('DOMContentLoaded',function(){h.classList.remove('fd-direct');});})();</script><script src="assets/js/demo-page.js?v=8" defer></script><style>@font-face{font-family:'Schibsted Grotesk';src:url('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}@@ -345,7 +346,7 @@ button,input{font:inherit;color:inherit}answer a dark ring and a tick. What and When answers have a still icon beside their words, How answers a small moving pictureabove them (drawn at the end of this stylesheet). */.finder{display:flex;flex-direction:column;align-items:center;padding-top:clamp(16px,4vw,56px);text-align:center}-.fd-direct .home-hero,.fd-direct [aria-labelledby="places-title"]{display:none} /* an address that opens the finder: the head script's class, gone once the script has drawn the view */+.fd-direct main,.fd-direct .foot{visibility:hidden} /* an address that opens the finder: the head script's class shows only the top bar until the script has drawn the finder; the start page under it keeps its room, so the bar does not shift */.fd-h{margin-top:0}.fd-qs{display:flex;flex-direction:column;gap:clamp(28px,4vw,44px);width:min(1080px,100%);margin-top:clamp(24px,4vw,44px);text-align:left}.fd-q{min-width:0;border:0}@@ -3109,7 +3110,7 @@ function showNotHere(finding,found){$('find-words').addEventListener('click',()=>{go({},true);scrollTo({top:0,behavior:reduce?'auto':'smooth'});q.focus({preventScroll:true});});const startCat=readURL();render();-document.documentElement.classList.remove('fd-direct'); // the view now hides or shows the hero and the tiles itself+document.documentElement.classList.remove('fd-direct'); // the view is drawn: the page under the top bar showsif(startCat){const g=$('cat-'+startCat);if(g)g.scrollIntoView();}(function(){const btn=$('theme-toggle');if(!btn)return;diff --git a/tests/finder.test.js b/tests/finder.test.jsindex 8eddffe0..689c3c04 100644--- a/tests/finder.test.js+++ b/tests/finder.test.js@@ -476,19 +476,25 @@ test('an answer drops Show all and only replaces the address, and in the finderassert.deepEqual([e.prevented, els.q.focused], [true, {}], 'elsewhere');});-test('an address that opens the finder hides the hero and the place tiles from the first paint until the script has drawn the view', () => {+test('an address that opens the finder shows only the top bar from the first paint until the script has drawn the view, and the page once it is read even if the script failed', () => {const head = between(HOME, '(function(){var p=new URLSearchParams(location.search);', '</script>');assert.ok(head && at(head) < at('</head>'), 'the line runs in the head');const page = finder({ URLSearchParams, location: { search: '' } });vm.runInContext(source('fromURL'), page);for (const search of ['?view=find', '?view=find&what=text&how=fade', '?q=%20&view=find', '?q=fade&view=find', '?place=buttons&view=find', '?view=all', '?what=text', '']) {- const added = [];- vm.runInNewContext(head, { URLSearchParams, location: { search }, document: { documentElement: { classList: { add: name => added.push(name) } } } });+ const added = [], removed = [], read = [];+ vm.runInNewContext(head, { URLSearchParams, location: { search }, addEventListener: (type, fn) => { if (type === 'DOMContentLoaded') read.push(fn); },+ document: { documentElement: { classList: { add: name => added.push(name), remove: name => removed.push(name) } } } });page.location.search = search;- assert.deepEqual(added, page.fromURL().next.view === 'find' ? ['fd-direct'] : [], `${search || 'the start page'}: as the page reads the address`);+ const where = search || 'the start page';+ assert.deepEqual(added, page.fromURL().next.view === 'find' ? ['fd-direct'] : [], `${where}: as the page reads the address`);+ read.forEach(fn => fn());+ assert.deepEqual(removed, added, `${where}: the class goes once the page is read, so a script that failed still leaves the page to see`);}- assert.ok(HOME.includes('<section class="wrap" aria-labelledby="places-title">'), "the place tiles' section");- assert.ok(STYLE.includes('.fd-direct .home-hero,.fd-direct [aria-labelledby="places-title"]{display:none}'), 'the class hides the hero and the place tiles');+ const main = between(HOME, '<main>', '</main>');+ for (const part of ['<section class="wrap home-hero"', '<section class="wrap" aria-labelledby="places-title">', '<section class="wrap finder" id="finder"',+ '<section class="wrap results" id="results"', '<section class="how" id="how"']) assert.ok(main.includes(part), `${part}… sits in <main>`);+ assert.ok(STYLE.includes('.fd-direct main,.fd-direct .foot{visibility:hidden}'), 'the class hides everything under the top bar and keeps its room');assert.match(HOME, /\nconst startCat=readURL\(\);\r?\nrender\(\);\r?\ndocument\.documentElement\.classList\.remove\('fd-direct'\);/, 'the first render takes the class away');});