chore: migrate from direct <link> with css towards font-face approach

This commit is contained in:
Ilia Mashkov
2026-02-02 12:10:38 +03:00
parent 961475dea0
commit a392b575cc

View File

@@ -20,6 +20,8 @@ interface Props {
* Font id to load
*/
id: string;
url: string;
/**
* Font weight
*/
@@ -34,7 +36,7 @@ interface Props {
children?: Snippet;
}
let { name, id, weight = 400, className, children }: Props = $props();
let { name, id, url, weight = 400, className, children }: Props = $props();
let element: Element;
// Track if the user has actually scrolled this into view
@@ -44,7 +46,7 @@ $effect(() => {
const observer = new IntersectionObserver(entries => {
if (entries[0].isIntersecting) {
hasEnteredViewport = true;
appliedFontsManager.touch([{ slug: id, weight }]);
appliedFontsManager.touch([{ id, weight, name, url }]);
// Once it has entered, we can stop observing to save CPU
observer.unobserve(element);
@@ -54,7 +56,7 @@ $effect(() => {
return () => observer.disconnect();
});
const status = $derived(appliedFontsManager.getFontStatus(id, weight, false));
const status = $derived(appliedFontsManager.getFontStatus(id, weight));
// The "Show" condition: Element is in view AND (Font is ready OR it errored out)
const shouldReveal = $derived(hasEnteredViewport && (status === 'loaded' || status === 'error'));