Try to add character editor inside the character sheet

This commit is contained in:
Clément Pons
2026-02-13 17:34:35 +01:00
parent 898d95793a
commit 9face0ac3b
8 changed files with 14833 additions and 320 deletions

View File

@@ -226,17 +226,20 @@ const iconLoadingRegistry: Map<string, Promise<Required<IconifyIcon>> | null | u
export function icon(name: Reactive<string>, properties?: IconProperties)
{
const element = dom('div', { class: properties?.class, style: properties?.style });
let timeout: NodeJS.Timeout = setTimeout(() => {}, 0);
const build = (icon: IconifyIcon | null | undefined) => {
if(!icon) return element.replaceChildren();
if(!icon) return clearTimeout(timeout) ?? element.replaceChildren();
const built = buildIcon(icon, properties);
const dom = svg('svg', { attributes: built.attributes });
dom.innerHTML = built.body;
clearTimeout(timeout);
element.replaceChildren(dom);
}
reactivity(name, (name) => {
if(!iconLoaded(name))
{
element.replaceChildren(loading('small'));
timeout = setTimeout(() => { element.replaceChildren(loading('small')); }, 100);
if(!iconLoadingRegistry.has(name)) iconLoadingRegistry.set(name, loadIcon(name));
iconLoadingRegistry.get(name)?.then(build);
}