BLK-31Blocks

CSS Gridの非対称レイアウト|成果で並び替える実績カード

React+Tailwind v4・レスポンシブ・コード付き。CSS Gridで先頭の1件だけを2×2に広げる非対称(ベントー型)の実績カード一覧。価格の位置に before→after と改善率を置き、新着順/改善率順の切り替えでカードが位置を変えながら主役の大枠が入れ替わる。サムネは案件ごとの図解(SVG)で画像素材なし。折り返しはコンテナクエリ基準、依存ライブラリなし、reduced-motion では即時に切り替える。

プレビュー

BLK-31 — Works / Showcase

数字で並べ替えられる実績一覧

並び替え

6件 ・ 公開月の新しい順。大枠は W-2601(2026.06)

改善率 =(after − before)÷ before で、件数・率・時間・金額を同じ物差しにする

すべての実績をみる

掲載の事例と数値は、見本用の架空データです。

X でシェア

説明の全文を読む

React+Tailwind v4・レスポンシブ・コード付き。CSS Gridで先頭の1件だけを2×2に広げる非対称(ベントー型)の実績カード一覧。価格の位置に before→after と改善率を置き、新着順/改善率順の切り替えでカードが位置を変えながら主役の大枠が入れ替わる。サムネは案件ごとの図解(SVG)で画像素材なし。折り返しはコンテナクエリ基準、依存ライブラリなし、reduced-motion では即時に切り替える。

追加日:
2026-08-19
更新日:
2026-11-07
依存:
なし
tags
#block #works #case-study #css-grid #grid #asymmetric #bento #container-query #sort #flip-animation #kpi #svg-diagram #stretched-link #no-image #no-dependency
"use client";

import { type ReactNode, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
import { Montserrat } from "next/font/google";

const montserrat = Montserrat({
  weight: ["600", "700", "800"],
  subsets: ["latin"],
  display: "swap",
});

/**
 * CSS Gridの非対称レイアウト|成果で並び替える実績カード / Asymmetric CSS Grid — Works Cards Sorted by Results
 * 通販サイトの商品一覧に見られる「グリッド分割」と「情報の詰め方の優先順位」を、
 * 実績・事例の情報設計へ置き換えて再構築したブロック。文言・配色・構成はすべてオリジナル、
 * 外部コード・素材の取り込みはなし。画像素材ゼロ・ライブラリ依存ゼロ。掲載の事例と数値は見本用の架空データ。
 *
 * 汎用技法メモ:
 * - 不揃いグリッド(1件だけ 2×2): 3カラムの grid に対し先頭の1件だけ col-span-2 row-span-2 を与えると、
 *   3×3=9セルを「大1+小5」でちょうど埋められる。並び替えで先頭が入れ替わると主役の枠も入れ替わり、
 *   「一番押したい1件」を構造で表現できる(カードを同じ大きさで並べるより一覧に主従が生まれる)。
 * - ビューポートではなくコンテナで折り返す: 親に @container を付け、@md: / @xl: のコンテナクエリで
 *   1→2→3カラムに切り替える。埋め込み先の幅が狭い(プレビュー枠・サイドバー内など)ときに、
 *   ビューポート基準の sm:/lg: では起きる「広い画面なのに箱は狭い」ズレが構造的に起きない。
 * - 価格の位置に成果指標: 商品一覧の視線は サムネ→ラベル→商品名→価格 の順に落ちる。この最後の「価格」を
 *   KPI(before → after + 変化率チップ)に置換すると、実績一覧が読み物ではなく「比較できる一覧」になる。
 *   数字は tabular-nums、参考価格の位置に before を小さい灰色で置くと変化量が一目で読める。
 * - カラースウォッチの転用: 商品の色バリエーション(小さな丸の列)を「担当した工程」の塗り/中抜きに置換。
 *   同じ形で違う意味を運べるので、EC由来の見た目を残したまま非ECの情報を載せられる。
 * - stretched link: セル内のリンクは h3 の <a> 1つだけにして after:absolute after:inset-0 でセル全面を
 *   クリック領域にする。<a> の入れ子を作らずにカード全体を押せる(クイックアクションの丸は装飾=aria-hidden)。
 * - 並び替えは FLIP で動かす: 押した瞬間に各カードの位置を測り(First)、並びを差し替えた直後に測り直して(Last)、
 *   差分だけ translate で戻してから 0 へ 220ms で動かす(Invert / Play)。grid の配置は即時に確定し、動くのは
 *   transform だけ。reduced-motion では動かさず即時に差し替える。結果は見える1文(role=status)でも伝える。
 * - 単位の違う成果を1本の物差しにする: 件数・率・時間・金額が混ざる一覧は、そのままでは順位を付けられない。
 *   改善率 =(after − before)÷ before を並び替えの基準にし、基準そのものをツールバーの下に書いておく。
 * - サムネは案件ごとの図解: 画像が無くても、導線・フロー・成果を表す小さな SVG 図を案件ごとに描き分けると、
 *   縮小しても6件を見分けられる(共通の地紋+種別名の反復だと、どのカードも同じ顔になる)。
 * - モーションは transform/opacity のみ・すべて motion-reduce ガード。リビールは IntersectionObserver で
 *   1回だけ発火させ、reduced-motion 環境では初期状態=最終状態にする。
 */

type Work = {
  id: string;
  code: string;
  kind: string;
  industry: string;
  title: string;
  excerpt: string;
  metric: string;
  before: string;
  after: string;
  lift: number;
  liftLabel: string;
  badge: string | null;
  phases: [boolean, boolean, boolean];
  added: string;
};

const PHASES = ["設計", "制作", "運用"] as const;

const works: Work[] = [
  {
    id: "w-2601",
    code: "W-2601",
    kind: "SITE",
    industry: "製造・金属加工",
    title: "工場見学の予約導線を、問い合わせの主役に",
    excerpt:
      "設備写真を並べる会社案内をやめ、見学予約を軸に再編。図面ダウンロードの手前で担当者の顔と連絡先を出し、比較検討中の相手を取りこぼさない構成にした。",
    metric: "月間問い合わせ数",
    before: "4件",
    after: "13件",
    lift: 225,
    liftLabel: "+225%",
    badge: "新着",
    phases: [true, true, false],
    added: "2026-06",
  },
  {
    id: "w-2555",
    code: "W-2555",
    kind: "LP",
    industry: "医療・歯科",
    title: "初診予約の離脱を、3ステップで止める",
    excerpt: "症状別の入口と費用の目安を先に見せ、入力項目を7から4へ。",
    metric: "予約完了率",
    before: "4.2%",
    after: "11.8%",
    lift: 181,
    liftLabel: "+181%",
    badge: null,
    phases: [false, true, true],
    added: "2026-05",
  },
  {
    id: "w-2512",
    code: "W-2512",
    kind: "SITE",
    industry: "建設・リフォーム",
    title: "施工事例を、更新できる資産にする",
    excerpt: "現場写真の投稿をスマホで完結。担当者が週1で更新できる実績データベースに。",
    metric: "平均滞在時間",
    before: "1:12",
    after: "3:04",
    lift: 156,
    liftLabel: "+156%",
    badge: "継続支援中",
    phases: [true, true, true],
    added: "2026-04",
  },
  {
    id: "w-2488",
    code: "W-2488",
    kind: "FORM",
    industry: "教育・スクール",
    title: "体験申込フォームの入力を、途中でやめさせない",
    excerpt: "住所の自動入力と一時保存を追加し、長い同意文は開閉式に。",
    metric: "体験申込の完了数",
    before: "11件",
    after: "26件",
    lift: 136,
    liftLabel: "+136%",
    badge: null,
    phases: [false, true, false],
    added: "2026-03",
  },
  {
    id: "w-2440",
    code: "W-2440",
    kind: "SHOP",
    industry: "食品・産直",
    title: "贈答セットの回遊をつくる特集ページ",
    excerpt: "用途別の入口と同梱提案を足し、単品購入から詰め合わせへ。",
    metric: "平均客単価",
    before: "3,480円",
    after: "5,120円",
    lift: 47,
    liftLabel: "+47%",
    badge: null,
    phases: [true, true, false],
    added: "2026-02",
  },
  {
    id: "w-2398",
    code: "W-2398",
    kind: "SITE",
    industry: "士業・社会保険労務",
    title: "専門用語をやめたら、相談が増えた",
    excerpt: "サービス名を悩みの言葉に置換し、料金の考え方を先出し。",
    metric: "資料ダウンロード数",
    before: "8件",
    after: "41件",
    lift: 413,
    liftLabel: "+413%",
    badge: "継続支援中",
    phases: [true, false, true],
    added: "2026-01",
  },
];

type SortKey = "new" | "impact";

const SORTS: { key: SortKey; label: string }[] = [
  { key: "new", label: "新着順" },
  { key: "impact", label: "改善率順" },
];

const INK = "#111827";
const LINE = "#d1d5db";
const SOFT = "#e5e7eb";
const AMBER = "#f59e0b";
const AMBER_DEEP = "#b45309";
const AMBER_SOFT = "#fef3c7";
const NOTE = "#6b7280";

/**
 * プレート(サムネの代替)の図解。案件ごとに「何を直したか」を描き分ける(viewBox 240×150・装飾なので aria-hidden)。
 * 図は work.id に結び付けるので、並び替えても図と案件の対応は崩れない。
 */
function PlateFigure({ id }: { id: string }) {
  let body: ReactNode = null;
  if (id === "w-2601") {
    // 会社案内のファーストビュー: 主役のボタンを「見学予約」にし、右に空き枠のカレンダー
    body = (
      <>
        <rect x="18" y="14" width="204" height="122" rx="7" fill="#fff" stroke={LINE} />
        <path d="M18 30h204" stroke={SOFT} />
        {[28, 36, 44].map((cx) => (
          <circle key={cx} cx={cx} cy="22" r="2.2" fill={LINE} />
        ))}
        <rect x="32" y="42" width="72" height="7" rx="2" fill={INK} />
        <rect x="32" y="54" width="54" height="7" rx="2" fill={INK} />
        <rect x="32" y="68" width="64" height="4" rx="2" fill={LINE} />
        <rect x="32" y="82" width="66" height="18" rx="9" fill={AMBER} />
        <rect x="44" y="89.5" width="42" height="3" rx="1.5" fill="#fff" />
        <rect x="32" y="108" width="66" height="14" rx="7" fill="none" stroke={LINE} />
        <rect x="46" y="113.75" width="38" height="2.5" rx="1.25" fill={LINE} />
        <rect x="118" y="40" width="90" height="84" rx="5" fill="#fff" stroke={SOFT} />
        <rect x="118" y="40" width="90" height="14" rx="5" fill={INK} />
        <rect x="118" y="48" width="90" height="6" fill={INK} />
        {Array.from({ length: 20 }, (_, i) => {
          const c = i % 5;
          const r = Math.floor(i / 5);
          const booked = i === 6 || i === 13;
          const picked = i === 17;
          return (
            <rect
              key={i}
              x={126 + c * 15}
              y={62 + r * 15}
              width="12"
              height="12"
              rx="2"
              fill={booked ? AMBER : picked ? AMBER_SOFT : SOFT}
              stroke={picked ? AMBER_DEEP : "none"}
              strokeWidth={picked ? 1.5 : 0}
            />
          );
        })}
      </>
    );
  } else if (id === "w-2555") {
    // 予約の3ステップと、入力項目 7 → 4
    body = (
      <>
        <path d="M54 56H186" stroke={LINE} strokeWidth="2" strokeDasharray="4 4" />
        <path d="M54 56H152" stroke={INK} strokeWidth="2" />
        {[54, 120].map((cx, i) => (
          <g key={cx}>
            <circle cx={cx} cy="56" r="17" fill={INK} />
            <text x={cx} y="56" fill="#fff" fontSize="13" fontWeight="700" textAnchor="middle" dominantBaseline="central">
              {i + 1}
            </text>
          </g>
        ))}
        <circle cx="186" cy="56" r="17" fill={AMBER} />
        <path d="M178 56l5 5 10-10" fill="none" stroke="#fff" strokeWidth="2.5" strokeLinecap="round" strokeLinejoin="round" />
        {Array.from({ length: 7 }, (_, i) => {
          const kept = i < 4;
          const x = 34 + i * 25;
          return (
            <g key={i}>
              <rect
                x={x}
                y="96"
                width="22"
                height="10"
                rx="5"
                fill={kept ? INK : "none"}
                stroke={kept ? "none" : LINE}
                strokeDasharray={kept ? undefined : "3 2"}
              />
              {!kept && <path d={`M${x + 2} 109L${x + 20} 93`} stroke={AMBER_DEEP} strokeWidth="1.5" />}
            </g>
          );
        })}
        <text x="120" y="128" fill={NOTE} fontSize="10" fontWeight="600" textAnchor="middle">
          入力 7 → 4 項目
        </text>
      </>
    );
  } else if (id === "w-2512") {
    // スマホで撮って投稿 → 施工事例のデータベースが1枠ずつ増える
    body = (
      <>
        <rect x="30" y="18" width="56" height="114" rx="10" fill="#fff" stroke={INK} strokeWidth="2" />
        <rect x="50" y="24" width="16" height="3" rx="1.5" fill={INK} />
        <rect x="38" y="34" width="40" height="48" rx="3" fill={AMBER_SOFT} />
        <path d="M38 82V76l12-14 9 9 7-6 12 13v4z" fill={AMBER} />
        <circle cx="69" cy="44" r="4" fill={AMBER} />
        <circle cx="58" cy="106" r="9" fill="none" stroke={INK} strokeWidth="2" />
        <circle cx="58" cy="106" r="5" fill={AMBER} />
        <path d="M96 75h26" stroke={INK} strokeWidth="2" />
        <path d="M116 69l7 6-7 6" fill="none" stroke={INK} strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" />
        {Array.from({ length: 16 }, (_, i) => {
          const x = 132 + (i % 4) * 23;
          const y = 28 + Math.floor(i / 4) * 23;
          if (i < 12) return <rect key={i} x={x} y={y} width="18" height="18" rx="3" fill={SOFT} />;
          if (i === 12) return <rect key={i} x={x} y={y} width="18" height="18" rx="3" fill={AMBER} />;
          return (
            <rect key={i} x={x} y={y} width="18" height="18" rx="3" fill="none" stroke={LINE} strokeDasharray="3 2" />
          );
        })}
        <text x="176" y="136" fill={NOTE} fontSize="10" fontWeight="600" textAnchor="middle">
          週1で追加
        </text>
      </>
    );
  } else if (id === "w-2488") {
    // 申込フォーム: 進み具合・郵便番号から住所を自動入力・同意文は開閉式
    body = (
      <>
        <rect x="48" y="12" width="144" height="126" rx="8" fill="#fff" stroke={LINE} />
        <rect x="62" y="24" width="116" height="4" rx="2" fill={SOFT} />
        <rect x="62" y="24" width="78" height="4" rx="2" fill={AMBER} />
        <rect x="62" y="38" width="24" height="3" rx="1.5" fill={LINE} />
        <rect x="62" y="44" width="52" height="14" rx="3" fill="#fff" stroke={INK} strokeWidth="1.5" />
        <text x="69" y="51.5" fill={INK} fontSize="9" fontWeight="700" textAnchor="middle" dominantBaseline="central">
          〒
        </text>
        <rect x="77" y="49.5" width="30" height="3" rx="1.5" fill={INK} />
        <path d="M127 43l-7 10h5l-3 8 9-11h-5l3-7z" fill={AMBER} />
        <rect x="62" y="66" width="24" height="3" rx="1.5" fill={LINE} />
        <rect x="62" y="72" width="116" height="14" rx="3" fill={AMBER_SOFT} stroke={AMBER} />
        <rect x="68" y="77.5" width="72" height="3" rx="1.5" fill={INK} />
        <rect x="62" y="94" width="116" height="14" rx="3" fill="#f9fafb" stroke={SOFT} />
        <rect x="68" y="99.5" width="44" height="3" rx="1.5" fill={LINE} />
        <path d="M166 98l4 3-4 3" fill="none" stroke={INK} strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
        <rect x="62" y="116" width="80" height="13" rx="6.5" fill={INK} />
        <rect x="148" y="116" width="30" height="13" rx="6.5" fill="none" stroke={LINE} />
        <rect x="155" y="121.25" width="16" height="2.5" rx="1.25" fill={LINE} />
      </>
    );
  } else if (id === "w-2440") {
    // 単品3つを、贈答の詰め合わせ1箱へまとめる
    body = (
      <>
        {[22, 60, 98].map((y) => (
          <g key={y}>
            <rect x="30" y={y} width="28" height="28" rx="6" fill="#fff" stroke={LINE} />
            <path d={`M60 ${y + 14}C88 ${y + 14} 92 85 112 85`} fill="none" stroke={LINE} strokeWidth="1.5" strokeDasharray="4 3" />
          </g>
        ))}
        <circle cx="44" cy="36" r="7" fill={AMBER_SOFT} stroke={AMBER} />
        <rect x="39" y="65" width="10" height="18" rx="3" fill={INK} />
        <rect x="37" y="106" width="14" height="12" rx="2" fill={SOFT} stroke={LINE} />
        <rect x="120" y="62" width="86" height="60" rx="4" fill={INK} />
        <rect x="114" y="48" width="98" height="18" rx="3" fill="#1f2937" />
        <rect x="158" y="48" width="10" height="74" fill={AMBER} />
        <path d="M163 48c-6-14-24-12-16 0z" fill={AMBER} />
        <path d="M163 48c6-14 24-12 16 0z" fill={AMBER} />
        <text x="163" y="138" fill={NOTE} fontSize="10" fontWeight="600" textAnchor="middle">
          単品 → 詰め合わせ
        </text>
      </>
    );
  } else if (id === "w-2398") {
    // 専門用語の見出しを、悩みの言葉へ置き換える + 資料ダウンロード数の前後(8 → 41 を同じ縮尺で)
    body = (
      <>
        <rect x="22" y="22" width="96" height="30" rx="8" fill="#fff" stroke={LINE} />
        <rect x="32" y="31" width="64" height="4" rx="2" fill={LINE} />
        <rect x="32" y="40" width="44" height="4" rx="2" fill={LINE} />
        <path d="M28 46L112 28" stroke={AMBER_DEEP} strokeWidth="2" strokeLinecap="round" />
        <rect x="22" y="70" width="96" height="42" rx="8" fill={AMBER_SOFT} stroke={AMBER} />
        <path d="M38 112l-4 10 14-10" fill={AMBER_SOFT} stroke={AMBER} strokeLinejoin="round" />
        <path d="M37 111.5h12" stroke={AMBER_SOFT} strokeWidth="2" />
        <rect x="32" y="80" width="72" height="5" rx="2.5" fill={INK} />
        <rect x="32" y="90" width="52" height="5" rx="2.5" fill={INK} />
        <rect x="32" y="100" width="30" height="4" rx="2" fill={NOTE} />
        <path d="M140 124H222" stroke={LINE} />
        <rect x="152" y="112" width="22" height="12" rx="2" fill={LINE} />
        <rect x="188" y="62" width="22" height="62" rx="2" fill={INK} />
        <text x="163" y="106" fill={NOTE} fontSize="10" fontWeight="700" textAnchor="middle">
          8
        </text>
        <text x="199" y="55" fill={INK} fontSize="11" fontWeight="800" textAnchor="middle">
          41
        </text>
        <text x="181" y="139" fill={NOTE} fontSize="9" fontWeight="600" textAnchor="middle">
          資料DL / 月
        </text>
      </>
    );
  }
  return (
    <svg
      aria-hidden="true"
      viewBox="0 0 240 150"
      preserveAspectRatio="xMidYMid meet"
      className="absolute inset-x-4 top-8 bottom-7 h-[calc(100%-3.75rem)] w-[calc(100%-2rem)] transition-transform duration-500 ease-out group-hover:scale-[1.03] motion-reduce:transition-none"
    >
      {body}
    </svg>
  );
}

/** 担当した工程(商品一覧のカラースウォッチの位置・見た目を転用) */
function PhaseSwatch({ phases }: { phases: Work["phases"] }) {
  const taken = PHASES.filter((_, i) => phases[i]);
  return (
    <p className="mt-3 flex items-center gap-2">
      <span aria-hidden="true" className="flex items-center gap-1">
        {phases.map((on, i) => (
          <span
            key={i}
            className={`size-2.5 rounded-full border ${
              on ? "border-gray-900 bg-gray-900" : "border-gray-300 bg-white"
            }`}
          />
        ))}
      </span>
      <span className="text-[11px] leading-none font-medium text-gray-400">
        <span className="sr-only">担当した工程: </span>
        {taken.join(" / ")}
      </span>
    </p>
  );
}

/** 価格の位置に置く成果指標(before → after + 変化率チップ) */
function MetricLine({
  work,
  large = false,
  keyed = false,
}: {
  work: Work;
  large?: boolean;
  /** 改善率順のときは、並び替えの基準になっている変化率チップを強める */
  keyed?: boolean;
}) {
  return (
    <div className="mt-3">
      <p className="flex flex-wrap items-baseline gap-x-2 gap-y-1">
        <span
          className={`${montserrat.className} text-[11px] font-semibold text-gray-400 tabular-nums line-through decoration-gray-300`}
        >
          {work.before}
        </span>
        <span
          className={`${montserrat.className} font-extrabold tracking-tight text-gray-900 tabular-nums ${
            large ? "text-[28px]" : "text-[21px]"
          }`}
        >
          {work.after}
        </span>
        <span
          className={`${montserrat.className} rounded-full px-2 py-0.5 text-[11px] font-bold tabular-nums ${
            keyed ? "bg-gray-900 text-amber-300" : "bg-amber-50 text-amber-700"
          }`}
        >
          <span className="sr-only">改善率 </span>
          {work.liftLabel}
        </span>
      </p>
      <p className="mt-1 text-[11px] leading-none text-gray-500">{work.metric}</p>
    </div>
  );
}

export default function CommerceGridLayout() {
  const [sort, setSort] = useState<SortKey>("new");
  const [active, setActive] = useState(false);
  const rootRef = useRef<HTMLDivElement>(null);
  // FLIP 用: カードの要素(id → article)と、並び替える直前の位置
  const cellRefs = useRef(new Map<string, HTMLElement>());
  const firstRects = useRef<Map<string, DOMRect> | null>(null);

  // 画面内に入ったら1回だけリビール(reduced-motion 時は motion-reduce: で初期状態=最終状態)
  useEffect(() => {
    const el = rootRef.current;
    if (!el || typeof IntersectionObserver === "undefined") {
      const id = requestAnimationFrame(() => setActive(true));
      return () => cancelAnimationFrame(id);
    }
    const io = new IntersectionObserver(
      (entries) => {
        if (entries.some((e) => e.isIntersecting)) {
          setActive(true);
          io.disconnect();
        }
      },
      { threshold: 0.15 },
    );
    io.observe(el);
    return () => io.disconnect();
  }, []);

  const sorted = useMemo(
    () =>
      [...works].sort((a, b) =>
        sort === "new" ? b.added.localeCompare(a.added) : b.lift - a.lift,
      ),
    [sort],
  );

  // First: 押した瞬間の位置を測ってから並びを差し替える(選択表示は同じ描画で即時に変わる)
  const changeSort = (key: SortKey) => {
    if (key === sort) return;
    const rects = new Map<string, DOMRect>();
    cellRefs.current.forEach((el, id) => rects.set(id, el.getBoundingClientRect()));
    firstRects.current = rects;
    setSort(key);
  };

  // Last → Invert → Play: 描画前に測り直し、差分を translate で戻してから 0 へ動かす
  useLayoutEffect(() => {
    const first = firstRects.current;
    firstRects.current = null;
    if (!first) return;
    if (window.matchMedia("(prefers-reduced-motion: reduce)").matches) return;
    cellRefs.current.forEach((el, id) => {
      const a = first.get(id);
      if (!a || typeof el.animate !== "function") return;
      const b = el.getBoundingClientRect();
      const dx = a.left - b.left;
      const dy = a.top - b.top;
      if (Math.abs(dx) < 1 && Math.abs(dy) < 1) return;
      el.animate([{ transform: `translate(${dx}px, ${dy}px)` }, { transform: "translate(0, 0)" }], {
        duration: 220,
        easing: "cubic-bezier(0.2, 0.8, 0.2, 1)",
      });
    });
  }, [sort]);

  const lead = sorted[0];
  const statusText =
    sort === "new"
      ? `公開月の新しい順。大枠は ${lead.code}(${lead.added.replace("-", ".")})`
      : `改善率の高い順。大枠は ${lead.code}(${lead.liftLabel})`;

  const reveal = `transition-[opacity,transform] duration-700 ease-out motion-reduce:transition-none ${
    active
      ? "translate-y-0 opacity-100"
      : "translate-y-6 opacity-0 motion-reduce:translate-y-0 motion-reduce:opacity-100"
  }`;
  const delay = (ms: number) => ({ transitionDelay: `${ms}ms` });

  return (
    <section
      ref={rootRef}
      aria-labelledby="cgl-heading"
      className="@container w-full max-w-6xl bg-white px-1"
    >
      {/* 見出しと並び替えを1段に詰め、最初の画面をグリッドに渡す */}
      <div
        style={delay(0)}
        className={`${reveal} flex flex-wrap items-end justify-between gap-x-6 gap-y-3`}
      >
        <div>
          <p
            className={`${montserrat.className} text-[11px] font-bold tracking-[0.25em] text-amber-600 uppercase`}
          >
            BLK-31 — Works / Showcase
          </p>
          <h2
            id="cgl-heading"
            className="mt-2 text-[20px] leading-[1.35] font-bold tracking-tight text-gray-900 @2xl:text-[24px]"
          >
            数字で
            <span className="relative inline-block">
              <span className="relative z-10">並べ替えられる</span>
              <span
                aria-hidden="true"
                className="absolute bottom-0 left-0 h-[3px] w-full bg-amber-500/70"
              />
            </span>
            実績一覧
          </h2>
        </div>
        {/* 並び替え(商品一覧の「並び替え」行の置換)。色の変化にトランジションを付けず即時に切り替える */}
        <div className="flex items-center gap-2 whitespace-nowrap">
          <span className="text-[11px] font-semibold text-gray-500">並び替え</span>
          <div className="flex items-center gap-1 rounded-full bg-gray-100 p-1">
            {SORTS.map((s) => (
              <button
                key={s.key}
                type="button"
                aria-pressed={sort === s.key}
                onClick={() => changeSort(s.key)}
                className={`rounded-full px-3 py-1.5 text-[12px] font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-600 ${
                  sort === s.key
                    ? "bg-white text-gray-900 shadow-[0_1px_2px_rgba(17,24,39,0.12)]"
                    : "text-gray-500 hover:text-gray-900"
                }`}
              >
                {s.label}
              </button>
            ))}
          </div>
        </div>
      </div>

      {/* 結果の1文と、並び替えの基準 */}
      <div
        style={delay(80)}
        className={`${reveal} mt-4 flex flex-wrap items-baseline justify-between gap-x-4 gap-y-1 border-y border-gray-200 py-2.5`}
      >
        <p role="status" aria-live="polite" className="text-[12px] font-semibold text-gray-800">
          <span className={`${montserrat.className} tabular-nums`}>{works.length}</span>件 ・ {statusText}
        </p>
        <p className="text-[11px] text-gray-500">
          改善率 =(after − before)÷ before で、件数・率・時間・金額を同じ物差しにする
        </p>
      </div>

      {/* 不揃いグリッド: 3カラム × 3行を「大1(2×2)+小5」で埋める(@xl=576px 以上で3列) */}
      <ul className="mt-5 grid grid-cols-1 gap-x-5 gap-y-7 @md:grid-cols-2 @xl:grid-cols-3">
        {sorted.map((w, i) => {
          const feature = i === 0;
          return (
            <li
              key={w.id}
              style={delay(160 + i * 70)}
              className={`${reveal} ${feature ? "@md:col-span-2 @xl:row-span-2" : ""}`}
            >
              <article
                ref={(el) => {
                  if (el) cellRefs.current.set(w.id, el);
                  else cellRefs.current.delete(w.id);
                }}
                className="group relative flex h-full flex-col border-b border-gray-200 pb-5"
              >
                {/* プレート(サムネの代替・案件ごとの図解) */}
                <div
                  className={`relative overflow-hidden rounded-lg border border-gray-200 bg-gray-50 ${
                    feature
                      ? "h-[136px] @md:h-[200px] @xl:h-auto @xl:max-h-[460px] @xl:min-h-[220px] @xl:flex-1"
                      : "aspect-[4/3]"
                  }`}
                >
                  <span
                    aria-hidden="true"
                    className="absolute inset-0"
                    style={{
                      backgroundImage: "radial-gradient(rgba(17,24,39,0.08) 1px, transparent 1px)",
                      backgroundSize: "12px 12px",
                    }}
                  />
                  <PlateFigure id={w.id} />

                  {/* ラベル(商品一覧のNEW/SALEバッジの位置) */}
                  {w.badge && (
                    <span
                      className={`absolute top-3 left-3 rounded-full px-2.5 py-0.5 text-[11px] font-semibold ${
                        w.badge === "新着"
                          ? "bg-amber-700 text-white"
                          : "border border-gray-300 bg-white/90 text-gray-600"
                      }`}
                    >
                      {w.badge}
                    </span>
                  )}

                  {/* 制作種別と標本番号(左下の小さな刻印) */}
                  <span
                    className={`${montserrat.className} absolute bottom-2 left-3 text-[10px] font-bold tracking-[0.2em] text-gray-500 tabular-nums`}
                  >
                    {w.kind} · {w.code}
                  </span>

                  {/* クイックアクション(商品一覧のカート追加ボタンの位置・装飾) */}
                  <span
                    aria-hidden="true"
                    className="absolute right-2 bottom-2 grid size-8 translate-y-0 place-items-center rounded-full bg-gray-900 text-[13px] text-white opacity-100 transition-[opacity,transform] duration-300 ease-out motion-reduce:transition-none @md:translate-y-2 @md:opacity-0 @md:group-hover:translate-y-0 @md:group-hover:opacity-100 @md:group-focus-within:translate-y-0 @md:group-focus-within:opacity-100"
                  >
                    →
                  </span>
                </div>

                {/* 情報(サムネ→ラベル→タイトル→数字の順に落とす) */}
                <div className="mt-3.5 flex flex-col">
                  <p className="flex items-center gap-2 text-[11px] font-semibold text-gray-500">
                    <span>{w.industry}</span>
                    <span aria-hidden="true" className="text-gray-300">
                      /
                    </span>
                    <span
                      className={`${montserrat.className} tabular-nums ${
                        sort === "new" ? "text-gray-900" : "text-gray-500"
                      }`}
                    >
                      {w.added.replace("-", ".")}
                    </span>
                  </p>

                  <h3
                    className={`mt-1.5 leading-[1.55] font-bold text-gray-900 ${
                      feature
                        ? "text-[16px] @xl:text-[19px]"
                        : "line-clamp-2 text-[14px] @md:min-h-[3.1em]"
                    }`}
                  >
                    <a
                      href="#"
                      className="after:absolute after:inset-0 after:content-[''] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-600"
                    >
                      {w.title}
                    </a>
                  </h3>

                  <MetricLine work={w} large={feature} keyed={sort === "impact"} />

                  {feature && (
                    <p className="mt-3 max-w-xl text-[13px] leading-[1.85] text-gray-500">
                      {w.excerpt}
                    </p>
                  )}

                  <PhaseSwatch phases={w.phases} />
                </div>

                {/* フィーチャーの余白を埋める擬似リンク行(実リンクは h3 の1本だけ=aria-hidden の装飾) */}
                {feature && (
                  <p
                    aria-hidden="true"
                    className="mt-auto hidden items-center gap-2 pt-5 text-[12px] font-semibold text-amber-700 @xl:flex"
                  >
                    この事例をみる
                    <span className="inline-block transition-transform duration-300 ease-out group-hover:translate-x-1 motion-reduce:transition-none">
                      →
                    </span>
                  </p>
                )}
              </article>
            </li>
          );
        })}
      </ul>

      {/* CTA(下線ワイプ) */}
      <div
        style={delay(640)}
        className={`${reveal} mt-8 flex flex-wrap items-center justify-between gap-x-6 gap-y-3`}
      >
        <a
          href="#"
          className="group inline-flex items-center gap-3 text-sm font-semibold text-gray-900 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-amber-600"
        >
          <span className="relative">
            すべての実績をみる
            <span
              aria-hidden="true"
              className="absolute -bottom-1 left-0 h-px w-full origin-left scale-x-100 bg-gray-900 transition-transform duration-300 ease-out group-hover:scale-x-0 motion-reduce:transition-none"
            />
            <span
              aria-hidden="true"
              className="absolute -bottom-1 left-0 h-px w-full origin-right scale-x-0 bg-amber-600 transition-transform delay-150 duration-300 ease-out group-hover:origin-left group-hover:scale-x-100 motion-reduce:transition-none"
            />
          </span>
          <span
            aria-hidden="true"
            className="inline-block transition-transform duration-300 ease-out group-hover:translate-x-1 motion-reduce:transition-none"
          >
            →
          </span>
        </a>
        <p className="text-[11px] text-gray-500">掲載の事例と数値は、見本用の架空データです。</p>
      </div>
    </section>
  );
}

shadcn CLI でプロジェクトに追加

npx shadcn@latest add https://designs.first-ch.com/r/commerce-grid-layout.json