chore: incorporate renewed appliderFontStore and comparisonStore logic

This commit is contained in:
Ilia Mashkov
2026-02-02 12:18:20 +03:00
parent 072690270f
commit 31a72d90ea
3 changed files with 53 additions and 26 deletions

View File

@@ -3,25 +3,35 @@
- Renders a virtualized list of fonts
- Handles font registration with the manager
-->
<script lang="ts" generics="T extends { id: string }">
<script lang="ts" generics="T extends UnifiedFont">
import type { FontConfigRequest } from '$entities/Font/model/store/appliedFontsStore/appliedFontsStore.svelte';
import { VirtualList } from '$shared/ui';
import type { ComponentProps } from 'svelte';
import { appliedFontsManager } from '../../model';
import {
type UnifiedFont,
appliedFontsManager,
} from '../../model';
interface Props extends Omit<ComponentProps<typeof VirtualList<T>>, 'onVisibleItemsChange'> {
onVisibleItemsChange?: (items: T[]) => void;
onNearBottom?: (lastVisibleIndex: number) => void;
weight: number;
}
let { items, children, onVisibleItemsChange, onNearBottom, ...rest }: Props = $props();
let { items, children, onVisibleItemsChange, onNearBottom, weight, ...rest }: Props = $props();
function handleInternalVisibleChange(visibleItems: T[]) {
// Auto-register fonts with the manager
const slugs = visibleItems.map(item => item.id);
appliedFontsManager.registerFonts(slugs);
const configs = visibleItems.map<FontConfigRequest>(item => ({
id: item.id,
name: item.name,
weight,
url: item.styles.regular!,
}));
appliedFontsManager.touch(configs);
// Forward the call to any external listener
onVisibleItemsChange?.(visibleItems);
// // Forward the call to any external listener
// onVisibleItemsChange?.(visibleItems);
}
function handleNearBottom(lastVisibleIndex: number) {