From 6e8376b8fca2ab964e5e6758b11c860a3d332512 Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Mon, 12 Jan 2026 08:51:36 +0300 Subject: [PATCH] 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. --- src/app/ui/Layout.svelte | 20 +++++ src/routes/Page.svelte | 173 +++++++++++++++++++++++++++++++++++++-- 2 files changed, 184 insertions(+), 9 deletions(-) diff --git a/src/app/ui/Layout.svelte b/src/app/ui/Layout.svelte index 920662e..1f59a65 100644 --- a/src/app/ui/Layout.svelte +++ b/src/app/ui/Layout.svelte @@ -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 }; diff --git a/src/routes/Page.svelte b/src/routes/Page.svelte index 1c3ee63..36559bd 100644 --- a/src/routes/Page.svelte +++ b/src/routes/Page.svelte @@ -1,16 +1,171 @@ - -

Welcome to Svelte + Vite

-

- Visit svelte.dev/docs to read the documentation -

+
+
+

Font Browser

+

+ Browse and compare fonts from multiple providers +

+
+ + + {#if testResults.length > 0} +
+

Feature Validation Tests

+
    + {#each testResults as result} +
  • + {result} +
  • + {/each} +
+
+ {/if} + + +
+
+

+ Font List + + ({unifiedFontStore.count} total, {unifiedFontStore.filteredFonts.length} + displayed) + +

+
+
+ +
+
+ + +
+

Debug Information

+
+
+

Loading: {unifiedFontStore.isLoading}

+

Error: {unifiedFontStore.error || 'None'}

+
+
+

+ Providers filter: { + unifiedFontStore.filters.providers.join(', ') || 'All' + } +

+

+ Categories filter: { + unifiedFontStore.filters.categories.join(', ') || 'All' + } +

+
+
+

+ Subsets filter: { + unifiedFontStore.filters.subsets.join(', ') || 'All' + } +

+

Search query: {unifiedFontStore.searchQuery || 'None'}

+
+
+

Sort field: {unifiedFontStore.sort.field}

+

Sort direction: {unifiedFontStore.sort.direction}

+
+
+
+