feature/comparison-slider #19
@@ -3,7 +3,7 @@
|
||||
- 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 ({ id: string } | [{ id: string }, { id: string }])">
|
||||
import { VirtualList } from '$shared/ui';
|
||||
import type { ComponentProps } from 'svelte';
|
||||
import { appliedFontsManager } from '../../model';
|
||||
@@ -16,7 +16,12 @@ let { items, children, onVisibleItemsChange, ...rest }: Props = $props();
|
||||
|
||||
function handleInternalVisibleChange(visibleItems: T[]) {
|
||||
// Auto-register fonts with the manager
|
||||
const slugs = visibleItems.map(item => item.id);
|
||||
const slugs = visibleItems.map(item => {
|
||||
if (Array.isArray(item)) {
|
||||
return item.map(font => font.id);
|
||||
}
|
||||
return item.id;
|
||||
}).flat();
|
||||
appliedFontsManager.registerFonts(slugs);
|
||||
|
||||
// Forward the call to any external listener
|
||||
|
||||
Reference in New Issue
Block a user