feat: reusable registry galleries and individual HTML examples [verified]

This commit is contained in:
jarvis-at-skic committed 2026-10-25 09:19:23 +00:00
1 parent 55e559dcd1
commit 3bb9555e6a
67 files changed
+1229 -77

No files matched your search

+25 -3
View File
@@ -55,7 +55,29 @@
settle();
return {seek,settle,play:()=>play(),replay:()=>play(true),state:()=>({duration:tl.duration,time:tl.currentTime,paused:tl.paused,destroyed}),destroy(){if(destroyed)return;settle();abort.abort();tl.revert();destroyed=true;host.replaceChildren();}};
}
const controllers={};
for(const config of window.animeExamples){const host=document.createElement('article');host.id=config.id;document.querySelector('main').append(host);controllers[config.id]=mount(host,config);}
window.animeGallery={controllers,mount};
const main=document.querySelector('main'), selected=document.body.dataset.example;
if(selected !== undefined) {
const config=window.animeExamples.find(c=>c.id===selected);
if(!config)throw new Error('Unknown example ID: '+selected);
if(window.self!==window.top)document.body.classList.add('embedded');
const host=document.createElement('article');host.id=config.id;main.append(host);
window.animeGallery={controllers:{[config.id]:mount(host,config)},mount};
} else {
const group=document.body.dataset.gallery;
if(!['all','elements','compositions'].includes(group))throw new Error('Unknown gallery: '+group);
for(const name of ['elements','compositions']) {
if(group!=='all'&&group!==name)continue;
const section=document.createElement('section'), heading=document.createElement('h2'), link=document.createElement('a');
section.dataset.registry=name;link.href=group==='all'?name+'/index.html':'index.html';link.textContent=name==='elements'?'Elements':'Compositions';heading.append(link);section.append(heading);
const grid=document.createElement('div');grid.className='preview-grid';section.append(grid);
for(const config of window.animeExamples.filter(c=>c.kind===(name==='elements'?'element':'composition'))) {
const card=document.createElement('article'),frame=document.createElement('iframe'),open=document.createElement('a');
const href=(group==='all'?'':'../')+'examples/'+config.id+'.html';
frame.src=href;frame.title=config.title;frame.dataset.example=config.id;
open.href=href;open.textContent='Open example: '+config.title;open.className='open-example';
card.append(frame,open);grid.append(card);
}
main.append(section);
}
}
})();