Procházet zdrojové kódy

fix: show the gradient name on iPhone; keep the headline serif

Safari clips a background-clip: text gradient only to an element's own
inline text, so the per-letter inline-block spans left "Eric" fully
transparent on every iPhone. The name's letters are now plain inline
spans, which the melt effect handles the same way.

Every font variable now has a static fallback, so a missing one (for
example, a page from an older deploy) can no longer void the headline's
font stack and drop it to the body sans. The glass bead also sizes
itself from the smaller of the dot's measures, since WebKit reports the
advance rather than the ink for its width.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEPoSHwHCYMNpm2iKxY9hL
Claude před 1 měsícem
rodič
revize
9b0591307d
2 změnil soubory, kde provedl 19 přidání a 11 odebrání
  1. 9 5
      components/cards/hero-title.tsx
  2. 10 6
      styles/globals.css

+ 9 - 5
components/cards/hero-title.tsx

@@ -16,10 +16,10 @@ const FILTER_ID = "hero-droplet-lens";
 /** Matches the wrapper's px-1/py-1, so the clone inside the lens lines up with the title. */
 /** Matches the wrapper's px-1/py-1, so the clone inside the lens lines up with the title. */
 const PAD = 4;
 const PAD = 4;
 
 
-const letter = (ch: string, i: number) => (
+const letter = (ch: string, i: number, block = true) => (
   <span
   <span
     key={i}
     key={i}
-    className={cn("inline-block", ch === " " && "w-[0.24em]")}
+    className={cn(block && "inline-block", ch === " " && "w-[0.24em]")}
     data-wave={i}
     data-wave={i}
     style={REST}
     style={REST}
   >
   >
@@ -36,10 +36,12 @@ function Title({ clone }: { clone?: boolean }) {
       className="hero-title font-display tracking-[-0.022em] whitespace-nowrap"
       className="hero-title font-display tracking-[-0.022em] whitespace-nowrap"
     >
     >
       <span aria-hidden>
       <span aria-hidden>
-        {LEAD.split("").map(letter)}
+        {LEAD.split("").map((ch, i) => letter(ch, i))}
         <span className="hero-tail inline-block">
         <span className="hero-tail inline-block">
+          {/* Plain inline letters: WebKit clips the gradient only to the
+              name's own inline text, so inline-block letters would vanish. */}
           <span className="hero-name">
           <span className="hero-name">
-            {NAME.split("").map((ch, j) => letter(ch, LEAD.length + j))}
+            {NAME.split("").map((ch, j) => letter(ch, LEAD.length + j, false))}
           </span>
           </span>
           <span
           <span
             className="inline-block"
             className="inline-block"
@@ -219,7 +221,9 @@ export function HeroTitle() {
         right = m.actualBoundingBoxRight;
         right = m.actualBoundingBoxRight;
         ascent = m.actualBoundingBoxAscent;
         ascent = m.actualBoundingBoxAscent;
       }
       }
-      const dot = Math.max(right - left, ascent);
+      // The dot is round. Some engines give the advance rather than the ink
+      // for its width, so trust the smaller measure.
+      const dot = Math.min(right - left, ascent);
 
 
       home.x = r.left - w.left + (left + right) / 2;
       home.x = r.left - w.left + (left + right) / 2;
       home.y = base.getBoundingClientRect().top - w.top - ascent / 2;
       home.y = base.getBoundingClientRect().top - w.top - ascent / 2;

+ 10 - 6
styles/globals.css

@@ -4,10 +4,10 @@
 
 
 @theme inline {
 @theme inline {
   --font-sans:
   --font-sans:
-    -apple-system, BlinkMacSystemFont, "SF Pro Text", var(--ff-text),
+    -apple-system, BlinkMacSystemFont, "SF Pro Text", var(--ff-text, Figtree),
     ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
     ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
-  --font-display: var(--display-face);
-  --font-name: var(--name-face);
+  --font-display: var(--display-face, ui-serif, Georgia, serif);
+  --font-name: var(--name-face, ui-serif, Georgia, serif);
   --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
   --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
 
 
   --color-bg: var(--bg);
   --color-bg: var(--bg);
@@ -42,15 +42,19 @@
 /* ---------- Tokens ---------- */
 /* ---------- Tokens ---------- */
 
 
 /* Display type: a metric-matched fallback until Fraunces arrives after the
 /* Display type: a metric-matched fallback until Fraunces arrives after the
-   first paint (components/font-loader.tsx), then Fraunces. */
+   first paint (components/font-loader.tsx), then Fraunces. Every var() has a
+   fallback, so a missing variable (say, a page from an older deploy) can never
+   void the whole stack and drop the headline to the body sans. */
 :root {
 :root {
   --display-face: "Fraunces Fallback", ui-serif, Georgia, serif;
   --display-face: "Fraunces Fallback", ui-serif, Georgia, serif;
   --name-face: "Fraunces Fallback", ui-serif, Georgia, serif;
   --name-face: "Fraunces Fallback", ui-serif, Georgia, serif;
 }
 }
 
 
 html.ff {
 html.ff {
-  --display-face: var(--ff-display), ui-serif, Georgia, serif;
-  --name-face: var(--ff-name), var(--ff-display), ui-serif, Georgia, serif;
+  --display-face: var(--ff-display, Fraunces), ui-serif, Georgia, serif;
+  --name-face:
+    var(--ff-name, Fraunces), var(--ff-display, Fraunces), ui-serif, Georgia,
+    serif;
 }
 }
 
 
 /* A gentle settle when the display face swaps in. */
 /* A gentle settle when the display face swaps in. */