diff --git a/src/widgets/ComparisonSlider/ui/ComparisonSlider/components/Labels.svelte b/src/widgets/ComparisonSlider/ui/ComparisonSlider/components/Labels.svelte index 8ac4499..96bc85b 100644 --- a/src/widgets/ComparisonSlider/ui/ComparisonSlider/components/Labels.svelte +++ b/src/widgets/ComparisonSlider/ui/ComparisonSlider/components/Labels.svelte @@ -6,6 +6,7 @@ import { FontVirtualList, type UnifiedFont, + unifiedFontStore, } from '$entities/Font'; import FontApplicator from '$entities/Font/ui/FontApplicator/FontApplicator.svelte'; import { displayedFontsStore } from '$features/DisplayFont'; @@ -35,19 +36,18 @@ interface Props { let { fontA, fontB, sliderPos }: Props = $props(); const fontList = $derived( - displayedFontsStore.fonts.filter(font => font.name !== fontA.name && font.name !== fontB.name), + // displayedFontsStore.fonts.filter(font => font.name !== fontA.name && font.name !== fontB.name), + unifiedFontStore.fonts, ); -function selectFontA(fontId: string) { - const newFontA = displayedFontsStore.getById(fontId); - if (!newFontA) return; - displayedFontsStore.fontA = newFontA; +function selectFontA(font: UnifiedFont) { + if (!font) return; + displayedFontsStore.fontA = font; } -function selectFontB(fontId: string) { - const newFontB = displayedFontsStore.getById(fontId); - if (!newFontB) return; - displayedFontsStore.fontB = newFontB; +function selectFontB(font: UnifiedFont) { + if (!font) return; + displayedFontsStore.fontB = font; } @@ -55,58 +55,84 @@ function selectFontB(fontId: string) { name: string, id: string, fonts: UnifiedFont[], - handleChange: (value: string) => void, + selectFont: (font: UnifiedFont) => void, + align: 'start' | 'end', )} -
e.stopPropagation())} - > - +
e.stopPropagation())}> + - - {name} - +
+ + {name} + +
- - {#snippet children({ item: font })} - - - {font.name} - - - {/snippet} - +
+ + {#snippet children({ item: font })} + {@const handleClick = () => selectFont(font)} + + + {font.name} + + + {/snippet} + +
{/snippet} -
+
- - Baseline - - {@render fontSelector(fontB.name, fontB.id, fontList, selectFontB)} +
+
+
+ + ch_01 + +
+ {@render fontSelector(fontB.name, fontB.id, fontList, selectFontB, 'start')}
85 ? 0 : 1} + class="flex flex-col items-end text-right gap-2 transition-all duration-500" + style:opacity={sliderPos > 80 ? 0 : 1} + style:transform="translateY({sliderPos > 80 ? '8px' : '0px'})" > - - Comparison - - {@render fontSelector(fontA.name, fontA.id, fontList, selectFontA)} +
+ + ch_02 + +
+
+
+ {@render fontSelector(fontA.name, fontA.id, fontList, selectFontA, 'end')}