Files
novalon-website/src/components/detail/detail-case-studies-section.tsx
T
zhangxiang 75ab3bdc2c refactor(grammar): OPEN-05b 批 3 清零——15 处棘轮存量落地,R13-R17 上限归 0 棘轮转硬禁
- detail 件 10 处:直角化(certifications 图标盒 / certification 徽章 / early-access 面板)、
  R16 红面→中性面(bg-bg-elevated / bg-bg-primary/80,红降级 text-brand-ink 点缀,用户裁定 A 方案)、
  DetailCTA 标题 font-black→font-bold、certification 去 hover:shadow-md
- R14 5 处:hub 列表箭头去竖直分量 ×3(留水平位移)、erp-upgrade 卡片去 hover:-translate-y ×2(留 border-brand/30 + 顶部红线)
- 上限同批下调 R13 0 · R14 0 · R15 0 · R16 0 · R17 0;selftest 双向成立
- 基线实写 35 张(预测 35 == git status 35,零外溢;hover 态改动静态零漂移不产生基线);
  归因表 docs/acceptance/2026-12-02-grammar-batch3/attribution.md(L2 卡片 1 例选择器超时单跑复验过,非像素)
- 门禁:check:grammar 25/25 · tsc 0 error · eslint 0 error / 32 warning · jest 161 套件 / 1899 例 ·
  独立只读复跑 225 passed / 0 failed / EXIT=0
- 文档:ADR-0013 §8 回填 + qa-tracker OPEN-05b 已闭 + CONTEXT 决策行 + README 台账
2026-12-02 14:19:32 +08:00

138 lines
6.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
'use client';
/**
* CaseStudiesSection — L3 信任层「客户案例」共享区块(B-2 合并自 3 份本地实现)
*
* 合并来源与差异消解(2026-09-02,修订方案 B' 第二步):
* - solution-detail-content-v3 / product-detail-content-v3 的本地实现原本 ~95% 相同,
* 仅 section 底色(bg-white vs bg-bg-primary)与 h2 文案不同 → 统一为 token 底色
* (bg-bg-primary:浅色与 bg-white 视觉零差异,深色模式正确反色),
* h2 文案改由 heading prop 传入(solution 传「同行业落地案例」,product 用默认「客户案例」)。
* - service-detail-content-v4 的本地实现是异类(motion.a 链接 /cases/<slug>、无 SectionLabel、
* 动效 0.8s 违规)→ 统一到本组件:卡片不带链接(/cases/<slug> 依赖尚不存在的案例数据,
* 链向 404 违反零编造);如需锚点(service hero 的 #cases CTA)用 id prop。
*
* 布局要点:grid 类必须挂在 StaggerReveal 自身——它会给每个子项包一层 motion.div,
* 放外层 div 时包装层成为 grid 唯一子项,卡片会堆成单列(commit 3091035 踩坑记录)。
*
* 数据闸门:caseStudies 为空时 return null(L3EmptyFallback 接管兜底渲染)。
* DEC-N4 同闸(2026-10-19):非空条目还须过 lib/constants/case-publish-gate
* (授权 + basis=verified + 禁词),与首页 ResultsSlot 同一判据实现。
*/
import { ScrollReveal, StaggerReveal } from '@/components/ui/scroll-reveal';
import { SectionLabel } from '@/components/ui/page-decoration';
import { gateCaseItems } from '@/lib/constants/case-publish-gate';
import type { MetricBasis } from '@/lib/constants/metrics-basis';
/** 三处数据源(cases.ts / services.ts / products.ts)的结构公共子集 */
export interface CaseStudyItem {
client: string;
industry: string;
challenge: string;
solution?: string;
result: string;
/**
* DEC-N4 同闸(2026-10-19):卡片型案例必须声明「客户授权对外展示」+
* 「成果口径 verified」才会渲染,判据复用 lib/constants/case-publish-gate
* (与首页成果槽同一实现,非第二套真源)。两字段可选 ⇒ 既有未补口径的
* 条目一律被闸住,这正是 fail-closed 的应有行为。
*/
authorized?: boolean;
basis?: MetricBasis;
}
interface CaseStudiesSectionProps {
caseStudies?: readonly CaseStudyItem[];
/** h2 标题文案(solution 页传「同行业落地案例」,其余用默认) */
heading?: string;
/** 锚点 id(service 页 hero 的 #cases CTA 依赖) */
id?: string;
}
export function CaseStudiesSection({
caseStudies,
heading = '客户案例',
id,
}: CaseStudiesSectionProps) {
/**
* 数据闸门分两层(DEC-N4 同闸改造):
* 1. 原契约:入参为空 ⇒ return null,由 L3EmptyFallback 兜底;
* 2. 新契约:非空条目先过 case-publish-gate,未授权 / 缺 verified 口径 /
* 命中虚构佐证禁词的条目**不渲染**,降级原因逐条 console.error 喊出来
* (静默吞掉等于掩饰,同 ResultsSlot 的纪律)。全部被闸住 ⇒ 整段 null。
*/
const { publishable, blocked } = gateCaseItems(caseStudies ?? []);
for (const { item, blockers } of blocked) {
console.error(
`[CaseStudiesSection] 案例「${item.client}」未通过反伪造门槛,已隐藏:${blockers.join(';')}`,
);
}
if (publishable.length === 0) return null;
return (
<section id={id} data-testid="case-studies-section" className="relative py-20 sm:py-28 md:py-32 lg:py-40 overflow-hidden bg-bg-primary">
<div className="absolute top-0 left-0 right-0 h-px bg-border-primary" />
<div className="absolute bottom-0 left-0 right-0 h-px bg-border-primary" />
<div className="max-w-container mx-auto px-4 sm:px-6 lg:px-10">
<ScrollReveal className="text-center max-w-3xl mx-auto mb-16 sm:mb-20 md:mb-20">
<SectionLabel className="justify-center">
<div className="flex items-center gap-5">
<div className="w-14 h-px bg-brand" />
<span className="text-[11px] tracking-[0.4em] uppercase font-bold text-brand-ink">
客户案例
</span>
<div className="w-14 h-px bg-brand" />
</div>
</SectionLabel>
<h2 className="text-2xl sm:text-3xl md:text-4xl lg:text-5xl font-bold text-ink tracking-tight leading-tight">
{heading}
</h2>
</ScrollReveal>
{/* grid 直接挂 StaggerReveal(见文件头注释),gap-px 露出容器底色形成发丝分隔线 */}
<StaggerReveal
staggerDelay={0.05}
delayChildren={0.05}
className="grid md:grid-cols-2 lg:grid-cols-3 gap-px bg-border-primary"
>
{publishable.map((study) => (
<div
key={study.client}
className="group relative block h-full overflow-hidden bg-bg-primary transition-all duration-normal hover:bg-bg-secondary"
>
<div className="aspect-[4/3] bg-gradient-to-br from-bg-secondary to-bg-tertiary relative overflow-hidden">
<div className="absolute inset-0 flex items-center justify-center">
{/* 客户名首字占位图形(无真实配图时):aria-hidden 不豁免 1.4.3,用大字档令牌 text-text-hint */}
<span aria-hidden="true" className="text-6xl font-bold text-text-hint">
{study.client.charAt(0)}
</span>
</div>
<div className="absolute top-5 left-5">
<span className="px-3 py-1.5 text-xs font-bold text-brand-ink bg-bg-primary/80 backdrop-blur-sm">
{study.industry}
</span>
</div>
</div>
<div className="p-8">
<h3 className="text-xl font-bold text-ink mb-3 group-hover:translate-x-2 transition-transform duration-normal">
{study.client}
</h3>
<p className="text-text-secondary text-sm leading-relaxed mb-6">
{study.challenge}
</p>
<div className="pt-6 border-t border-border-primary">
<div className="text-2xl font-bold text-brand-ink mb-1">{study.result}</div>
<div className="text-xs text-text-muted">核心成果</div>
</div>
</div>
</div>
))}
</StaggerReveal>
</div>
</section>
);
}