update for levels

This commit is contained in:
Jesse Winton
2025-03-27 09:23:29 -04:00
parent 44aadc5f1d
commit af348d22d0
3 changed files with 8 additions and 4 deletions

View File

@@ -30,6 +30,8 @@
export let toc: Array<TocItem> = []; export let toc: Array<TocItem> = [];
export let heading: string = 'Table of Contents'; export let heading: string = 'Table of Contents';
$: console.log({ toc });
</script> </script>
<svelte:window on:scroll={handleIsScrolled} /> <svelte:window on:scroll={handleIsScrolled} />
@@ -50,8 +52,8 @@
'before:bg-greyscale-300 before:absolute before:top-0 before:left-0 before:h-6 before:w-px before:rounded-full before:opacity-0 before:transition-opacity', 'before:bg-greyscale-300 before:absolute before:top-0 before:left-0 before:h-6 before:w-px before:rounded-full before:opacity-0 before:transition-opacity',
{ {
'font-medium': parent.level && parent.level === 1, 'font-medium': parent.level && parent.level === 1,
'ps-6': parent.level && parent.level === 2, 'pl-12': parent.level && parent.level === 2,
'ps-12': parent.level && parent.level >= 3, 'ps-16': parent.level && parent.level >= 3,
'before:opacity-100': parent.selected 'before:opacity-100': parent.selected
} }
)} )}

View File

@@ -54,7 +54,8 @@
title: heading.title, title: heading.title,
href: `#${id}`, href: `#${id}`,
step: heading.step, step: heading.step,
selected: selected === id selected: selected === id,
level: heading.level
}); });
return carry; return carry;
}, []); }, []);

View File

@@ -52,7 +52,8 @@
title: heading.title, title: heading.title,
href: `#${id}`, href: `#${id}`,
step: heading.step, step: heading.step,
selected: selected === id selected: selected === id,
level: heading.level
}); });
return carry; return carry;
}, []); }, []);