3-Second Homepage Test — Missed vs. Missing on a Bakery Hero
A 3-second first-view test for small-shop homepages. A fictional bakery hero is shown for three seconds and hidden, then three questions (signature item, nearest station, today's closing time) are judged as read, shown-but-missed, not shown ("couldn't find it" is a correct observation) or guessed — and the matching spot lights up on the page. Next, tap to find five fixes (headline, photo, feature row, hours band, button) with before/after and the reason. Copy a request message to run the same test with an acquaintance on your own homepage, copy the fixed hero as React code, and send a result line plus a quiz URL to X. Answers stay in the browser.
Preview
パン屋のトップ3秒テスト
架空の店「こむぎ堂」で試します
書いてあるのに見落とす所と、そもそも書いていない所を分けて見つける
このパン屋、今日何時まで?
トップを3秒だけ見て、3つの質問に答えます
ボタンを押すと、こむぎ堂のトップが3秒だけ出て、すぐ隠れます。
なぜ3秒か・このテストについて
3秒は、Lyssna(ユーザーテストのサービス)の短時間提示テストの考え方を借りた、この体験用の設定です。
店・駅・住所はすべて架空、絵は仮のイラスト(自作)です。答えはこのブラウザの中にだけ残し、外へ送りません。1つの版を解けるのは1回までです。
Read the full description
A 3-second first-view test for small-shop homepages. A fictional bakery hero is shown for three seconds and hidden, then three questions (signature item, nearest station, today's closing time) are judged as read, shown-but-missed, not shown ("couldn't find it" is a correct observation) or guessed — and the matching spot lights up on the page. Next, tap to find five fixes (headline, photo, feature row, hours band, button) with before/after and the reason. Copy a request message to run the same test with an acquaintance on your own homepage, copy the fixed hero as React code, and send a result line plus a quiz URL to X. Answers stay in the browser.
- Added:
- 2026-11-17
- Dependencies:
- None
- tags
- #hero #page #first-view #usability-test #quiz #bakery #small-business #share #localstorage #container-query #reduced-motion #no-dependency
"use client";
import { useEffect, useMemo, useRef, useState, type ReactNode } from "react";
/**
* パン屋のトップ3秒テスト(書いてあるのに見落とす所と、書いていない所を分ける)
*
* 差別化: 既存のヒーロー(スプリット・大タイポ・全面写真・3D・粒子など)はどれも「見せ方」の見本で、
* 操作は眺めるかスクロールだけ。本ブロックはヒーローを3秒だけ見せて隠し、3問の答えを4種類に判定して
* 画面上で光らせ、直す所を5か所当てさせる診断型。比較スライダーは使わず、直した版は復習として見せるだけ。
*
* 汎用技法メモ:
* 1. 5か所の前後・解説・依頼文・書き出すReactコード・模擬画面の文字は、すべて EDITS と QUESTIONS の1か所から作る。
* 文言を直すと画面と書き出しが同時に変わり、食い違わない。
* 2. 判定は「その版に書いてあるか」と「選んだのが正解か・見当たらなかったか」の2軸で4つに分ける(judge)。
* 書いていない項目で「見当たらなかった」を選ぶのは正しい観察として数える。
* 3. 模擬画面は container query 単位(cqi)で文字を組むので、幅が変わっても同じ構図のまま縮む。
* 4. 1つの版を解けるのはブラウザごとに1回。答えは localStorage にだけ残し、外へ送らない。
* 出題URLの #top3s=before|after で友だちに版を渡し、答えた後だけもう一方の版を見せる。
* 5. 光らせる・流れる帯は opacity と transform だけ。prefers-reduced-motion では帯を止め、光は点滅させない。
*/
// --- 設定データ(ここだけ直せば画面・判定・依頼文・コードがそろって変わる) ---------------------------
export type Version = "before" | "after";
export type Region = "headline" | "photo" | "features" | "band" | "station" | "cta";
export type Verdict = "read" | "missed" | "absent-ok" | "guessed";
export const SHOP = {
name: "こむぎ堂",
station: "麦が丘駅 徒歩5分",
address: "〒000-0000 架空市こむぎ町1-2",
close: "18:00",
};
export const EDITS = [
{
id: "headline",
regions: ["headline"] as Region[],
name: "見出し",
before: "毎日に、ちいさなしあわせを。",
after: "朝7時、塩バターパンが焼き上がる坂の上のパン屋",
why: "3秒で読まれるのは大きな文字だけ。どの店にも言える言葉をやめ、名物・時間・場所を見出しに入れる。",
check: "見出しだけで、名物と開く時間と場所が分かるか",
},
{
id: "photo",
regions: ["photo"] as Region[],
name: "背景の絵",
before: "小麦畑の風景",
after: "焼き上がった塩バターパンの写真",
why: "小麦畑はどのパン屋にも当てはまる。売り物そのものを大きく見せると、名物が絵だけで伝わる。",
check: "最初の画面の写真が、売っている物そのものか",
},
{
id: "features",
regions: ["features"] as Region[],
name: "特徴3列",
before: "素材・こだわり・真心",
after: "名物・駐車2台・電話で取り置き",
beforeItems: [
["素材", "厳選した素材を使用しています"],
["こだわり", "一つひとつ丁寧に"],
["真心", "心を込めてお届けします"],
],
afterItems: [
["名物", "塩バターパン 1個180円"],
["駐車2台", "店の前に停められます"],
["電話で取り置き", "前日18時までに"],
],
why: "「こだわり」「真心」は読み飛ばされる。来る前に知りたい事実(何が名物か・車で行けるか・取り置けるか)に替える。",
check: "特徴の欄が、来る前に知りたい事実になっているか",
},
{
id: "band",
regions: ["band", "station"] as Region[],
name: "駅と本日の営業時間",
before: "閉店時刻は流れるお知らせの中、駅名は下の端の薄い小さな文字",
after: `${SHOP.station}|本日 7:00–${SHOP.close}`,
why: "流れる文字は読む前に消え、薄く小さい文字は見えていても読まれない。止めた帯に、最初の画面で出す。",
check: "最寄り駅と今日の営業時間が、最初の画面に止まって出ているか",
},
{
id: "cta",
regions: ["cta"] as Region[],
name: "ボタン",
before: "詳しく見る",
after: "今日の焼き上がりと地図を見る",
why: "「詳しく」では押した先が分からない。押すと何が見られるかをボタンに書く。",
check: "ボタンの文字で、押した先に何があるか分かるか",
},
] as const;
export type EditId = (typeof EDITS)[number]["id"];
const edit = <K extends EditId>(id: K) => EDITS.find((e) => e.id === id) as Extract<(typeof EDITS)[number], { id: K }>;
// 閉店時刻は2つ目に置き、3秒の間に必ず枠の中を流れるようにする(「表示されていた」と言える条件)
export const TICKER = ["年末年始の営業", `本日は${SHOP.close}で閉店します`, "新商品 くるみとレーズンのカンパーニュ", "ポイントカード終了のお知らせ"];
export const CLOSE_INDEX = TICKER.findIndex((t) => t.includes(SHOP.close));
export const NOT_FOUND = "見当たらなかった";
export const QUESTIONS = [
{
id: "specialty",
label: "名物",
q: "名物は?",
options: ["塩バターパン", "あんぱん", "カレーパン"],
answer: 0,
present: { before: false, after: true },
where: { before: "headline", after: "headline" } as Record<Version, Region>,
whereText: {
before: "名物はどこにも書いていません。見出しは「毎日に、ちいさなしあわせを。」",
after: "見出しに「塩バターパン」と書いてあります",
},
},
{
id: "station",
label: "最寄り駅",
q: "最寄り駅は?",
options: ["潮見通り駅", "麦が丘駅", "かえで台駅"],
answer: 1,
present: { before: true, after: true },
where: { before: "station", after: "band" } as Record<Version, Region>,
whereText: {
before: `下の端に、薄い小さな文字で「${SHOP.station}」`,
after: `上の帯に「${SHOP.station}」`,
},
},
{
id: "close",
label: "閉店時刻",
q: "今日は何時まで?",
options: ["17:00", "18:00", "19:30"],
answer: 1,
present: { before: true, after: true },
where: { before: "band", after: "band" } as Record<Version, Region>,
whereText: {
before: `流れるお知らせ帯の中に「本日は${SHOP.close}で閉店します」`,
after: `上の帯に「本日 7:00–${SHOP.close}」`,
},
},
] as const;
export const VERDICT: Record<Verdict, { label: string; short: string; color: string; ok: boolean }> = {
read: { label: "読み取れた", short: "読み取れた", color: "#047857", ok: true },
missed: { label: "表示されていたが見つけられなかった", short: "見落とし", color: "#d97706", ok: false },
"absent-ok": { label: "表示されていない(見当たらなかったは正しい観察)", short: "書いていない", color: "#57534e", ok: true },
guessed: { label: "表示されていないのに推測した", short: "推測", color: "#be123c", ok: false },
};
export const PEEK_MS = 3000;
export const STORE_KEY = "first-ch:three-sec-top:v1";
export const HASH_KEY = "top3s";
export const VERSION_LABEL: Record<Version, string> = { before: "直す前", after: "直した版" };
// --- 判定・文面(純粋関数) ---------------------------------------------------------------
/** answer は選択肢の番号。選択肢の数(3)を「見当たらなかった」とする */
export function judge(version: Version, qi: number, answer: number): Verdict {
const q = QUESTIONS[qi];
const notFound = answer >= q.options.length;
if (q.present[version]) return !notFound && answer === q.answer ? "read" : "missed";
return notFound ? "absent-ok" : "guessed";
}
export function judgeAll(version: Version, answers: readonly number[]): Verdict[] {
return QUESTIONS.map((_, i) => judge(version, i, answers[i] ?? QUESTIONS[i].options.length));
}
export function shareText(verdicts: readonly Verdict[]): string {
const n = verdicts.filter((v) => VERDICT[v].ok).length;
const mi = verdicts.indexOf("missed");
const gi = verdicts.indexOf("guessed");
const tail =
mi >= 0
? `${QUESTIONS[mi].label}は書いてあったのに見落とした`
: gi >= 0
? `${QUESTIONS[gi].label}は書いていないのに推測した`
: "書いていない所まで見分けた";
return `3秒で拾えたのは3つ中${n}つ。${tail}。あなたは?`;
}
export function shareUrl(base: string, version: Version): string {
return `${base.split("#")[0]}#${HASH_KEY}=${version}`;
}
export function parseHash(hash: string): Version | null {
const m = hash.match(new RegExp(`(?:^#|&)${HASH_KEY}=(before|after)(?:&|$)`));
return m ? (m[1] as Version) : null;
}
export function requestText(): string {
const qs = QUESTIONS.map((q, i) => `${i + 1}. ${q.q.replace("?", "")}は何でしたか?`);
const checks = EDITS.map((e) => `□ ${e.check}`);
return [
"お願い:うちの店のサイトのトップページを3秒だけ見て、すぐ閉じてください。そのあと3つだけ質問させてください。",
"",
...qs,
"",
"分からなければ「見当たらなかった」で大丈夫です。当てずっぽうより助かります。",
"",
"(自分用メモ:答えを聞いたら、トップで次の5つを確かめる)",
...checks,
].join("\n");
}
/** 直した版のトップを React(TSX・Tailwind)の1ファイルで返す */
export function reactCode(): string {
const f = edit("features");
const data = {
shop: SHOP.name,
band: edit("band").after,
headline: edit("headline").after,
photoAlt: edit("photo").after,
cta: edit("cta").after,
features: f.afterItems.map(([title, note]) => ({ title, note })),
};
return `// ${data.shop} のトップ(直した版)。写真は差し替えてください
const TOP = ${JSON.stringify(data, null, 2)};
export default function ShopTop() {
return (
<section className="bg-[#fbf8f2] text-stone-800">
<p className="bg-stone-900 px-4 py-2 text-center text-sm font-bold tracking-wide text-white">{TOP.band}</p>
<div className="relative">
<img src="/photo-top.jpg" alt={TOP.photoAlt} className="h-72 w-full object-cover sm:h-96" />
<div className="absolute inset-x-4 bottom-4 max-w-xl bg-white/95 p-5 sm:left-8 sm:p-7">
<h1 className="text-2xl font-bold leading-snug text-stone-900 sm:text-3xl">{TOP.headline}</h1>
<a
href="#today"
className="mt-4 inline-flex min-h-11 items-center bg-amber-600 px-5 font-bold text-white hover:bg-amber-700 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-amber-600"
>
{TOP.cta}
</a>
</div>
</div>
<ul className="grid grid-cols-3 divide-x divide-stone-200 border-y border-stone-200 bg-white">
{TOP.features.map((f) => (
<li key={f.title} className="px-3 py-4 text-center">
<p className="text-sm font-bold text-stone-900 sm:text-base">{f.title}</p>
<p className="mt-1 text-xs text-stone-600 sm:text-sm">{f.note}</p>
</li>
))}
</ul>
</section>
);
}
`;
}
// --- 保存(ブラウザ内だけ) ------------------------------------------------------------------
type Store = { before?: number[]; after?: number[]; seen?: Version[] };
function readStore(): Store {
try {
const v = JSON.parse(localStorage.getItem(STORE_KEY) ?? "{}");
return v && typeof v === "object" ? v : {};
} catch {
return {};
}
}
/** 結果の画面で模擬画面に出る版。「直す所を探す」は直す前、「もう一方」は解いた版の逆 */
export function stageVersionOf(phase: string, view: string, version: Version): Version {
if (phase !== "result") return version;
if (view === "find") return "before";
if (view === "other") return version === "before" ? "after" : "before";
return version;
}
/** 解いた版と違う版を見せたら seen に入れる(答えを知った版を後で採点させない) */
export function markShown(s: Store, solved: Version, shown: Version): Store {
if (shown === solved || s.seen?.includes(shown)) return s;
return { ...s, seen: [...(s.seen ?? []), shown] };
}
function writeStore(s: Store) {
try {
localStorage.setItem(STORE_KEY, JSON.stringify(s));
} catch {
/* 保存できない環境では、この画面の間だけ覚える */
}
}
async function copyText(text: string) {
try {
await navigator.clipboard.writeText(text);
return true;
} catch {
const ta = document.createElement("textarea");
ta.value = text;
ta.setAttribute("readonly", "");
ta.style.position = "fixed";
ta.style.opacity = "0";
document.body.appendChild(ta);
ta.focus({ preventScroll: true });
ta.select();
const ok = document.execCommand("copy");
ta.remove();
return ok;
}
}
// --- 模擬画面の絵(自作の仮イラスト) -------------------------------------------------------------
function WheatField() {
const stalks = Array.from({ length: 22 }, (_, i) => i);
return (
<svg viewBox="0 0 400 220" preserveAspectRatio="xMidYMid slice" className="absolute inset-0 h-full w-full" aria-hidden="true">
<defs>
<linearGradient id="ald-sky" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stopColor="#f5ead2" />
<stop offset="1" stopColor="#efd9a8" />
</linearGradient>
</defs>
<rect width="400" height="220" fill="url(#ald-sky)" />
<circle cx="318" cy="60" r="26" fill="#fbf3df" opacity="0.9" />
<path d="M0 140 Q100 118 200 134 T400 128 V220 H0Z" fill="#d9b46a" />
<path d="M0 165 Q120 148 230 162 T400 156 V220 H0Z" fill="#c99a48" />
{stalks.map((i) => {
const x = 8 + i * 18.4;
const h = 46 + ((i * 37) % 22);
return (
<g key={i} stroke="#a87a2c" strokeWidth="1.6" fill="#b9873a" strokeLinecap="round">
<path d={`M${x} 222 Q${x + 3} ${222 - h / 2} ${x + 5} ${222 - h}`} fill="none" />
{[0, 1, 2, 3].map((k) => (
<ellipse key={k} cx={x + 5 + (k % 2 ? 3 : -3)} cy={222 - h + 4 + k * 6} rx="2.6" ry="5" transform={`rotate(${k % 2 ? 28 : -28} ${x + 5} ${222 - h + 4 + k * 6})`} stroke="none" />
))}
</g>
);
})}
</svg>
);
}
function SaltBread() {
const rolls = [
{ x: 300, y: 112, r: 10, s: 1.05 },
{ x: 214, y: 168, r: -8, s: 0.95 },
{ x: 350, y: 182, r: -4, s: 0.8 },
];
return (
<svg viewBox="0 0 400 220" preserveAspectRatio="xMidYMid slice" className="absolute inset-0 h-full w-full" aria-hidden="true">
<rect width="400" height="220" fill="#e9dcc6" />
<rect y="150" width="400" height="70" fill="#b98b5a" />
<rect y="150" width="400" height="3" fill="#a3764a" />
{rolls.map((b, i) => (
<g key={i} transform={`translate(${b.x} ${b.y}) rotate(${b.r}) scale(${b.s})`}>
<ellipse cx="0" cy="26" rx="70" ry="10" fill="#7a5532" opacity="0.25" />
<path d="M-66 10 C-60 -30 60 -34 66 8 C68 22 -68 26 -66 10Z" fill="#c9893f" />
<path d="M-58 4 C-50 -24 50 -28 58 2" fill="none" stroke="#e7b06a" strokeWidth="6" strokeLinecap="round" opacity="0.75" />
{[-34, -12, 10, 32].map((x) => (
<path key={x} d={`M${x - 8} -14 Q${x} -22 ${x + 8} -12`} fill="none" stroke="#9c6229" strokeWidth="3" strokeLinecap="round" />
))}
{[-40, -22, -4, 16, 30, 44, -28, 6, 24].map((x, k) => (
<rect key={k} x={x} y={-20 + (k % 3) * 5} width="3" height="3" fill="#fffaf0" transform={`rotate(${k * 20} ${x} ${-20 + (k % 3) * 5})`} />
))}
<ellipse cx="-22" cy="-10" rx="16" ry="4" fill="#fff6e0" opacity="0.45" />
</g>
))}
</svg>
);
}
// --- 模擬画面 -----------------------------------------------------------------------------
type Mark = { region: Region; color: string; text: string; dashed?: boolean; n?: number };
/** 同じ場所を指す印は1つの枠にまとめ、ラベルを横に並べる(重ならない) */
function MarkBox({ marks, glow }: { marks: Mark[]; glow: boolean }) {
const m = marks[0];
const band = m.region === "band";
return (
<span aria-hidden="true" className="pointer-events-none absolute -inset-[3px] z-20">
<span
className={`absolute inset-0 border-2 ${marks.every((x) => x.dashed) ? "border-dashed" : ""} ${glow ? "animate-[ald-glow_1.4s_ease-in-out_3] motion-reduce:animate-none" : ""}`}
style={{ borderColor: m.color, backgroundColor: `${m.color}1f` }}
/>
<span className={`absolute flex gap-0.5 -top-px -translate-y-full ${band ? "right-0" : "left-0"}`}>
{marks.map((x, i) => (
<span key={i} className="flex items-center gap-1 px-1.5 py-0.5 text-[11px] leading-none font-bold whitespace-nowrap text-white" style={{ backgroundColor: x.color }}>
{x.n !== undefined && <span className="font-display tabular-nums">{x.n}</span>}
{x.text}
</span>
))}
</span>
</span>
);
}
function Spot({
region,
marks,
tappable,
onTap,
className = "",
children,
label,
glow,
z = "z-30",
}: {
z?: string;
region: Region;
marks: Mark[];
tappable: boolean;
onTap: (r: Region) => void;
className?: string;
children: ReactNode;
label: string;
glow: boolean;
}) {
const mine = marks.filter((m) => m.region === region);
return (
<div className={`relative ${className}`}>
{children}
{mine.length > 0 && <MarkBox marks={mine} glow={glow} />}
{tappable && (
<button
type="button"
aria-label={`${label}を直す所として選ぶ`}
onClick={(e) => {
e.stopPropagation();
onTap(region);
}}
className={`spot-tap spot-${region} absolute inset-0 ${z} cursor-pointer outline-offset-[-2px] hover:bg-amber-500/10 hover:outline-2 hover:outline-dashed hover:outline-amber-500 focus-visible:bg-amber-500/10 focus-visible:outline-2 focus-visible:outline-amber-600`}
/>
)}
</div>
);
}
function ShopTop({
version,
running,
marks = [],
tappable = false,
onTap = () => {},
onMiss,
glow = false,
tickerFrom = 0,
}: {
tickerFrom?: number;
version: Version;
running: boolean;
marks?: Mark[];
tappable?: boolean;
onTap?: (r: Region) => void;
onMiss?: () => void;
glow?: boolean;
}) {
const after = version === "after";
const head = edit("headline");
const feat = edit("features");
const items = after ? feat.afterItems : feat.beforeItems;
const sp = { marks, tappable, onTap, glow };
return (
<div className="@container relative bg-[#fbf8f2] text-stone-800 select-none" onClick={tappable ? onMiss : undefined}>
<div className="flex items-center justify-between border-b border-stone-200 bg-white px-[3.5cqi] py-[1.8cqi]">
<span className="flex items-center gap-[1.2cqi] text-[max(13px,3cqi)] font-bold tracking-[0.12em] text-stone-900">
<svg viewBox="0 0 20 20" className="h-[1.1em] w-[1.1em]" aria-hidden="true">
<path d="M10 18V5" stroke="#b9873a" strokeWidth="1.6" />
{[5, 8.5, 12].map((y) => (
<g key={y} fill="#b9873a">
<ellipse cx="7.6" cy={y} rx="1.7" ry="3" transform={`rotate(-30 7.6 ${y})`} />
<ellipse cx="12.4" cy={y} rx="1.7" ry="3" transform={`rotate(30 12.4 ${y})`} />
</g>
))}
</svg>
{SHOP.name}
</span>
<span className="flex gap-[3cqi] text-[max(10px,1.9cqi)] text-stone-500" aria-hidden="true">
<span>商品</span>
<span>店舗</span>
<span className="hidden @sm:inline">お知らせ</span>
</span>
</div>
<Spot region="band" label="上の帯" {...sp}>
{after ? (
<p className="bg-stone-900 px-[3cqi] py-[1.6cqi] text-center text-[max(11px,2.3cqi)] font-bold tracking-[0.04em] text-white">{edit("band").after}</p>
) : (
<div className="overflow-hidden bg-stone-700 py-[1.4cqi] text-[max(10px,1.9cqi)] text-stone-100">
<div key={running ? "run" : "idle"} className={`flex w-max ${running ? "animate-[ald-tick_16s_linear_infinite] motion-reduce:animate-none" : ""}`}>
{[0, 1].map((k) => (
<span key={k} className="flex shrink-0" aria-hidden={k === 1}>
{(running ? TICKER : [...TICKER.slice(tickerFrom), ...TICKER.slice(0, tickerFrom)]).map((t) => (
<span key={t} className="px-[3cqi] whitespace-nowrap">
<span className="mr-[1.4cqi] text-stone-400">お知らせ</span>
{t}
</span>
))}
</span>
))}
</div>
</div>
)}
</Spot>
<Spot region="photo" label="背景の絵" className="h-[50cqi] overflow-hidden" {...sp}>
{after ? <SaltBread /> : <WheatField />}
<span className="absolute right-[1.6cqi] bottom-[1.4cqi] z-10 bg-white/70 px-1 text-[max(8px,1.4cqi)] text-stone-500">仮のイラスト(自作)</span>
<div className={`absolute inset-0 flex flex-col justify-center px-[6cqi] ${after ? "items-start" : "items-center text-center"}`}>
<Spot region="headline" label="見出し" z="z-40" className={after ? "max-w-[78%] bg-white/92 px-[3.2cqi] py-[2.6cqi]" : ""} {...sp}>
<p className={`font-bold text-stone-900 ${after ? "text-[max(17px,4.6cqi)] leading-[1.35]" : "text-[max(18px,5.6cqi)] leading-[1.3] tracking-[0.06em] [text-shadow:0_1px_0_#fff8]"}`}>
{after ? head.after : head.before}
</p>
{!after && <p className="mt-[1.6cqi] text-[max(10px,2.1cqi)] text-stone-700">素材にこだわったパンをお届けします</p>}
</Spot>
<Spot region="cta" label="ボタン" z="z-40" className="mt-[3cqi]" {...sp}>
<span className={`inline-block px-[3.6cqi] py-[1.6cqi] text-[max(11px,2.3cqi)] font-bold ${after ? "bg-[#d97706] text-white" : "border border-stone-700 bg-white/60 text-stone-800"}`}>
{after ? edit("cta").after : edit("cta").before}
</span>
</Spot>
</div>
</Spot>
<Spot region="features" label="特徴3列" {...sp}>
<ul className="grid grid-cols-3 divide-x divide-stone-200 border-b border-stone-200 bg-white">
{items.map(([t, n]) => (
<li key={t} className="px-[1.6cqi] py-[2.6cqi] text-center">
<p className={`font-bold text-stone-900 ${after ? "text-[max(11px,2.5cqi)]" : "text-[max(12px,2.8cqi)] tracking-[0.2em]"}`}>{t}</p>
<p className="mt-[0.8cqi] text-[max(9px,1.8cqi)] leading-[1.5] text-stone-500">{n}</p>
</li>
))}
</ul>
</Spot>
<div className="flex justify-center px-[3cqi] py-[2cqi]">
<Spot region="station" label="下の端の文字" {...sp}>
<p className="text-[max(8px,1.5cqi)] text-stone-400/80">
{SHOP.address} {SHOP.station} © {SHOP.name}
</p>
</Spot>
</div>
</div>
);
}
// --- 本体 ---------------------------------------------------------------------------------
type Phase = "intro" | "peek" | "quiz" | "result" | "locked";
type View = "judge" | "find" | "other";
const focusRing = "focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#d97706]";
const btnBase = `inline-flex min-h-11 items-center justify-center px-4 text-[15px] font-bold transition-[transform,opacity] duration-100 active:scale-[0.98] motion-reduce:transition-none ${focusRing}`;
export default function ThreeSecondTopTest({ headingTag = "h2" }: { headingTag?: "h1" | "h2" | "p" }) {
const Heading = headingTag;
const [phase, setPhase] = useState<Phase>("intro");
const [version, setVersion] = useState<Version>("before");
const [fromFriend, setFromFriend] = useState(false);
const [answers, setAnswers] = useState<number[]>([]);
const [left, setLeft] = useState(3);
const [view, setView] = useState<View>("judge");
const [found, setFound] = useState<EditId[]>([]);
const [missMsg, setMissMsg] = useState("");
const [sendVer, setSendVer] = useState<Version>("before");
const [pageUrl, setPageUrl] = useState("");
const [copied, setCopied] = useState("");
const [savedBefore, setSavedBefore] = useState(false);
const stageRef = useRef<HTMLDivElement>(null);
const panelRef = useRef<HTMLDivElement>(null);
const timers = useRef<number[]>([]);
const other: Version = version === "before" ? "after" : "before";
const verdicts = useMemo(() => (answers.length === QUESTIONS.length ? judgeAll(version, answers) : []), [answers, version]);
const text = verdicts.length ? shareText(verdicts) : "";
const xHref = pageUrl ? `https://x.com/intent/post?text=${encodeURIComponent(text)}&url=${encodeURIComponent(shareUrl(pageUrl, sendVer))}` : undefined;
// 開いたとき: # の版と、このブラウザでの回答済みを読む
useEffect(() => {
// URL と localStorage はマウント後にしか読めない(サーバーで描いた画面とずらさない)
const init = () => {
const v = parseHash(window.location.hash);
const s = readStore();
const ver = v ?? "before";
setPageUrl(window.location.href);
setFromFriend(!!v);
setVersion(ver);
const done = s[ver];
if (Array.isArray(done) && done.length === QUESTIONS.length) {
setAnswers(done);
setSavedBefore(true);
setPhase("result");
} else if (s.seen?.includes(ver)) {
// 復習で先に見た版は解かせない(答えを知っているため)。見せるだけにする
setPhase("locked");
}
};
init();
const t = timers.current;
return () => t.forEach(clearTimeout);
}, []);
const start = () => {
setPhase("peek");
setLeft(3);
stageRef.current?.scrollIntoView({ block: "nearest", behavior: "auto" });
timers.current.push(
window.setTimeout(() => setLeft(2), 1000),
window.setTimeout(() => setLeft(1), 2000),
window.setTimeout(() => {
setPhase("quiz");
requestAnimationFrame(() => panelRef.current?.querySelector<HTMLButtonElement>("button.opt")?.focus({ preventScroll: true }));
}, PEEK_MS),
);
};
const answer = (k: number) => {
const next = [...answers, k];
setAnswers(next);
if (next.length === QUESTIONS.length) {
const s = readStore();
writeStore({ ...s, [version]: next });
setPhase("result");
setView("judge");
setSendVer(version);
} else {
requestAnimationFrame(() => panelRef.current?.querySelector<HTMLButtonElement>("button.opt")?.focus({ preventScroll: true }));
}
};
const showOther = () => setView("other");
const tapRegion = (r: Region) => {
const e = EDITS.find((x) => (x.regions as readonly Region[]).includes(r));
if (!e) return;
setMissMsg("");
setFound((f) => (f.includes(e.id) ? f : [...f, e.id]));
};
const doCopy = async (key: string, value: string) => {
const ok = await copyText(value);
setCopied(ok ? key : "");
timers.current.push(window.setTimeout(() => setCopied((c) => (c === key ? "" : c)), 1800));
};
// 模擬画面に重ねる印
const marks: Mark[] = useMemo(() => {
if (phase !== "result") return [];
if (view === "judge") {
return QUESTIONS.map((q, i) => {
const v = verdicts[i];
return { region: q.where[version], color: VERDICT[v].color, text: `${q.label}:${VERDICT[v].short}`, dashed: !q.present[version], n: i + 1 };
});
}
if (view === "find") {
return found.map((id) => {
const e = edit(id);
return { region: e.regions[0], color: "#d97706", text: e.name, n: EDITS.findIndex((x) => x.id === id) + 1 };
});
}
return [];
}, [phase, view, verdicts, version, found]);
const stageVersion: Version = stageVersionOf(phase, view, version);
// 結果の画面で解いた版と違う版を見せたら(「もう一方」も「直す所を探す」も)、その版は解けない版として残す
useEffect(() => {
if (phase !== "result" || stageVersion === version) return;
const s = readStore();
const next = markShown(s, version, stageVersion);
if (next !== s) writeStore(next);
}, [phase, stageVersion, version]);
const okCount = verdicts.filter((v) => VERDICT[v].ok).length;
const qi = answers.length;
return (
<section className="w-full max-w-5xl border-y border-stone-200 bg-white px-4 py-8 text-stone-800 sm:px-8 sm:py-10">
<style>{"@keyframes ald-tick{from{transform:translateX(0)}to{transform:translateX(-50%)}}@keyframes ald-glow{0%,100%{opacity:1}50%{opacity:.35}}"}</style>
<div className="flex flex-wrap items-baseline justify-between gap-x-6 gap-y-1 border-b border-stone-200 pb-4">
<Heading className="text-[clamp(1.35rem,3.4vw,1.85rem)] leading-[1.35] font-bold tracking-[0.02em] text-stone-900">パン屋のトップ3秒テスト</Heading>
<p className="text-[13px] text-stone-500">架空の店「{SHOP.name}」で試します</p>
</div>
<p className="mt-3 text-[15px] leading-[1.75] text-stone-700">
<span className="mr-2 inline-block h-[2px] w-5 translate-y-[-4px] bg-[#d97706]" aria-hidden="true" />
書いてあるのに見落とす所と、そもそも書いていない所を分けて見つける
</p>
{fromFriend && phase !== "result" && phase !== "locked" && (
<p className="mt-4 border-l-2 border-[#d97706] bg-amber-50 px-3 py-2 text-[14px] text-stone-800">
友だちから出題されました({VERSION_LABEL[version]})。答えた後に、もう一方の版を見られます。
</p>
)}
<div className="mt-6 grid gap-6 md:grid-cols-[minmax(0,1.45fr)_minmax(0,1fr)] md:gap-8">
{/* 模擬画面 */}
<div ref={stageRef} className="scroll-mt-4">
<div className="border border-stone-300 bg-white">
<div className="flex items-center gap-2 border-b border-stone-200 bg-stone-50 px-3 py-1.5" aria-hidden="true">
<span className="flex gap-1">
<span className="h-2 w-2 bg-stone-300" />
<span className="h-2 w-2 bg-stone-300" />
<span className="h-2 w-2 bg-stone-300" />
</span>
<span className="truncate font-display text-[11px] text-stone-400">komugido.example/</span>
<span className="ml-auto text-[11px] font-bold text-stone-500">
{phase === "result" ? `${VERSION_LABEL[stageVersion]}の画面` : VERSION_LABEL[version]}
</span>
</div>
<div className="relative overflow-hidden" role={phase === "result" && view === "find" ? "group" : "img"} aria-label={phase === "peek" || phase === "result" || phase === "locked" ? `${SHOP.name}のトップ(${VERSION_LABEL[stageVersion]})` : `${SHOP.name}のトップ(隠しています)`}>
<div className={phase === "intro" || phase === "quiz" ? "blur-[10px] saturate-50" : ""} aria-hidden={phase === "intro" || phase === "quiz"}>
<ShopTop
version={stageVersion}
running={phase === "peek"}
tickerFrom={phase === "result" || phase === "locked" ? CLOSE_INDEX : 0}
marks={marks}
glow={phase === "result" && view === "judge"}
tappable={phase === "result" && view === "find"}
onTap={tapRegion}
onMiss={() => setMissMsg("そこは今のままでも伝わります。文字が大きい所・最初に目に入る所を探してください")}
/>
</div>
{phase === "intro" && (
<div className="absolute inset-0 flex flex-col items-center justify-start bg-white/55 px-6 pt-[16%] text-center">
<p className="text-[clamp(1.3rem,4.4vw,2rem)] leading-[1.35] font-bold text-stone-900">このパン屋、今日何時まで?</p>
<p className="mt-2 text-[13px] text-stone-600">トップを3秒だけ見て、3つの質問に答えます</p>
</div>
)}
{phase === "quiz" && (
<div className="absolute inset-0 flex items-center justify-center bg-stone-100/80">
<p className="border border-stone-300 bg-white px-4 py-2 text-[14px] font-bold text-stone-700">画面を隠しました</p>
</div>
)}
{phase === "peek" && (
<div className="absolute inset-x-0 top-0 z-40 h-1 bg-stone-200/70" aria-hidden="true">
<div className="h-full origin-left animate-[ald-bar_3s_linear_forwards] bg-[#d97706] motion-reduce:animate-none" />
<style>{"@keyframes ald-bar{from{transform:scaleX(1)}to{transform:scaleX(0)}}"}</style>
</div>
)}
</div>
</div>
{phase === "result" && (
<div className="mt-3 flex border-b border-stone-200" role="group" aria-label="画面の切り替え">
{(
[
["judge", "判定"],
["find", "直す所を探す"],
["other", `${VERSION_LABEL[other]}${other === "after" ? "(復習)" : ""}`],
] as [View, string][]
).map(([v, l]) => (
<button
key={v}
type="button"
aria-pressed={view === v}
onClick={() => (v === "other" ? showOther() : setView(v))}
className={`view-${v} -mb-px min-h-11 flex-1 border-b-2 px-2 text-[14px] whitespace-nowrap font-bold ${view === v ? "border-[#d97706] text-stone-900" : "border-transparent text-stone-500 hover:text-stone-800"} ${focusRing}`}
>
{l}
</button>
))}
</div>
)}
{phase === "result" && view === "find" && (
<p className="mt-2 min-h-[1.5em] text-[13px] text-stone-600" aria-live="polite">
{missMsg || `直す前の画面で、直したい所をタップ(${found.length} / ${EDITS.length} か所)`}
</p>
)}
{phase === "result" && view === "other" && (
<p className="mt-2 text-[13px] text-stone-600">{other === "after" ? "直した版は見るだけです。もう一度は採点しません。" : "友だちが解いた版の、直す前の画面です。"}</p>
)}
</div>
{/* 操作と結果 */}
<div ref={panelRef} aria-live="polite">
{phase === "intro" && (
<div>
<p className="text-[15px] leading-[1.8] text-stone-700">
ボタンを押すと、{SHOP.name}のトップが<strong className="text-stone-900">3秒だけ</strong>出て、すぐ隠れます。
</p>
<button type="button" onClick={start} className={`start mt-5 w-full bg-[#d97706] text-white hover:bg-[#b45309] ${btnBase} min-h-14 text-[17px]`}>
3秒だけ見る
</button>
<details className="mt-5 border-t border-stone-200 pt-3 text-[13px] leading-[1.7] text-stone-500">
<summary className={`cursor-pointer font-bold text-stone-600 ${focusRing}`}>なぜ3秒か・このテストについて</summary>
<p className="mt-2">
3秒は、Lyssna(ユーザーテストのサービス)の短時間提示テストの考え方を借りた、この体験用の設定です。
</p>
<p className="mt-1">店・駅・住所はすべて架空、絵は仮のイラスト(自作)です。答えはこのブラウザの中にだけ残し、外へ送りません。1つの版を解けるのは1回までです。</p>
</details>
</div>
)}
{phase === "locked" && (
<div>
<p className="text-[15px] leading-[1.8] text-stone-700">
この版({VERSION_LABEL[version]})は前に復習で見ているので、採点せずに画面だけ見せます。
</p>
<p className="mt-2 text-[13px] text-stone-500">1つの版を解けるのは1回までです。答えはこのブラウザの中にだけ残しています。</p>
</div>
)}
{phase === "peek" && (
<div>
<p className="text-[13px] font-bold text-stone-500">見ています</p>
<p className="mt-1 font-display text-[clamp(3rem,9vw,4.5rem)] leading-none font-bold text-stone-900 tabular-nums">
{left}
<span className="ml-1 text-[18px] font-bold text-stone-500">秒</span>
</p>
<p className="mt-3 text-[14px] text-stone-600">名物・最寄り駅・今日の閉店時刻を聞きます</p>
</div>
)}
{phase === "quiz" && qi < QUESTIONS.length && (
<div>
<p className="flex items-baseline gap-2 text-[13px] font-bold text-stone-500">
<span className="font-display tabular-nums">
{qi + 1} / {QUESTIONS.length}
</span>
<span className="h-px flex-1 bg-stone-200" aria-hidden="true" />
</p>
<p className="mt-2 text-[clamp(1.4rem,4vw,1.9rem)] font-bold text-stone-900">{QUESTIONS[qi].q}</p>
<div className="mt-4 grid grid-cols-2 gap-2">
{[...QUESTIONS[qi].options, NOT_FOUND].map((o, k) => (
<button
key={o}
type="button"
onClick={() => answer(k)}
className={`opt min-h-14 border px-3 text-[15px] font-bold ${btnBase} ${k === QUESTIONS[qi].options.length ? "col-span-2 border-dashed border-stone-400 bg-stone-50 text-stone-700 hover:bg-stone-100" : "border-stone-300 bg-white text-stone-900 hover:border-[#d97706] hover:bg-amber-50"}`}
>
{o}
</button>
))}
</div>
<p className="mt-3 text-[12px] text-stone-500">分からなければ「{NOT_FOUND}」で。推測より正しい観察です。</p>
</div>
)}
{phase === "result" && verdicts.length > 0 && (
<div className="result">
<p className="text-[13px] font-bold text-stone-500">
{VERSION_LABEL[version]}の判定
{savedBefore && <span className="ml-2 border border-stone-300 px-1.5 py-0.5 text-[11px] font-bold text-stone-500">回答済み(1回まで)</span>}
</p>
<p className="mt-2 text-[15px] font-bold text-stone-700">3秒で拾えたのは</p>
<p className="flex items-baseline gap-1.5 font-display leading-none font-bold tabular-nums">
<span className="score text-[56px] text-[#d97706]">{okCount}</span>
<span className="text-[22px] text-stone-400">/ 3</span>
</p>
<ol className="mt-4 divide-y divide-stone-200 border-y border-stone-200">
{QUESTIONS.map((q, i) => {
const v = verdicts[i];
const a = answers[i];
return (
<li key={q.id} className="py-3">
<p className="flex flex-wrap items-center gap-x-2 gap-y-1 text-[14px]">
<span className="font-display text-[12px] font-bold text-stone-400 tabular-nums">{i + 1}</span>
<span className="font-bold text-stone-900">{q.q}</span>
<span className="text-stone-500">あなた:{a >= q.options.length ? NOT_FOUND : q.options[a]}</span>
</p>
<p className="mt-1 inline-block px-1.5 py-0.5 text-[12px] font-bold text-white" style={{ backgroundColor: VERDICT[v].color }}>
{VERDICT[v].label}
</p>
<p className="mt-1 text-[13px] leading-[1.6] text-stone-600">{q.whereText[version]}</p>
</li>
);
})}
</ol>
</div>
)}
</div>
</div>
{phase === "result" && verdicts.length > 0 && (
<div className="mt-8 grid gap-8 border-t border-stone-200 pt-6 md:grid-cols-2">
{/* 共有 */}
<div className="share">
<h3 className="text-[16px] font-bold text-stone-900">友だちに出題する</h3>
<p className="mt-2 border-l-2 border-stone-300 pl-3 text-[15px] leading-[1.7] text-stone-800">{text}</p>
<fieldset className="mt-3">
<legend className="text-[13px] text-stone-600">友だちが初めて解く版</legend>
<div className="mt-1 flex gap-2">
{(["before", "after"] as Version[]).map((v) => (
<label key={v} className={`flex min-h-11 flex-1 cursor-pointer items-center justify-center border text-[14px] font-bold has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-[#d97706] ${sendVer === v ? "border-stone-900 bg-stone-900 text-white" : "border-stone-300 text-stone-700"}`}>
<input type="radio" name="ald-send" value={v} checked={sendVer === v} onChange={() => setSendVer(v)} className="sr-only" />
{VERSION_LABEL[v]}
</label>
))}
</div>
</fieldset>
<div className="mt-3 flex flex-wrap gap-2">
<a href={xHref} target="_blank" rel="noopener noreferrer" className={`share-x flex-1 bg-stone-900 text-white hover:bg-stone-700 ${btnBase}`}>
Xで出題する
</a>
<button type="button" onClick={() => doCopy("url", shareUrl(pageUrl, sendVer))} className={`copy-url flex-1 border border-stone-900 bg-white text-stone-900 hover:bg-stone-100 ${btnBase}`}>
{copied === "url" ? "コピーしました" : "URLをコピー"}
</button>
</div>
<p className="mt-2 text-[12px] text-stone-500">友だちには答えた後にだけ、もう一方の版が出ます。</p>
</div>
{/* 5か所 */}
<div className="edits">
<div className="flex items-baseline justify-between gap-3">
<h3 className="text-[16px] font-bold text-stone-900">直す所 5か所</h3>
<span className="font-display text-[13px] font-bold text-stone-500 tabular-nums">
{found.length} / {EDITS.length}
</span>
</div>
{view !== "find" && found.length === 0 && (
<button type="button" onClick={() => setView("find")} className={`go-find mt-3 w-full border border-[#d97706] text-[#b45309] hover:bg-amber-50 ${btnBase}`}>
直す前の画面で探す
</button>
)}
<ol className="mt-3 divide-y divide-stone-200 border-y border-stone-200">
{EDITS.map((e, i) => {
const open = found.includes(e.id);
return (
<li key={e.id} className="py-2.5">
<p className="flex items-center gap-2 text-[14px] font-bold text-stone-900">
<span className={`flex h-5 w-5 shrink-0 items-center justify-center font-display text-[11px] ${open ? "bg-[#d97706] text-white" : "border border-stone-300 text-stone-400"}`}>{i + 1}</span>
{open ? e.name : "まだ見つけていません"}
</p>
{open && (
<div className="mt-1.5 pl-7 text-[13px] leading-[1.65]">
<p className="text-stone-500">
前:<span className="line-through decoration-stone-300">{e.before}</span>
</p>
<p className="font-bold text-stone-900">後:{e.after}</p>
<p className="mt-0.5 text-stone-600">{e.why}</p>
</div>
)}
</li>
);
})}
</ol>
{found.length < EDITS.length && found.length > 0 && (
<button
type="button"
onClick={() => setFound(EDITS.map((e) => e.id))}
className={`reveal-all mt-2 min-h-11 text-[13px] font-bold text-stone-600 underline underline-offset-4 hover:text-stone-900 ${focusRing}`}
>
残りの答えを見る
</button>
)}
</div>
{/* 持ち帰り */}
<div className="border-t border-stone-200 pt-6 md:col-span-2 md:grid md:grid-cols-2 md:gap-8">
<div>
<h3 className="text-[16px] font-bold text-stone-900">自分の店で試す</h3>
<p className="mt-1 text-[13px] leading-[1.7] text-stone-600">知人に自店のトップを3秒見せて聞く3問と、確かめる5項目の依頼文です。</p>
<button type="button" onClick={() => doCopy("req", requestText())} className={`copy-request mt-3 w-full bg-[#d97706] text-white hover:bg-[#b45309] ${btnBase}`}>
{copied === "req" ? "コピーしました" : "依頼文をコピー"}
</button>
<details className="mt-2 text-[13px]">
<summary className={`cursor-pointer text-stone-600 ${focusRing}`}>依頼文を見る</summary>
<pre className="mt-2 max-h-60 overflow-auto border border-stone-200 bg-stone-50 p-3 font-sans text-[12px] leading-[1.7] whitespace-pre-wrap text-stone-700">{requestText()}</pre>
</details>
</div>
<div className="mt-6 md:mt-0">
<h3 className="text-[16px] font-bold text-stone-900">制作者向け:直した版のコード</h3>
<p className="mt-1 text-[13px] leading-[1.7] text-stone-600">React と Tailwind CSS の1ファイル。文言は先頭の TOP にまとめています。</p>
<button type="button" onClick={() => doCopy("code", reactCode())} className={`copy-code mt-3 w-full border border-stone-900 bg-white text-stone-900 hover:bg-stone-100 ${btnBase}`}>
{copied === "code" ? "コピーしました" : "React コードをコピー"}
</button>
<details className="mt-2 text-[13px]">
<summary className={`cursor-pointer text-stone-600 ${focusRing}`}>コードを見る</summary>
<pre className="mt-2 max-h-60 overflow-auto border border-stone-200 bg-stone-950 p-3 font-mono text-[11px] leading-[1.6] text-stone-100">{reactCode()}</pre>
</details>
</div>
</div>
</div>
)}
</section>
);
}
Add to your project via shadcn CLI
npx shadcn@latest add https://designs.first-ch.com/r/ai-look-detox-hero.json