From 68ef9710375e862f02030d4441122c99456f5a4e Mon Sep 17 00:00:00 2001 From: Ahmedhossamdev Date: Sun, 24 Nov 2024 18:20:07 +0200 Subject: [PATCH] chore: formatting --- src/components/containers/Accordion.svelte | 66 +++++++-------- .../containers/AccordionItem.svelte | 80 +++++++++---------- src/components/navigation/ModalPane.svelte | 2 +- src/components/stops/StopPane.svelte | 18 ++--- 4 files changed, 84 insertions(+), 82 deletions(-) diff --git a/src/components/containers/Accordion.svelte b/src/components/containers/Accordion.svelte index 01ed5f8..21e7320 100644 --- a/src/components/containers/Accordion.svelte +++ b/src/components/containers/Accordion.svelte @@ -1,33 +1,35 @@ - -
- -
\ No newline at end of file + import { setContext } from 'svelte'; + import { writable, derived } from 'svelte/store'; + + // Create a store to track the active item + const activeItem = writable(null); + + // Create dispatch for activeChanged event + import { createEventDispatcher } from 'svelte'; + const dispatch = createEventDispatcher(); + + // Watch for changes to activeItem and dispatch event + $: { + dispatch('activeChanged', { activeItem: $activeItem }); + } + + // Provide context for child AccordionItems + setContext('accordion', { + registerItem: (id) => { + const isActive = derived(activeItem, ($activeItem) => $activeItem === id); + return { + isActive, + activate: () => { + activeItem.set($activeItem === id ? null : id); + } + }; + } + }); + + +
+ +
diff --git a/src/components/containers/AccordionItem.svelte b/src/components/containers/AccordionItem.svelte index 46cee01..7e12244 100644 --- a/src/components/containers/AccordionItem.svelte +++ b/src/components/containers/AccordionItem.svelte @@ -1,46 +1,46 @@
- -
- -
- - {#if $isActive} -
-
- -
-
- {/if} -
\ No newline at end of file + +
+ +
+ + {#if $isActive} +
+
+ +
+
+ {/if} + diff --git a/src/components/navigation/ModalPane.svelte b/src/components/navigation/ModalPane.svelte index ac31912..27a9677 100644 --- a/src/components/navigation/ModalPane.svelte +++ b/src/components/navigation/ModalPane.svelte @@ -40,7 +40,7 @@
-
+
 
diff --git a/src/components/stops/StopPane.svelte b/src/components/stops/StopPane.svelte index 2d06bc0..2e4a436 100644 --- a/src/components/stops/StopPane.svelte +++ b/src/components/stops/StopPane.svelte @@ -92,7 +92,7 @@ } function selectionChanged() { - console.log("bonk"); + console.log('bonk'); } @@ -114,14 +114,14 @@