fix(arch): move unifiedFontStore context creation to Layout.svelte
- Moved unifiedFontStore creation from Page.svelte to Layout.svelte - Layout now creates store instance and provides it via setContext() - Page.svelte now receives store via getContext() instead of creating it - Fixes context accessibility issue where FiltersSidebar and FontSearch (siblings of Page) could not access the store - All child components now share the same store instance at Layout level This resolves the architectural issue where context only flows downward, not sideways. All components (FiltersSidebar, FontSearch, Page) are now children of Layout and can access the unifiedFontStore context.
This commit is contained in:
@@ -12,14 +12,34 @@
|
||||
*
|
||||
* Uses Sidebar.Provider to enable mobile-responsive collapsible sidebar behavior
|
||||
* throughout the application.
|
||||
*
|
||||
* Creates and provides unifiedFontStore context to all child components (FiltersSidebar,
|
||||
* TypographyMenu/FontSearch, and Page.svelte), ensuring all components can access
|
||||
* the same font data and filtering state.
|
||||
*/
|
||||
import {
|
||||
UNIFIED_FONT_STORE_KEY,
|
||||
type UnifiedFontStore,
|
||||
createUnifiedFontStore,
|
||||
} from '$entities/Font/model/store/unifiedFontStore.svelte';
|
||||
import favicon from '$shared/assets/favicon.svg';
|
||||
import * as Sidebar from '$shared/shadcn/ui/sidebar/index';
|
||||
import { FiltersSidebar } from '$widgets/FiltersSidebar';
|
||||
import TypographyMenu from '$widgets/TypographySettings/ui/TypographyMenu.svelte';
|
||||
import { setContext } from 'svelte';
|
||||
|
||||
/** Slot content for route pages to render */
|
||||
let { children } = $props();
|
||||
|
||||
// Create unified font store instance at Layout level (highest common ancestor)
|
||||
const unifiedFontStore: UnifiedFontStore = createUnifiedFontStore();
|
||||
|
||||
// Provide store to all children components via context
|
||||
// This makes the store accessible to FiltersSidebar, FontSearch, and Page.svelte
|
||||
setContext(UNIFIED_FONT_STORE_KEY, unifiedFontStore);
|
||||
|
||||
// Export store for direct access in Page.svelte
|
||||
export { unifiedFontStore };
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
|
||||
Reference in New Issue
Block a user