Selaa lähdekoodia

fix: re-place the glass period when the web fonts land

On a first visit the display face swaps in late (html.ff) and moves the
period; if that happened after the opening sweep, the bead stayed where
the fallback face had put it. It now follows the swap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEPoSHwHCYMNpm2iKxY9hL
Claude 1 kuukausi sitten
vanhempi
sitoutus
2864c6579d
1 muutettua tiedostoa jossa 12 lisäystä ja 0 poistoa
  1. 12 0
      components/cards/hero-title.tsx

+ 12 - 0
components/cards/hero-title.tsx

@@ -499,6 +499,17 @@ export function HeroTitle() {
       copyCard();
       relayout.current();
     });
+    // On a first visit the web fonts land late (html.ff) and move the period.
+    const html = document.documentElement;
+    let fonts = html.classList.contains("ff");
+    const mo = new MutationObserver(() => {
+      if (html.classList.contains("ff") === fonts) return;
+      fonts = !fonts;
+      copyCard();
+      relayout.current();
+    });
+
+    mo.observe(html, { attributes: true, attributeFilter: ["class"] });
 
     return () => {
       cancelAnimationFrame(frame);
@@ -514,6 +525,7 @@ export function HeroTitle() {
       handle.removeEventListener("pointerleave", onLeave);
       window.removeEventListener("resize", onResize);
       ro.disconnect();
+      mo.disconnect();
     };
   }, []);