CODE · 2.5 KB
src/wireframe-layouts.js
Workspace snapshot · 08/31 23:51
export const wireframeLayoutCatalog = {
hero: ["hero-form", "hero-product-stage", "hero-proof-split", "hero-copy-led"],
trust: ["logo-wall", "trust-metric-band"],
problem: ["pain-cards", "pain-checklist", "pain-narrative"],
risk: ["risk-list", "risk-timeline", "risk-cost-stack"],
mechanism: ["step-flow", "before-after", "solution-map"],
process: ["step-flow", "process-circles", "process-timeline"],
differentiation: ["feature-grid", "feature-zigzag", "reason-stack"],
usecase: ["usecase-grid", "usecase-story", "lineup-catalog"],
comparison: ["comparison-table", "before-after-compare", "alternative-matrix"],
proof: ["metric-case", "case-study-featured", "logo-metrics", "review-cards"],
pricing: ["pricing-cards", "price-lineup", "estimate-explainer"],
faq: ["faq-list"],
fit: ["fit-split", "segment-selector"],
cta: ["cta-panel", "cta-banner", "sample-cta"],
form: ["form-panel", "form-split"],
message: ["editorial-message", "expert-profile", "company-authority"],
content: ["content-split", "content-editorial"],
};
const aliases = {
insight: "mechanism",
final: "cta",
action: "cta",
};
export function normalizeWireframeType(section = {}) {
const value = String(section.type || section.id || "content").toLowerCase();
const variant = String(section.layoutVariant || "").toLowerCase();
if (aliases[value]) return aliases[value];
if (value !== "content" || !variant) return value;
return (
Object.entries(wireframeLayoutCatalog).find(([, variants]) =>
variants.includes(variant),
)?.[0] || "content"
);
}
export function resolveWireframeLayout(section = {}, index = 0) {
const type = normalizeWireframeType(section);
const candidates = wireframeLayoutCatalog[type] || wireframeLayoutCatalog.content;
const requested = String(section.layoutVariant || "").toLowerCase();
if (candidates.includes(requested)) return requested;
const text = [section.title, section.body, section.content, section.asset, section.cta]
.filter(Boolean)
.join(" ");
if (type === "hero" && /フォーム|相談|資料|予約/u.test(text)) return "hero-form";
if (type === "hero" && /製品|商品|画面|パッケージ|ラインナップ/u.test(text)) return "hero-product-stage";
if (type === "proof" && /事例|導入|インタビュー/u.test(text)) return "case-study-featured";
if (type === "pricing" && /見積|個別|要件/u.test(text)) return "estimate-explainer";
if (type === "cta" && /サンプル|試す|診断/u.test(text)) return "sample-cta";
return candidates[Math.abs(index) % candidates.length];
}