From 4eeb43fa3426acc0cbf304d2dccd6690d6466441 Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Tue, 13 Jan 2026 20:05:33 +0300 Subject: [PATCH] chore: delete unused code --- src/app/ui/Layout.svelte | 20 ---- src/entities/Font/model/types/store.ts | 38 ------ src/routes/Page.svelte | 160 ++----------------------- 3 files changed, 8 insertions(+), 210 deletions(-) diff --git a/src/app/ui/Layout.svelte b/src/app/ui/Layout.svelte index 1f59a65..920662e 100644 --- a/src/app/ui/Layout.svelte +++ b/src/app/ui/Layout.svelte @@ -12,34 +12,14 @@ * * 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/entities/Font/model/types/store.ts b/src/entities/Font/model/types/store.ts index c93d5f4..1aa26bd 100644 --- a/src/entities/Font/model/types/store.ts +++ b/src/entities/Font/model/types/store.ts @@ -46,41 +46,3 @@ export interface FontCollectionSort { /** Sort direction */ direction: 'asc' | 'desc'; } - -/** - * Font collection store interface - */ -export interface FontCollectionStore { - /** Main state store */ - state: import('svelte/store').Writable; - /** All fonts as array */ - fonts: import('svelte/store').Readable; - /** Filtered fonts as array */ - filteredFonts: import('svelte/store').Readable; - /** Number of fonts in collection */ - count: import('svelte/store').Readable; - /** Loading state */ - isLoading: import('svelte/store').Readable; - /** Error state */ - error: import('svelte/store').Readable; - /** Add fonts to collection */ - addFonts: (fonts: UnifiedFont[]) => void; - /** Add single font to collection */ - addFont: (font: UnifiedFont) => void; - /** Remove font from collection */ - removeFont: (fontId: string) => void; - /** Clear all fonts */ - clear: () => void; - /** Update filters */ - setFilters: (filters: Partial) => void; - /** Clear filters */ - clearFilters: () => void; - /** Update sort configuration */ - setSort: (sort: FontCollectionSort) => void; - /** Get font by ID */ - getFont: (fontId: string) => UnifiedFont | undefined; - /** Get fonts by provider */ - getFontsByProvider: (provider: FontProvider) => UnifiedFont[]; - /** Get fonts by category */ - getFontsByCategory: (category: FontCategory) => UnifiedFont[]; -} diff --git a/src/routes/Page.svelte b/src/routes/Page.svelte index 36559bd..a89438d 100644 --- a/src/routes/Page.svelte +++ b/src/routes/Page.svelte @@ -8,164 +8,20 @@ * * Receives unifiedFontStore from context created in Layout.svelte. */ -import { - UNIFIED_FONT_STORE_KEY, - type UnifiedFontStore, -} from '$entities/Font/model/store/unifiedFontStore.svelte'; +// import { +// UNIFIED_FONT_STORE_KEY, +// type UnifiedFontStore, +// } from '$entities/Font/model/store/unifiedFontStore.svelte'; import FontList from '$entities/Font/ui/FontList/FontList.svelte'; -import { applyFilters } from '$features/FontManagement'; +// import { applyFilters } from '$features/FontManagement'; import { getContext, onMount, } from 'svelte'; // Receive store from context (created in Layout.svelte) -const unifiedFontStore: UnifiedFontStore = getContext(UNIFIED_FONT_STORE_KEY); - -let testResults: string[] = $state([]); - -async function runTests() { - const results: string[] = []; - - // Test 1: Basic Fetch - try { - await unifiedFontStore.fetchFonts(); - results.push(`✓ Test 1 - Basic fetch: ${unifiedFontStore.count} fonts loaded`); - } catch (e) { - results.push(`✗ Test 1 - Basic fetch: ${e}`); - } - - // Test 2: Filter functionality - try { - const initialCount = unifiedFontStore.filteredFonts.length; - unifiedFontStore.setFilter('providers', ['google']); - const afterFilter = unifiedFontStore.filteredFonts.length; - results.push(`✓ Test 2 - Provider filter: ${initialCount} → ${afterFilter} fonts`); - unifiedFontStore.clearFilters(); - } catch (e) { - results.push(`✗ Test 2 - Provider filter: ${e}`); - } - - // Test 3: Search functionality - try { - unifiedFontStore.searchQuery = 'Roboto'; - const searchResults = unifiedFontStore.filteredFonts.length; - results.push(`✓ Test 3 - Search "Roboto": ${searchResults} results`); - unifiedFontStore.searchQuery = ''; - } catch (e) { - results.push(`✗ Test 3 - Search: ${e}`); - } - - // Test 4: Provider separation - try { - unifiedFontStore.setFilter('providers', ['google']); - await unifiedFontStore.fetchFonts(); - const googleFonts = unifiedFontStore.filteredFonts.length; - - unifiedFontStore.setFilter('providers', ['fontshare']); - await unifiedFontStore.fetchFonts(); - const fontshareFonts = unifiedFontStore.filteredFonts.length; - - unifiedFontStore.setFilter('providers', ['google', 'fontshare']); - await unifiedFontStore.fetchFonts(); - const bothFonts = unifiedFontStore.filteredFonts.length; - - results.push( - `✓ Test 4 - Providers: Google=${googleFonts}, Fontshare=${fontshareFonts}, Both=${bothFonts}`, - ); - unifiedFontStore.clearFilters(); - } catch (e) { - results.push(`✗ Test 4 - Provider separation: ${e}`); - } - - // Test 5: Apply filters - try { - await applyFilters(unifiedFontStore); - results.push( - `✓ Test 5 - applyFilters(): ${unifiedFontStore.filteredFonts.length} fonts displayed`, - ); - } catch (e) { - results.push(`✗ Test 5 - applyFilters(): ${e}`); - } - - testResults = results; -} - -onMount(() => { - runTests(); -}); +// const unifiedFontStore: UnifiedFontStore = getContext(UNIFIED_FONT_STORE_KEY); -
-
-

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}

-
-
-
-
+ +