From 43d77d0f0477af975438120f3f84778d49cc8490 Mon Sep 17 00:00:00 2001 From: buttercat1791 Date: Tue, 8 Jul 2025 09:18:32 -0500 Subject: [PATCH] Remove accordion display mode from ToC component --- .../publications/TableOfContents.svelte | 93 ++++++------------- 1 file changed, 30 insertions(+), 63 deletions(-) diff --git a/src/lib/components/publications/TableOfContents.svelte b/src/lib/components/publications/TableOfContents.svelte index 3c0b8f1..08097ed 100644 --- a/src/lib/components/publications/TableOfContents.svelte +++ b/src/lib/components/publications/TableOfContents.svelte @@ -4,17 +4,13 @@ type TocEntry } from '$lib/components/publications/table_of_contents.svelte'; import { getContext } from 'svelte'; - import { Accordion, AccordionItem, SidebarDropdownWrapper, SidebarGroup, SidebarItem } from 'flowbite-svelte'; + import { SidebarDropdownWrapper, SidebarGroup, SidebarItem } from 'flowbite-svelte'; import Self from './TableOfContents.svelte'; - export type TocDisplayMode = 'accordion' | 'sidebar'; - let { - displayMode = 'accordion', depth, onSectionFocused, - } = $props<{ - displayMode?: TocDisplayMode; + } = $props<{ rootAddress: string; depth: number; onSectionFocused?: (address: string) => void; @@ -46,65 +42,36 @@ } - -{#if displayMode === 'accordion'} - - {#each entries as entry} - {@const address = entry.address} - {@const expanded = toc.expandedMap.get(address) ?? false} - + + + {#each entries as entry} + {@const address = entry.address} + {@const expanded = toc.expandedMap.get(address) ?? false} + {@const isLeaf = toc.leaves.has(address)} + {#if isLeaf} + onSectionFocused?.(address)} + /> + {:else} + {@const childDepth = depth + 1} + expanded, (open) => setEntryExpanded(address, open) } > - {#snippet header()} - {entry.title} - {/snippet} - {#if entry.children.length > 0} - - {/if} - - {/each} - -{:else} - - - - {#each entries as entry} - {@const address = entry.address} - {@const expanded = toc.expandedMap.get(address) ?? false} - {@const isLeaf = toc.leaves.has(address)} - {#if isLeaf} - onSectionFocused?.(address)} + - {:else} - {@const childDepth = depth + 1} - expanded, - (open) => setEntryExpanded(address, open) - } - > - - - {/if} - {/each} - -{/if} + + {/if} + {/each} +