refactor(font): inject font-load status as a prop, decoupling UI from the store

FontApplicator and FontSampler no longer read fontLifecycleManager. They take a
`status` prop (FontLoadStatus | undefined) supplied by the composing widget;
FontList and SampleList resolve status once per visible row and pass it down.

FSD+ dependency inversion: the entity/feature UI depends on a value, not the
lifecycle store. Removes FontApplicator's value-import of the store (one step
toward an inert ./ui barrel) and drops the duplicate getFontStatus read per row
in FontList. FontSampler is now status-decoupled and trivially relocatable to
entities/Font/ui.
This commit is contained in:
Ilia Mashkov
2026-06-01 12:06:30 +03:00
parent 28a8e49915
commit fcd61be4fa
6 changed files with 52 additions and 46 deletions
@@ -6,11 +6,10 @@
<script lang="ts">
import { cn } from '$shared/lib';
import type { Snippet } from 'svelte';
import {
DEFAULT_FONT_WEIGHT,
type UnifiedFont,
fontLifecycleManager,
} from '../../model';
import type {
FontLoadStatus,
UnifiedFont,
} from '../../model/types';
interface Props {
/**
@@ -18,10 +17,13 @@ interface Props {
*/
font: UnifiedFont;
/**
* Font weight
* @default 400
* Current load status for this font, supplied by the composing layer.
* Kept out of the component so it does not depend on (and import) the
* lifecycle store — the owning widget reads the manager and passes the
* resolved status down. `undefined` means the font is not tracked yet and
* is treated as not-yet-revealed (skeleton / system-font fallback).
*/
weight?: number;
status: FontLoadStatus | undefined;
/**
* CSS classes
*/
@@ -39,20 +41,12 @@ interface Props {
let {
font,
weight = DEFAULT_FONT_WEIGHT,
status,
className,
children,
skeleton,
}: Props = $props();
const status = $derived(
fontLifecycleManager.getFontStatus(
font.id,
weight,
font.features?.isVariable,
),
);
const shouldReveal = $derived(status === 'loaded' || status === 'error');
</script>