Переглянути джерело

fix: recompose the hero card and align every card to one inset

The hero's headline and bio floated in the middle of the card, leaving
two large gaps, with a small hint line wedged under the headline.

- Headline, bio, and links now rest together at the foot of the card,
  so the space under the byline is the only gap.
- When the card has the height (phones, large squares), the headline
  breaks to "Hey, I'm / Eric." and fills the width; otherwise it stays
  on one line sized to the card. Thresholds follow each bio type size.
- The hint line is gone; the glass period swells once after load to
  invite a pull. The melt now follows the cursor across both lines.
- Wide phones and split views (480-639px) get a square hero.
- Every card's text starts on the same inset (20px on phones, 24px
  from 640px), and the photo deck and My Mini controls follow it, so
  cards stacked in a column line up.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEPoSHwHCYMNpm2iKxY9hL
Claude 1 місяць тому
батько
коміт
c6b7273135

+ 17 - 1
app/page.tsx

@@ -22,7 +22,8 @@ export default async function Page() {
   const [home, posts] = await Promise.all([getHomeData(), getLatestPosts()]);
 
   // Order matters: cards pack first-fit in this order. Sizes are columns × rows
-  // on phones (2 columns), small tablets (2), tablets (3), and desktops (4).
+  // on phones (2 columns), wide phones (2), small tablets (2), tablets (3), and
+  // desktops (4).
   // On tablets:
   //   [hero      ][sky  ]
   //   [hero      ][globe]
@@ -52,6 +53,7 @@ export default async function Page() {
         [2, 2],
         [2, 2],
         [2, 2],
+        [2, 2],
       ],
       still: true,
       content: <HeroCard avatarUrl={home.avatarUrl} dogUrl={home.dogUrl} />,
@@ -61,6 +63,7 @@ export default async function Page() {
       tags: ["work"],
       label: "AWS FinOps Agent",
       size: [
+        [2, 2],
         [2, 2],
         [2, 1],
         [3, 1],
@@ -73,6 +76,7 @@ export default async function Page() {
       tags: ["work"],
       label: "Amazon Q artifacts",
       size: [
+        [2, 2],
         [2, 2],
         [2, 1],
         [3, 1],
@@ -89,6 +93,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <SkyCard />,
     },
@@ -101,6 +106,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <GlobeCard />,
     },
@@ -113,6 +119,7 @@ export default async function Page() {
         [2, 1],
         [2, 1],
         [2, 1],
+        [2, 1],
       ],
       content: (
         <ProjectCard
@@ -127,6 +134,7 @@ export default async function Page() {
       tags: ["projects"],
       label: "PackBook",
       size: [
+        [2, 2],
         [2, 2],
         [1, 2],
         [1, 2],
@@ -143,6 +151,7 @@ export default async function Page() {
         [2, 2],
         [2, 2],
         [2, 2],
+        [2, 2],
       ],
       content: <PhotoDeck photos={home.photos} />,
     },
@@ -155,6 +164,7 @@ export default async function Page() {
         [1, 2],
         [1, 2],
         [1, 2],
+        [1, 2],
       ],
       content: (
         <ProjectCard
@@ -175,6 +185,7 @@ export default async function Page() {
         [2, 1],
         [2, 1],
         [2, 1],
+        [2, 1],
       ],
       content: (
         <ProjectCard
@@ -195,6 +206,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <TechSphere />,
     },
@@ -207,6 +219,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <MiniCard />,
     },
@@ -219,6 +232,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <EmojiCard />,
     },
@@ -231,6 +245,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: (
         <ProjectCard
@@ -247,6 +262,7 @@ export default async function Page() {
       tags: ["about"],
       label: "Latest writing",
       size: [
+        [2, 2],
         [2, 2],
         [2, 1],
         [2, 1],

+ 2 - 2
components/bento/bento-grid.tsx

@@ -35,8 +35,8 @@ import {
 export type BentoItem = {
   id: string;
   tags: View[];
-  /** Columns × rows in each layout tier (TIERS): phones, small tablets, tablets, desktops. */
-  size: readonly [Size, Size, Size, Size];
+  /** Columns × rows in each layout tier (TIERS): phones, wide phones, small tablets, tablets, desktops. */
+  size: readonly [Size, Size, Size, Size, Size];
   label: string;
   content: ReactNode;
   /** Skip the entrance animation (keep it off the LCP card). */

+ 1 - 1
components/cards/artifacts.tsx

@@ -226,7 +226,7 @@ export function ArtifactsCard() {
   }, [busy, active]);
 
   return (
-    <div className="flex h-full flex-col gap-4 p-5 sm:flex-row sm:gap-5 sm:p-6 lg:p-7">
+    <div className="flex h-full flex-col gap-4 p-5 sm:flex-row sm:gap-5 sm:p-6">
       <div className="flex flex-col sm:w-[40%] sm:shrink-0">
         <Eyebrow className="text-glacier-ink">AWS · Amazon Q</Eyebrow>
         <div className="mt-1 flex items-baseline justify-between gap-3">

+ 1 - 1
components/cards/emoji.tsx

@@ -61,7 +61,7 @@ export function EmojiCard() {
   return (
     <form
       ref={rootRef}
-      className="flex h-full flex-col gap-2 p-3 sm:gap-3 sm:p-5"
+      className="flex h-full flex-col gap-2 p-3 sm:gap-3 sm:p-6"
       onSubmit={submit}
     >
       <div className="relative grid min-h-0 flex-1 place-items-center">

+ 1 - 1
components/cards/finops.tsx

@@ -71,7 +71,7 @@ export function FinOpsCard() {
   }, []);
 
   return (
-    <div className="flex h-full flex-col gap-4 p-5 sm:flex-row sm:gap-5 sm:p-6 lg:p-7">
+    <div className="flex h-full flex-col gap-4 p-5 sm:flex-row sm:gap-5 sm:p-6">
       <div className="flex flex-col sm:w-[43%] sm:shrink-0">
         <Eyebrow accent>AWS · Public preview</Eyebrow>
         <div className="mt-1 flex items-baseline justify-between gap-3">

+ 1 - 1
components/cards/globe.tsx

@@ -192,7 +192,7 @@ export function GlobeCard() {
 
   return (
     <div className="@container relative h-full overflow-hidden">
-      <div className="absolute top-4 left-5 z-10 leading-tight @min-[220px]:top-5">
+      <div className="absolute top-5 left-5 z-10 leading-tight sm:top-6 sm:left-6">
         <p className="font-display text-[15px] leading-snug font-semibold tracking-[-0.005em] @min-[250px]:text-[17px]">
           Purdue → UCLA → Seattle
         </p>

+ 54 - 43
components/cards/hero-title.tsx

@@ -27,32 +27,34 @@ const letter = (ch: string, i: number) => (
   </span>
 );
 
-// From small tablets up the line scales with its card (it runs ~6.4em wide).
+// Sized in CSS (.hero-title): one line, or two when the card has the height.
 function Title({ clone }: { clone?: boolean }) {
   return (
     <h1
       aria-hidden={clone || undefined}
       aria-label={clone ? undefined : TEXT}
-      className="font-display text-[2.8rem] leading-[1.02] tracking-[-0.022em] whitespace-nowrap sm:text-[length:clamp(2.4rem,15.5cqi_+_2px,5.2rem)]"
+      className="hero-title font-display tracking-[-0.022em] whitespace-nowrap"
     >
       <span aria-hidden>
         {LEAD.split("").map(letter)}
-        <span className="hero-name">
-          {NAME.split("").map((ch, j) => letter(ch, LEAD.length + j))}
-        </span>
-        <span
-          className="inline-block"
-          data-period={clone ? undefined : ""}
-          data-wave={TEXT.length - 1}
-          style={REST}
-        >
-          .
-          {!clone && (
-            <span
-              className="inline-block size-0 align-baseline"
-              data-baseline
-            />
-          )}
+        <span className="hero-tail inline-block">
+          <span className="hero-name">
+            {NAME.split("").map((ch, j) => letter(ch, LEAD.length + j))}
+          </span>
+          <span
+            className="inline-block"
+            data-period={clone ? undefined : ""}
+            data-wave={TEXT.length - 1}
+            style={REST}
+          >
+            .
+            {!clone && (
+              <span
+                className="inline-block size-0 align-baseline"
+                data-baseline
+              />
+            )}
+          </span>
         </span>
       </span>
     </h1>
@@ -73,7 +75,6 @@ export function HeroTitle() {
   const handleRef = useRef<HTMLSpanElement>(null);
   const relayout = useRef<() => void>(() => {});
   const [map, setMap] = useState<LensMap | null>(null);
-  const [pulled, setPulled] = useState(false);
 
   /* ---------- Variable-weight wave ---------- */
   useEffect(() => {
@@ -92,16 +93,12 @@ export function HeroTitle() {
     ].filter((el) => !el.closest("[data-clone]"));
     let frame = 0;
 
-    /** `fx` gives each letter's closeness to the wave (0 to 1), or null for rest. */
-    const setWeights = (fx: (center: number) => number | null) => {
-      const centers = originals.map((el) => {
-        const r = el.getBoundingClientRect();
-
-        return r.left + r.width / 2;
-      });
+    /** `fx` gives each letter's closeness to the wave (0 to 1) from its box, or null for rest. */
+    const setWeights = (fx: (box: DOMRect) => number | null) => {
+      const boxes = originals.map((el) => el.getBoundingClientRect());
 
       originals.forEach((el, i) => {
-        const g = fx(centers[i]);
+        const g = fx(boxes[i]);
         const weight = g === null ? REST.fontWeight : Math.round(500 + 400 * g);
         const soft =
           g === null
@@ -116,15 +113,22 @@ export function HeroTitle() {
       // Heavier letters are wider: keep the bead on the period as it moves.
       relayout.current();
     };
-    const near = (x: number) => (c: number) =>
-      Math.exp(-((c - x) ** 2) / (2 * 64 ** 2));
+    // Closeness to a point; with no y, to a vertical line (the sweep crosses both lines at once).
+    const near = (x: number, y?: number) => (b: DOMRect) =>
+      Math.exp(
+        -(
+          (b.left + b.width / 2 - x) ** 2 +
+          (y === undefined ? 0 : (b.top + b.height / 2 - y) ** 2)
+        ) /
+          (2 * 64 ** 2),
+      );
 
     const onMove = (e: PointerEvent) => {
       if (e.pointerType === "touch") return;
-      const x = e.clientX;
+      const { clientX: x, clientY: y } = e;
 
       cancelAnimationFrame(frame);
-      frame = requestAnimationFrame(() => setWeights(near(x)));
+      frame = requestAnimationFrame(() => setWeights(near(x, y)));
     };
     const onLeave = () => {
       cancelAnimationFrame(frame);
@@ -265,6 +269,21 @@ export function HeroTitle() {
     settle();
     orb.style.opacity = "1";
 
+    // A moment after load the bead swells and settles once: a wink that it can be pulled.
+    let wink = false;
+    let winkTimer = 0;
+    const winkStart = still
+      ? 0
+      : window.setTimeout(() => {
+          if (held) return;
+          wink = true;
+          kick();
+          winkTimer = window.setTimeout(() => {
+            wink = false;
+            kick();
+          }, 700);
+        }, 2600);
+
     let frame = 0;
     let last = performance.now();
     let lift = 0;
@@ -273,7 +292,7 @@ export function HeroTitle() {
       const dt = Math.min(32, now - last) / 16.67;
       const goal = held ? target : home;
       // Hovering swells the bead a little: an invitation to pull it.
-      const goalS = held ? 1 : hover ? home.s * 1.55 : home.s;
+      const goalS = held ? 1 : hover || wink ? home.s * 1.55 : home.s;
 
       last = now;
       if (held) {
@@ -318,7 +337,7 @@ export function HeroTitle() {
         frame = requestAnimationFrame(step);
       } else {
         frame = 0;
-        if (!hover) settle();
+        if (!hover && !wink) settle();
       }
     };
     const kick = () => {
@@ -349,7 +368,6 @@ export function HeroTitle() {
       handle.setPointerCapture(e.pointerId);
       held = true;
       lift = e.pointerType === "touch" ? size * 0.85 : 0;
-      setPulled(true);
       aim(e);
       kick();
     };
@@ -395,6 +413,8 @@ export function HeroTitle() {
 
     return () => {
       cancelAnimationFrame(frame);
+      window.clearTimeout(winkStart);
+      window.clearTimeout(winkTimer);
       unlight();
       relayout.current = () => {};
       handle.removeEventListener("pointerdown", onDown);
@@ -450,15 +470,6 @@ export function HeroTitle() {
         data-cursor="Pull the period"
         data-nodrag
       />
-      <p
-        aria-hidden
-        className={cn(
-          "pointer-events-none mt-3 text-[13px] text-muted transition-opacity duration-500 max-sm:hidden",
-          pulled && "opacity-0",
-        )}
-      >
-        Psst, the period is liquid glass. Pull it.
-      </p>
     </div>
   );
 }

+ 11 - 8
components/cards/hero.tsx

@@ -31,7 +31,7 @@ export function HeroCard({
   dogUrl: string;
 }) {
   return (
-    <div className="@container relative flex h-full flex-col p-6 sm:p-7 lg:p-9">
+    <div className="relative flex h-full flex-col p-5 [container:hero/size] sm:p-6">
       <div className="flex items-center gap-3.5">
         <AvatarFlip avatarUrl={avatarUrl} dogUrl={dogUrl} />
         <div className="leading-tight">
@@ -51,22 +51,25 @@ export function HeroCard({
           </p>
         </div>
       </div>
-      <div className="my-auto py-6">
+      {/* Headline, bio, and links rest together at the foot of the card, so the
+          space above them is the only gap, whatever the card's height. */}
+      <div className="mt-auto pt-6">
         <HeroTitle />
-        <p className="mt-4 max-w-[32em] text-[16px] leading-[1.5] text-pretty text-muted sm:text-[17px] lg:text-[18px]">
+        <p className="mt-4 max-w-[32em] text-[16px] leading-[1.5] text-pretty text-muted @max-[270px]/hero:text-[15px] min-[480px]:text-[17px] lg:text-[18px]">
           An SDE II at AWS building agentic systems and generative UI. UCLA
           &amp; Purdue alum. Passionate about crafting AI experiences that make
           life easier. Outside work, I&apos;m hiking with my dog Bert and
           planning to summit Mount Rainier in 2027!
         </p>
-      </div>
-      <div>
-        <nav aria-label="Social links" className="dock flex items-center gap-2">
+        <nav
+          aria-label="Social links"
+          className="dock mt-6 flex items-center gap-2"
+        >
           {socials.map((s) => (
             <a
               key={s.label}
               aria-label={s.label}
-              className="lg grid size-10 place-items-center rounded-full transition-[scale,translate] duration-300 ease-out"
+              className="lg grid size-10 place-items-center rounded-full transition-[scale,translate] duration-300 ease-out @max-[270px]/hero:size-9"
               data-cursor={s.label}
               href={s.href}
               rel="noopener noreferrer"
@@ -84,7 +87,7 @@ export function HeroCard({
             </a>
           ))}
           <Link
-            className="lg ml-1 inline-flex h-10 items-center gap-2 rounded-full px-4 text-[13px] font-medium transition-[scale] duration-300 hover:scale-[1.04]"
+            className="lg ml-1 inline-flex h-10 items-center gap-2 rounded-full px-4 text-[13px] font-medium transition-[scale] duration-300 hover:scale-[1.04] @max-[270px]/hero:h-9 @max-[270px]/hero:px-3.5"
             data-cursor="Writing"
             href="/blog"
           >

+ 2 - 2
components/cards/mini-card.tsx

@@ -32,7 +32,7 @@ export function MiniCard() {
 
   return (
     <div className="relative h-full">
-      <p className="absolute top-4 left-5 z-10 font-display text-[17px] font-semibold tracking-[-0.005em] sm:top-5">
+      <p className="absolute top-5 left-5 z-10 font-display text-[17px] font-semibold tracking-[-0.005em] sm:top-6 sm:left-6">
         My Mini
       </p>
       {show3D ? (
@@ -55,7 +55,7 @@ export function MiniCard() {
             sizes="(max-width: 640px) 40vw, 240px"
             src={mini}
           />
-          <span className="lg absolute bottom-4 left-1/2 -translate-x-1/2 rounded-full px-3 py-1 text-[12px] font-medium whitespace-nowrap">
+          <span className="lg absolute bottom-5 left-1/2 -translate-x-1/2 rounded-full px-3 py-1 text-[12px] font-medium whitespace-nowrap sm:bottom-6">
             <span className="lg-caustic" />
             <span>Tap for 3D</span>
           </span>

+ 2 - 2
components/cards/photo-deck.tsx

@@ -179,7 +179,7 @@ export function PhotoDeck({ photos }: { photos: string[] }) {
       onPointerEnter={(e) => e.pointerType !== "touch" && setFanned(true)}
       onPointerLeave={() => setFanned(false)}
     >
-      <div className="absolute inset-x-0 top-0 z-20 flex items-center justify-between p-5">
+      <div className="absolute inset-x-0 top-0 z-20 flex items-center justify-between p-5 sm:p-6">
         <p className="font-display text-[17px] font-semibold tracking-[-0.005em]">
           Field notes
         </p>
@@ -237,7 +237,7 @@ export function PhotoDeck({ photos }: { photos: string[] }) {
           })}
       </div>
 
-      <div className="absolute right-4 bottom-4 z-20 flex gap-2">
+      <div className="absolute right-5 bottom-5 z-20 flex gap-2 sm:right-6 sm:bottom-6">
         {([-1, 1] as const).map((dir) => (
           <button
             key={dir}

+ 1 - 1
components/cards/sky.tsx

@@ -544,7 +544,7 @@ export function SkyCard() {
         style={{ backgroundImage: GRAIN }}
       />
 
-      <div className="relative flex h-full flex-col justify-between p-4 [text-shadow:0_1px_10px_rgb(0_0_0/0.18)] sm:p-5">
+      <div className="relative flex h-full flex-col justify-between p-5 [text-shadow:0_1px_10px_rgb(0_0_0/0.18)] sm:p-6">
         <div className="flex items-start justify-between gap-2">
           <div className="min-w-0 flex-1 leading-none">
             <p className="flex items-center gap-1 text-[15px] font-semibold">

+ 1 - 1
components/cards/tech-sphere.tsx

@@ -210,7 +210,7 @@ export function TechSphere() {
   }, []);
 
   return (
-    <div className="relative flex h-full flex-col p-4 sm:p-5">
+    <div className="relative flex h-full flex-col p-5 sm:p-6">
       <p className="font-display text-[17px] font-semibold tracking-[-0.005em]">
         Toolbox
       </p>

+ 2 - 1
lib/bento-layout.ts

@@ -16,10 +16,11 @@ export type Cell = { id: string; x: number; y: number; w: number; h: number };
 /**
  * Layout tiers: columns, and the viewport width where each starts. Cells stay
  * between ~230px and ~350px from small tablets up, the range the cards' larger
- * type is drawn for; phones get their own sizes.
+ * type is drawn for; phones get their own sizes (wide phones a square hero).
  */
 export const TIERS = [
   { cols: 2, min: 0 },
+  { cols: 2, min: 480 },
   { cols: 2, min: 640 },
   { cols: 3, min: 768 },
   { cols: 4, min: 1024 },

+ 73 - 3
styles/globals.css

@@ -381,27 +381,34 @@ html.ff {
     grid-row: var(--r0) / span var(--h0);
   }
 
-  @media (min-width: 640px) {
+  @media (min-width: 480px) {
     .bento > .card {
       grid-column: var(--c1) / span var(--w1);
       grid-row: var(--r1) / span var(--h1);
     }
   }
 
-  @media (min-width: 768px) {
+  @media (min-width: 640px) {
     .bento > .card {
       grid-column: var(--c2) / span var(--w2);
       grid-row: var(--r2) / span var(--h2);
     }
   }
 
-  @media (min-width: 1024px) {
+  @media (min-width: 768px) {
     .bento > .card {
       grid-column: var(--c3) / span var(--w3);
       grid-row: var(--r3) / span var(--h3);
     }
   }
 
+  @media (min-width: 1024px) {
+    .bento > .card {
+      grid-column: var(--c4) / span var(--w4);
+      grid-row: var(--r4) / span var(--h4);
+    }
+  }
+
   /* Where the held card will land: a soft, empty well of glass. */
   .bento-ghost {
     border-radius: 28px;
@@ -924,6 +931,69 @@ html .notion-yt-lite {
   background-color: transparent;
 }
 
+/*
+ * The hero headline: one line that grows with its card (it runs ~6.4em wide),
+ * or "Hey, I'm / Eric." on two lines when the card has the height for it.
+ * How much height that takes depends on how the bio wraps, so each type size
+ * (phones 16px, tablets 17px, desktops 18px) gets its own threshold.
+ */
+.hero-title {
+  font-size: clamp(2rem, 15.5cqi, 5.2rem);
+  line-height: 1.02;
+}
+
+/* Tall phone cards. */
+@container hero (min-height: 470px) and (max-aspect-ratio: 9 / 10) {
+  .hero-title {
+    font-size: 23cqi;
+    line-height: 0.98;
+  }
+
+  .hero-tail {
+    display: block;
+  }
+}
+
+/* Square cards, from wide phones up. */
+@media (max-width: 639px) {
+  @container hero (min-height: 480px) and (min-aspect-ratio: 9 / 10) {
+    .hero-title {
+      font-size: min(18.5cqi, 7.5rem);
+      line-height: 0.98;
+    }
+
+    .hero-tail {
+      display: block;
+    }
+  }
+}
+
+@media (min-width: 640px) and (max-width: 1023px) {
+  @container hero (min-height: 470px) and (min-aspect-ratio: 9 / 10) {
+    .hero-title {
+      font-size: min(18.5cqi, 7.5rem);
+      line-height: 0.98;
+    }
+
+    .hero-tail {
+      display: block;
+    }
+  }
+}
+
+@media (min-width: 1024px) {
+  @container hero (min-height: 500px) and (min-aspect-ratio: 9 / 10) {
+    .hero-title {
+      font-size: min(18.5cqi, 7.5rem);
+      line-height: 0.98;
+    }
+
+    .hero-tail {
+      display: block;
+    }
+  }
+}
+
 /* The name in the hero: a sky-to-blush gradient, Apple Intelligence style. */
 .hero-name {
   font-family: var(--font-name);