GlossaryPanel.svelte
GlossaryPanel.svelte
Root container component that acts as a state-machine view router, switching child components based on glossaryStore.viewMode.
Source: src/lib/components/glossary/GlossaryPanel.svelte
Exports
| Export | Kind | Description |
|---|---|---|
| GlossaryPanel | default Svelte component | State-machine view router for the glossary sidebar panel |
State Machine
The panel renders exactly one child component at a time, determined by the viewMode value in glossaryStore:
| viewMode | Component Rendered | Trigger |
|---|---|---|
'list' |
GlossaryList | Default state, after delete completes |
'detail' |
GlossaryEntryDetail | Click entry in list, glossary:view-term event |
'create' |
GlossaryEntryForm (mode=create) | "New" button in list header, context menu "Add to Glossary" |
'edit' |
GlossaryEntryForm (mode=edit) | "Edit" button from detail view |
Lifecycle
onMount
- Subscribes to the
glossary:view-termevent on moduleEventBus. When received, callsglossaryStore.navigateToEntry()with the event payload's entry ID to switch to detail view for the referenced term. - Calls
glossaryStore.loadEntries(projectSlug)ifprojectSlugis set, triggering the initial fetch of glossary entries for the current project.
onDestroy
- Unsubscribes from all moduleEventBus event listeners registered during mount.
- Clears store state to prevent stale data from persisting when the panel is unmounted.
Dependencies
| Dependency | Type | Purpose |
|---|---|---|
| glossaryStore | internal | Reactive state — viewMode, entries, selected entry |
| moduleEventBus | internal | Subscribe to glossary:view-term events |
| GlossaryList | child component | List view rendering |
| GlossaryEntryDetail | child component | Detail view rendering |
| GlossaryEntryForm | child component | Create/edit form rendering |
Side Effects
- Subscribes to
moduleEventBuson mount; unsubscribes on destroy. - Triggers network I/O indirectly via
glossaryStore.loadEntries()on mount.