math-tasks/assets/themes/sonic/loader.mjs

16 lines
488 B
JavaScript

/**
* Sonic theme component loader.
* Scans the document for `sonic-*` custom elements and lazy-imports
* only those component modules. See src/components/CLAUDE.md.
*/
const PREFIX = 'sonic-';
const tags = new Set();
document.querySelectorAll('*').forEach(el => {
const t = el.tagName.toLowerCase();
if (t.startsWith(PREFIX)) tags.add(t);
});
await Promise.all([...tags].map(t => {
const name = t.slice(PREFIX.length);
return import(`./components/${name}/${name}.mjs`);
}));