Browse Source

fix: tablet and narrow-desktop layouts

Between 640px and 1023px the grid used four columns, so cards shrank to
138-240px while switching to their desktop type: the headline, FinOps,
Q artifacts, globe, and writing cards were clipped or overlapping.

- Grid tiers are now 2/2/3/4 columns at 0/640/768/1024px, which keeps
  cells between ~230px and ~350px from small tablets up. Tablets get a
  hole-free three-column arrangement.
- The headline scales with its card, so the glass period never runs off
  the edge (it was clipped at 1024px).
- FinOps: the cost chart sits below the notifications instead of poking
  through them, with a third notification only when there's room.
- Q artifacts: short panels drop the prompt bubble so the chart keeps
  its height; bar labels truncate instead of spilling out; the table
  shows whole rows only.
- Globe title and PackBook footer fit narrow cards.
- The footer shows Ctrl K or ⌘K to match the platform, like the nav.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QEPoSHwHCYMNpm2iKxY9hL
Claude 1 month ago
parent
commit
be1ec002f7

+ 29 - 2
app/page.tsx

@@ -22,7 +22,19 @@ 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), tablets, and desktops (4 columns). On desktop:
+  // on phones (2 columns), small tablets (2), tablets (3), and desktops (4).
+  // On tablets:
+  //   [hero      ][sky  ]
+  //   [hero      ][globe]
+  //   [finops           ]
+  //   [artifacts        ]
+  //   [secondself][pack ]
+  //   [photos    ][pack ]
+  //   [photos    ][web  ]
+  //   [chatbot   ][web  ]
+  //   [tech][mini][emoji]
+  //   [paper][writing   ]
+  // On desktop:
   //   [hero      ][finops    ]
   //   [hero      ][artifacts ]
   //   [sky][globe][secondself]
@@ -37,7 +49,8 @@ export default async function Page() {
       label: "About Eric",
       size: [
         [2, 3],
-        [2, 3],
+        [2, 2],
+        [2, 2],
         [2, 2],
       ],
       still: true,
@@ -50,6 +63,7 @@ export default async function Page() {
       size: [
         [2, 2],
         [2, 1],
+        [3, 1],
         [2, 1],
       ],
       content: <FinOpsCard />,
@@ -61,6 +75,7 @@ export default async function Page() {
       size: [
         [2, 2],
         [2, 1],
+        [3, 1],
         [2, 1],
       ],
       content: <ArtifactsCard />,
@@ -73,6 +88,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <SkyCard />,
     },
@@ -84,6 +100,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <GlobeCard />,
     },
@@ -95,6 +112,7 @@ export default async function Page() {
         [2, 1],
         [2, 1],
         [2, 1],
+        [2, 1],
       ],
       content: (
         <ProjectCard
@@ -112,6 +130,7 @@ export default async function Page() {
         [2, 2],
         [1, 2],
         [1, 2],
+        [1, 2],
       ],
       content: <PackBookCard />,
     },
@@ -123,6 +142,7 @@ export default async function Page() {
         [2, 2],
         [2, 2],
         [2, 2],
+        [2, 2],
       ],
       content: <PhotoDeck photos={home.photos} />,
     },
@@ -134,6 +154,7 @@ export default async function Page() {
         [1, 2],
         [1, 2],
         [1, 2],
+        [1, 2],
       ],
       content: (
         <ProjectCard
@@ -153,6 +174,7 @@ export default async function Page() {
         [2, 1],
         [2, 1],
         [2, 1],
+        [2, 1],
       ],
       content: (
         <ProjectCard
@@ -172,6 +194,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <TechSphere />,
     },
@@ -183,6 +206,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <MiniCard />,
     },
@@ -194,6 +218,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: <EmojiCard />,
     },
@@ -205,6 +230,7 @@ export default async function Page() {
         [1, 1],
         [1, 1],
         [1, 1],
+        [1, 1],
       ],
       content: (
         <ProjectCard
@@ -224,6 +250,7 @@ export default async function Page() {
         [2, 2],
         [2, 1],
         [2, 1],
+        [2, 1],
       ],
       content: <WritingCard posts={posts} />,
     },

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

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

+ 6 - 5
components/cards/artifacts.tsx

@@ -64,7 +64,7 @@ function RegionChart() {
           <button
             key={r.name}
             aria-label={`${r.name}: $${r.value.toLocaleString()}`}
-            className="flex h-full flex-1 flex-col items-center justify-end gap-1"
+            className="flex h-full min-w-0 flex-1 flex-col items-center justify-end gap-1"
             type="button"
             onFocus={() => setHover(i)}
             onPointerEnter={() => setHover(i)}
@@ -111,11 +111,12 @@ function InstanceTable() {
           CPU {dir === -1 ? "↓" : "↑"}
         </button>
       </div>
-      <ul className="min-h-0 flex-1 overflow-hidden">
+      {/* Rows that don't fit wrap into a hidden second column: only whole rows show. */}
+      <ul className="flex min-h-0 flex-1 flex-col flex-wrap overflow-hidden">
         {rows.map((r, i) => (
           <li
             key={r.id}
-            className="grid grid-cols-[1fr_1.2fr_1fr] items-center border-b border-line/70 py-[5px] [animation:rise_.4s_ease_both]"
+            className="grid w-full grid-cols-[1fr_1.2fr_1fr] items-center border-b border-line/70 py-[5px] [animation:rise_.4s_ease_both]"
             style={{ animationDelay: `${i * 40}ms` }}
           >
             <span className="font-mono text-[10.5px] text-glacier-ink">
@@ -253,7 +254,7 @@ export function ArtifactsCard() {
       </div>
 
       <div
-        className="flex min-h-0 flex-1 flex-col gap-2 rounded-[20px] bg-inset p-2.5 ring-1 ring-line ring-inset"
+        className="flex min-h-0 flex-1 flex-col gap-2 rounded-[20px] bg-inset p-2.5 ring-1 ring-line ring-inset [container-type:size]"
         data-nodrag
       >
         <div
@@ -286,7 +287,7 @@ export function ArtifactsCard() {
             </button>
           ))}
         </div>
-        <p className="ml-auto max-w-[90%] truncate rounded-[14px] rounded-br-[5px] bg-glacier-ink px-2.5 py-1 text-[11.5px] text-white dark:text-[#06223a]">
+        <p className="ml-auto max-w-[90%] truncate rounded-[14px] rounded-br-[5px] bg-glacier-ink px-2.5 py-1 text-[11.5px] text-white [@container(height<185px)]:hidden dark:text-[#06223a]">
           {TABS[index].prompt}
         </p>
         <div className="relative min-h-0 flex-1 rounded-[14px] bg-card/75 p-2.5 dark:bg-black/25">

+ 45 - 37
components/cards/finops.tsx

@@ -99,7 +99,7 @@ export function FinOpsCard() {
 
       <div
         ref={rootRef}
-        className="relative min-h-0 flex-1 cursor-pointer overflow-hidden rounded-[20px] bg-gradient-to-b from-inset to-[color-mix(in_oklab,var(--blush)_34%,var(--card-inset))] ring-1 ring-line ring-inset dark:to-[color-mix(in_oklab,var(--ember)_12%,var(--card-inset))]"
+        className="relative min-h-0 flex-1 cursor-pointer overflow-hidden rounded-[20px] [container-type:size] bg-gradient-to-b from-inset to-[color-mix(in_oklab,var(--blush)_34%,var(--card-inset))] ring-1 ring-line ring-inset dark:to-[color-mix(in_oklab,var(--ember)_12%,var(--card-inset))]"
         data-cursor="Replay"
         data-nodrag
         role="button"
@@ -107,40 +107,48 @@ export function FinOpsCard() {
         onClick={play}
         onKeyDown={(e) => (e.key === "Enter" || e.key === " ") && play()}
       >
-        <svg
-          aria-label="Daily cost over 30 days with a spike on day 23"
-          className="absolute inset-x-0 bottom-0 h-[52%] w-full"
-          preserveAspectRatio="none"
-          role="img"
-          viewBox={`0 0 ${W} ${H}`}
-        >
-          <defs>
-            <linearGradient id="finops-area" x1="0" x2="0" y1="0" y2="1">
-              <stop offset="0" stopColor="var(--glacier)" stopOpacity="0.28" />
-              <stop offset="1" stopColor="var(--glacier)" stopOpacity="0" />
-            </linearGradient>
-          </defs>
-          <path d={`${PATH} L${W} ${H} L0 ${H} Z`} fill="url(#finops-area)" />
-          <path
-            d={PATH}
-            fill="none"
-            stroke="var(--glacier)"
-            strokeLinejoin="round"
-            strokeWidth="2"
-            vectorEffect="non-scaling-stroke"
-          />
-        </svg>
-        <span
-          aria-hidden
-          className="absolute size-2.5 -translate-x-1/2 -translate-y-1/2"
-          style={{
-            left: `${(x(SPIKE) / W) * 100}%`,
-            top: `${48 + (y(DAYS[SPIKE]) / H) * 52}%`,
-          }}
-        >
-          <span className="absolute inset-0 animate-ping-soft rounded-full bg-ember" />
-          <span className="absolute inset-0 rounded-full bg-ember ring-2 ring-card" />
-        </span>
+        {/* The chart sits below the notifications: three when the panel is
+            tall enough, else two (46px each, 6px apart, from 10px down). */}
+        <div className="absolute inset-x-0 top-[168px] bottom-0 [@container(height<220px)]:top-[116px]">
+          <svg
+            aria-label="Daily cost over 30 days with a spike on day 23"
+            className="absolute inset-0 size-full"
+            preserveAspectRatio="none"
+            role="img"
+            viewBox={`0 0 ${W} ${H}`}
+          >
+            <defs>
+              <linearGradient id="finops-area" x1="0" x2="0" y1="0" y2="1">
+                <stop
+                  offset="0"
+                  stopColor="var(--glacier)"
+                  stopOpacity="0.28"
+                />
+                <stop offset="1" stopColor="var(--glacier)" stopOpacity="0" />
+              </linearGradient>
+            </defs>
+            <path d={`${PATH} L${W} ${H} L0 ${H} Z`} fill="url(#finops-area)" />
+            <path
+              d={PATH}
+              fill="none"
+              stroke="var(--glacier)"
+              strokeLinejoin="round"
+              strokeWidth="2"
+              vectorEffect="non-scaling-stroke"
+            />
+          </svg>
+          <span
+            aria-hidden
+            className="absolute size-2.5 -translate-x-1/2 -translate-y-1/2"
+            style={{
+              left: `${(x(SPIKE) / W) * 100}%`,
+              top: `${(y(DAYS[SPIKE]) / H) * 100}%`,
+            }}
+          >
+            <span className="absolute inset-0 animate-ping-soft rounded-full bg-ember" />
+            <span className="absolute inset-0 rounded-full bg-ember ring-2 ring-card" />
+          </span>
+        </div>
 
         <ol
           className="absolute inset-x-2.5 top-2.5 flex flex-col gap-1.5"
@@ -153,8 +161,8 @@ export function FinOpsCard() {
               <li
                 key={n.title}
                 className={cn(
-                  "lg flex items-start gap-2.5 rounded-[16px] bg-card/60 px-3 py-2 [--lg-blur:14px] [animation:notify_.55s_cubic-bezier(.2,.9,.25,1.15)_both] dark:bg-card/45",
-                  k > 1 && "max-sm:hidden",
+                  "lg flex h-[46px] items-start gap-2.5 rounded-[16px] bg-card/60 px-3 py-2 [--lg-blur:14px] [animation:notify_.55s_cubic-bezier(.2,.9,.25,1.15)_both] dark:bg-card/45",
+                  k > 1 && "[@container(height<220px)]:hidden",
                 )}
               >
                 <span className="lg-caustic" />

+ 7 - 5
components/cards/globe.tsx

@@ -191,16 +191,18 @@ export function GlobeCard() {
   }, [resolvedTheme]);
 
   return (
-    <div className="relative h-full overflow-hidden">
-      <div className="absolute top-4 left-5 z-10 leading-tight sm:top-5">
-        <p className="font-display text-[15px] leading-snug font-semibold tracking-[-0.005em] sm:text-[17px]">
+    <div className="@container relative h-full overflow-hidden">
+      <div className="absolute top-4 left-5 z-10 leading-tight @min-[220px]:top-5">
+        <p className="font-display text-[15px] leading-snug font-semibold tracking-[-0.005em] @min-[250px]:text-[17px]">
           Purdue → UCLA → Seattle
         </p>
-        <p className="text-[12px] text-muted max-sm:hidden">Drag to spin</p>
+        <p className="text-[12px] text-muted @max-[220px]:hidden">
+          Drag to spin
+        </p>
       </div>
       <div
         ref={wrapRef}
-        className="absolute inset-x-[-14%] top-[30%] aspect-square sm:top-[12%]"
+        className="absolute inset-x-[-14%] top-[30%] aspect-square @min-[220px]:top-[12%]"
       >
         <canvas
           ref={canvasRef}

+ 2 - 1
components/cards/hero-title.tsx

@@ -27,12 +27,13 @@ const letter = (ch: string, i: number) => (
   </span>
 );
 
+// From small tablets up the line scales with its card (it runs ~6.4em wide).
 function Title({ clone }: { clone?: boolean }) {
   return (
     <h1
       aria-hidden={clone || undefined}
       aria-label={clone ? undefined : TEXT}
-      className="font-display text-[clamp(2.8rem,6.8vw,5.2rem)] leading-[1.02] tracking-[-0.022em] whitespace-nowrap"
+      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)]"
     >
       <span aria-hidden>
         {LEAD.split("").map(letter)}

+ 1 - 1
components/cards/hero.tsx

@@ -31,7 +31,7 @@ export function HeroCard({
   dogUrl: string;
 }) {
   return (
-    <div className="relative flex h-full flex-col p-6 sm:p-7 lg:p-9">
+    <div className="@container relative flex h-full flex-col p-6 sm:p-7 lg:p-9">
       <div className="flex items-center gap-3.5">
         <AvatarFlip avatarUrl={avatarUrl} dogUrl={dogUrl} />
         <div className="leading-tight">

+ 4 - 3
components/cards/packbook.tsx

@@ -69,7 +69,7 @@ export function PackBookCard() {
   return (
     <div
       ref={rootRef}
-      className="flex h-full gap-4 p-5 max-sm:flex-row sm:flex-col sm:p-6"
+      className="@container flex h-full gap-4 p-5 max-sm:flex-row sm:flex-col sm:p-6"
       onPointerEnter={(e) => {
         if (e.pointerType !== "touch") {
           setLoaded((n) => Math.max(n, 3));
@@ -135,12 +135,13 @@ export function PackBookCard() {
       </button>
 
       <div className="hidden items-center justify-between sm:flex">
-        <div className="-ml-[9px] flex">
+        {/* On a narrow card the dots tighten up to leave room for the link. */}
+        <div className="-ml-[9px] flex @max-[215px]:-ml-[5px]">
           {SCREENS.map((s, i) => (
             <button
               key={s.label}
               aria-label={`Show ${s.label}`}
-              className="group/dot grid size-6 place-items-center"
+              className="group/dot grid size-6 place-items-center @max-[215px]:w-4"
               type="button"
               onClick={() => go(i)}
             >

+ 18 - 0
components/nav/shortcut.tsx

@@ -0,0 +1,18 @@
+"use client";
+
+import { useSyncExternalStore } from "react";
+
+const noSubscribe = () => () => {};
+const platformShortcut = () =>
+  /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent)
+    ? "⌘K"
+    : "Ctrl K";
+
+/** The command palette's shortcut as this platform writes it (⌘K until hydrated). */
+export const useShortcut = () =>
+  useSyncExternalStore(noSubscribe, platformShortcut, () => "⌘K");
+
+/** The same label, for server-rendered places like the footer. */
+export function Shortcut() {
+  return useShortcut();
+}

+ 3 - 18
components/nav/site-nav.tsx

@@ -3,15 +3,10 @@
 import dynamic from "next/dynamic";
 import { usePathname, useRouter } from "next/navigation";
 import { useTheme } from "next-themes";
-import {
-  useCallback,
-  useEffect,
-  useRef,
-  useState,
-  useSyncExternalStore,
-} from "react";
+import { useCallback, useEffect, useRef, useState } from "react";
 
 import { LiquidGlass, useGlassLight } from "@/components/glass/liquid-glass";
+import { useShortcut } from "@/components/nav/shortcut";
 import { springs } from "@/lib/motion";
 import { switchTheme } from "@/lib/theme-transition";
 import { cn } from "@/lib/utils";
@@ -31,12 +26,6 @@ const TABS: Tab[] = [
   { id: "blog", label: "Blog" },
 ];
 
-const noSubscribe = () => () => {};
-const platformShortcut = () =>
-  /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent)
-    ? "⌘K"
-    : "Ctrl K";
-
 export function SiteNav() {
   const pathname = usePathname();
   const router = useRouter();
@@ -45,11 +34,7 @@ export function SiteNav() {
   const activeId = pathname.startsWith("/blog") ? "blog" : onHome ? view : null;
   const activeIndex = TABS.findIndex((t) => t.id === activeId);
   const [paletteOpen, setPaletteOpen] = useState(false);
-  const shortcut = useSyncExternalStore(
-    noSubscribe,
-    platformShortcut,
-    () => "⌘K",
-  );
+  const shortcut = useShortcut();
 
   const select = useCallback(
     (id: Tab["id"]) => {

+ 2 - 1
components/site-footer.tsx

@@ -1,3 +1,4 @@
+import { Shortcut } from "@/components/nav/shortcut";
 import { siteConfig } from "@/config/site";
 
 export function SiteFooter() {
@@ -9,7 +10,7 @@ export function SiteFooter() {
           {" "}
           ·{" "}
           <kbd className="rounded-md border border-line px-1.5 py-0.5 font-sans text-[11px]">
-            ⌘K
+            <Shortcut />
           </kbd>{" "}
           to explore
         </span>

+ 16 - 4
lib/bento-layout.ts

@@ -13,15 +13,27 @@
 export type Size = readonly [w: number, h: number];
 export type Cell = { id: string; x: number; y: number; w: number; h: number };
 
-/** Layout tiers: columns, and the viewport width where each starts. */
+/**
+ * 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.
+ */
 export const TIERS = [
   { cols: 2, min: 0 },
-  { cols: 4, min: 640 },
+  { cols: 2, min: 640 },
+  { cols: 3, min: 768 },
   { cols: 4, min: 1024 },
 ] as const;
 
-export const tierFor = (width: number) =>
-  width >= TIERS[2].min ? 2 : width >= TIERS[1].min ? 1 : 0;
+export const tierFor = (width: number) => {
+  let tier = 0;
+
+  TIERS.forEach((t, i) => {
+    if (width >= t.min) tier = i;
+  });
+
+  return tier;
+};
 
 /** First fit from the top-left, in order (what CSS `row dense` does). */
 export function pack(

+ 15 - 2
styles/globals.css

@@ -388,13 +388,20 @@ html.ff {
     }
   }
 
-  @media (min-width: 1024px) {
+  @media (min-width: 768px) {
     .bento > .card {
       grid-column: var(--c2) / span var(--w2);
       grid-row: var(--r2) / span var(--h2);
     }
   }
 
+  @media (min-width: 1024px) {
+    .bento > .card {
+      grid-column: var(--c3) / span var(--w3);
+      grid-row: var(--r3) / span var(--h3);
+    }
+  }
+
   /* Where the held card will land: a soft, empty well of glass. */
   .bento-ghost {
     border-radius: 28px;
@@ -414,13 +421,19 @@ html.ff {
 
   @media (min-width: 640px) {
     .bento {
-      --cols: 4;
       --gap: 14px;
     }
   }
 
+  @media (min-width: 768px) {
+    .bento {
+      --cols: 3;
+    }
+  }
+
   @media (min-width: 1024px) {
     .bento {
+      --cols: 4;
       --gap: 18px;
     }
   }