瀏覽代碼

feat: let the hero fill its card at every size

Where the hero spans the full width (up to portrait tablets) it is now a
row as tall as its content, as on phones, rather than a square with
empty space in it. Beside other cards it stays square: the byline holds
the top and the headline, bio and links hold the bottom as one block,
the headline breaks to "Hey, I'm / Eric." and grows when the card is
tall enough, and the bio scales with the card. The spare height under
the byline now stays within 28-76px at every width, down from up to
160px, and the gaps inside the block are an even 24px.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEPoSHwHCYMNpm2iKxY9hL
Claude 1 月之前
父節點
當前提交
5098229b57
共有 4 個文件被更改,包括 44 次插入 和 54 次删除
  1. 2 1
      app/page.tsx
  2. 21 14
      components/bento/bento-grid.tsx
  3. 8 6
      components/cards/hero.tsx
  4. 13 33
      styles/globals.css

+ 2 - 1
app/page.tsx

@@ -56,7 +56,8 @@ export default async function Page() {
         [2, 2],
       ],
       still: true,
-      // On phones a header row as tall as its content (its phone size is unused).
+      // Below 768px a full-width header row as tall as its content (the first
+      // three sizes go unused).
       header: true,
       content: <HeroCard avatarUrl={home.avatarUrl} dogUrl={home.dogUrl} />,
     },

+ 21 - 14
components/bento/bento-grid.tsx

@@ -70,7 +70,7 @@ type Drag = {
   cell: { x: number; y: number } | null;
   /** Reading order when the drag began: the others always re-pack in this order. */
   base: string[];
-  /** Rows above the packed cards (a phone header row), and where those cards start. */
+  /** Rows above the packed cards (a header row), and where those cards start. */
   shift: number;
   top: number;
 };
@@ -78,8 +78,11 @@ type Drag = {
 // Pointer-downs on these never start a card drag.
 const INTERACTIVE =
   "a,button,input,textarea,select,label,canvas,[data-nodrag],[contenteditable=true]";
-/** The tier whose header cards become a content-height row above the grid. */
-const HEADER_TIER = 0;
+/**
+ * Tiers where header cards span the full width, so they become a
+ * content-height row above the grid instead of a forced square.
+ */
+const HEADER_TIERS: ReadonlySet<number> = new Set([0, 1, 2]);
 /** Press and hold this long before a touch drag starts (quicker moves scroll). */
 const HOLD_MS = 380;
 /** Holding a card this close to the top or bottom of the viewport scrolls. */
@@ -133,7 +136,7 @@ export function BentoGrid({ items }: { items: BentoItem[] }) {
         (t, i) =>
           custom[`${view}:${i}`] ??
           pack(
-            i === HEADER_TIER
+            HEADER_TIERS.has(i)
               ? display.filter((id) => !byId.get(id)?.header)
               : display,
             (id) => byId.get(id)?.size[i] ?? [1, 1],
@@ -313,7 +316,7 @@ export function BentoGrid({ items }: { items: BentoItem[] }) {
       d.grabX = Math.min(Math.max(d.startX - r.left, 0), r.width);
       d.grabY = Math.min(Math.max(d.startY - r.top, 0), r.height);
       d.base = readingOrder(layoutsRef.current[d.tier]);
-      // On phones the packed cards start below the header row (or its gap, when hidden).
+      // Under a header row the packed cards start below it (or its gap, when hidden).
       if (d.shift) {
         const header = grid.querySelector<HTMLElement>(
           ":scope > [data-header]",
@@ -414,8 +417,8 @@ export function BentoGrid({ items }: { items: BentoItem[] }) {
       if (!el || !grid.contains(el)) return;
       const tier = tierFor(window.innerWidth);
 
-      // A phone header is a fixed row, not a card to move.
-      if (tier === HEADER_TIER && el.hasAttribute("data-header")) return;
+      // A header row is fixed, not a card to move.
+      if (HEADER_TIERS.has(tier) && el.hasAttribute("data-header")) return;
       const r = el.getBoundingClientRect();
       const d: Drag = {
         id: el.dataset.card!,
@@ -435,7 +438,9 @@ export function BentoGrid({ items }: { items: BentoItem[] }) {
         cell: null,
         base: [],
         shift:
-          tier === HEADER_TIER && grid.hasAttribute("data-has-header") ? 1 : 0,
+          HEADER_TIERS.has(tier) && grid.hasAttribute("data-has-header")
+            ? 1
+            : 0,
         top: 0,
       };
 
@@ -550,8 +555,8 @@ export function BentoGrid({ items }: { items: BentoItem[] }) {
             const c = layout.find((cell) => cell.id === id);
 
             if (!c) return;
-            // Under a phone header row the cards start one row down.
-            const shift = t === HEADER_TIER && hasHeader ? 1 : 0;
+            // Under a header row the cards start one row down.
+            const shift = HEADER_TIERS.has(t) && hasHeader ? 1 : 0;
 
             place[`--c${t}`] = c.x + 1;
             place[`--r${t}`] = c.y + 1 + shift;
@@ -559,10 +564,12 @@ export function BentoGrid({ items }: { items: BentoItem[] }) {
             place[`--h${t}`] = c.h;
           });
           if (item.header) {
-            place[`--c${HEADER_TIER}`] = 1;
-            place[`--r${HEADER_TIER}`] = 1;
-            place[`--w${HEADER_TIER}`] = TIERS[HEADER_TIER].cols;
-            place[`--h${HEADER_TIER}`] = 1;
+            HEADER_TIERS.forEach((t) => {
+              place[`--c${t}`] = 1;
+              place[`--r${t}`] = 1;
+              place[`--w${t}`] = TIERS[t].cols;
+              place[`--h${t}`] = 1;
+            });
           }
 
           return (

+ 8 - 6
components/cards/hero.tsx

@@ -31,7 +31,7 @@ export function HeroCard({
   dogUrl: string;
 }) {
   return (
-    <div className="relative flex h-full flex-col justify-between p-5 [container:hero/inline-size] min-[480px]:[container:hero/size] sm:p-6">
+    <div className="relative flex h-full flex-col p-5 [container:hero/inline-size] md:[container:hero/size] sm:p-6">
       <div className="flex items-center gap-3.5">
         <AvatarFlip avatarUrl={avatarUrl} dogUrl={dogUrl} />
         <div className="leading-tight">
@@ -51,11 +51,13 @@ export function HeroCard({
           </p>
         </div>
       </div>
-      {/* Byline, statement, and links share any spare height evenly. On phones
-          the card is as tall as its content, so they sit at these minimum gaps. */}
-      <div className="pt-5 min-[480px]:pt-6">
+      {/* The byline holds the top; the statement and its links hold the bottom
+          as one block, so any spare height is a single field of space under
+          the byline rather than gaps that pull the block apart. Below 768px
+          the card is as tall as its content and nothing is spare. */}
+      <div className="mt-auto pt-5 min-[480px]:pt-6">
         <HeroTitle />
-        <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:mt-5 lg:text-[19px]">
+        <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] md:mt-5 md:text-[clamp(16px,3.5cqi,21px)]">
           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
@@ -64,7 +66,7 @@ export function HeroCard({
       </div>
       <nav
         aria-label="Social links"
-        className="dock mt-6 flex items-center gap-2 lg:mt-7"
+        className="dock mt-6 flex items-center gap-2"
       >
         {socials.map((s) => (
           <a

+ 13 - 33
styles/globals.css

@@ -430,9 +430,10 @@ html.ff {
     }
   }
 
-  /* Phones: a header card (the hero) is a full-width row of its own, as tall
-     as its content, so it never carries empty space. */
-  @media (max-width: 479px) {
+  /* Up to portrait tablets the header card (the hero) spans the full width, so
+     it is a row of its own, as tall as its content, never a square with empty
+     space in it (lib/bento-layout tiers 0 to 2). */
+  @media (max-width: 767px) {
     .bento[data-has-header] {
       grid-template-rows: auto;
     }
@@ -969,35 +970,21 @@ html .notion-yt-lite {
 }
 
 /*
- * The hero headline: one line that grows with its card (it runs ~6.2em wide),
- * or "Hey, I'm / Eric." on two lines when a square card has the height for
- * it. How much height that takes depends on how the bio wraps, so each type
- * size gets its own threshold. (On phones the card fits its content, so the
- * line stays single.)
+ * The hero headline: one line that grows with its card (it runs ~6.2em wide).
+ * Below 768px the hero is a full-width row as tall as its content, so the line
+ * stays single. From 768px it is a square beside other cards: the headline
+ * breaks to "Hey, I'm / Eric." and grows once the card is tall enough, while
+ * the bio scales with the card, so the square fills alike at every size
+ * (measured: the spare height under the byline stays within 28-75px).
  */
 .hero-title {
   font-size: clamp(2rem, 15.5cqi, 5.2rem);
   line-height: 1.02;
 }
 
-/* Square cards, from wide phones up. */
-@media (max-width: 639px) {
-  @container hero (min-height: 480px) and (min-aspect-ratio: 9 / 10) {
+@media (min-width: 768px) {
+  @container hero (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;
     }
 
@@ -1005,17 +992,10 @@ html .notion-yt-lite {
       display: block;
     }
   }
-}
 
-@media (min-width: 1024px) {
-  @container hero (min-height: 500px) and (min-aspect-ratio: 9 / 10) {
+  @container hero (min-height: 472px) and (min-aspect-ratio: 9 / 10) {
     .hero-title {
       font-size: min(18.5cqi, 7.5rem);
-      line-height: 0.98;
-    }
-
-    .hero-tail {
-      display: block;
     }
   }
 }