feat(home): 首屏改拼贴构图 + 外壳三修收口(Batch 1)
ADR-0009 的首屏读数取自对标 `opacity:0` 的视频轮播层(只在 ~13s 淡入 0.8s), 据此做出的「居中巨型声明」复刻的是一段过渡帧。本轮按静止态拼贴重做,并把 同批发现的四处结构缺陷收口。 首屏(拼贴) - 黑底半透明文字块(左 7/12)+ 右手错位副图(右 5/12,lg 起)+ 副图角上双 V + 深色影像上的斜线纹;素材复用既有 hero-architecture / industry-manufacturing, 禁人物入镜,题材换建筑/工业、语法不变 - title 字阶 90px → 桌面 44px(对标 100/700 是过渡帧字号,静止态短句是 40/700) - 诚实信号前置为 eyebrow:`2026 年 1 月成立 · 首批客户共创中`(均取常量单一真源) 令牌与面积纪律 - `--spacer-band` 7.5rem → 6.6667rem:原值注释称「16px 根字号下 120px」, 但 ≥1024px 根字号是 18px ⇒ 实测 135px,比对标的 120px 大 12.5% - 斜线纹加面积封顶(收束段原 h-full w-[38%] 实测 606×569,越过 ≤640×520) 新门禁 R20(check:grammar) - 裸 alpha 必须在 Tailwind opacity scale 内。`bg-[#0B0A08]/92` 与审计抓到的 `bg-bg-primary/98` 同根因:scale 外的值被编译器静默丢弃,computed 退化为 rgba(0,0,0,0)。type-check / lint / build / 单测四道全绿也拦不住 - 三向自证 + 真实树负对照(/95→/92 判红,改回即绿);上线当天即抓到本人 第二处同类失误(to-[#0B0A08]/88) 守卫与基线 - e2e/chrome-persistence.spec.ts:页头吸顶(1500/3000)、抽屉背景不透明、 mega 不被裁切。两处装配缺陷已修(`data-content-ready` 门控替代猜毫秒数; mega 必须 hover 打开,click 面板根本不挂载);注回缺陷 8/8 全红做负对照 - 视觉基线按授权重采 55 张(归因:同一棵树全量回滚后旧基线 26/26 全绿 ⇒ 失败全由本轮改动引起;只回滚外壳修复则 mobile 从 20 降到 4) 独立只读复跑 129 passed / 1 failed,那 1 条为并发抖动(单跑绿、连跑两轮 26/26) 文档 - ADR-0009 增「更正一」(首屏校准);签名件「逐字移植」改「同构再造」 - lessons §5.53–5.58;CONTEXT 决策表 4 行;quality-gates 记 R20 门禁:type-check / type-check:e2e / lint(0 error) / 158 套件 1854 例 / check:grammar 20-20 + selftest / check:motion / check:accents / check:brand-token / check:a11y / test:e2e:prod 80 passed / 视觉 129+ passed
This commit is contained in:
1 parent
8c64064181
commit
198d6a0303
70 files changed
+911
-54
No files matched your search
@@ -40,7 +40,7 @@ import type { CaseStudy } from '@/lib/constants/cases';
|
||||
import { weakestBasis } from '@/lib/constants/metrics-basis';
|
||||
import { INQUIRY_RESPONSE_COMMITMENT, FREE_FIRST_CONSULT } from '@/lib/constants/commitments';
|
||||
import { canonicalCtaLabel, CTA_LABELS } from '@/lib/constants/cta-labels';
|
||||
import { COMPANY_INFO } from '@/lib/constants';
|
||||
import { COMPANY_INFO, EARLY_ACCESS } from '@/lib/constants';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { ArrowRight } from 'lucide-react';
|
||||
import type { NewsItem } from '@/lib/constants/news';
|
||||
@@ -63,6 +63,30 @@ const CO_CREATION_STEPS: CoCreationStep[] = [
|
||||
|
||||
/* ───────────────────────── 1. Hero ───────────────────────── */
|
||||
|
||||
/**
|
||||
* 首屏 —— **拼贴构图**(2026-11-24 重做,替换「居中巨型声明」)。
|
||||
*
|
||||
* 为什么换:ADR-0009 的实测把对标首屏记成「全幅影像 + 居中声明 100/700,无框无容器底」,
|
||||
* 但那段 `100/700`(`携手共进促变革`)位于 `c-changeOverlay`,CSS 是 `opacity: 0` +
|
||||
* `transition: all 1.5s`,只在视频播放到 ~13s 时交叉淡入约 0.8s。**它是一帧过渡,
|
||||
* 不是静止态**。对标真正常驻的是 `c-collageOverlay`:全幅影像 + 642×380 照片 +
|
||||
* **642×184 黑底文字块**(内嵌 40/700 短句)+ 142×111 双 V + 第二张照片错位叠放。
|
||||
* 取 `opacity:0` 的层做读数、不校验该层此刻是否可见,是那次取证的方法论漏洞
|
||||
* (见 docs/lessons-learned.md 与 ADR-0009 的更正段)。
|
||||
*
|
||||
* 所以这里换的是**骨骼**、不是素材:主图仍是既有的 `hero-architecture.webp`(1920 宽、
|
||||
* 无人无文字无标识),副图用 `industry-manufacturing.webp`(工业内景)做错位叠放 ——
|
||||
* 对标靠人物照承担「我们在跟谁打交道」,本仓禁人物入镜(零编造 + 肖像授权),
|
||||
* 题材换成建筑与工业,构图语法不变。
|
||||
*
|
||||
* 三条硬约束(不是口味):
|
||||
* 1. **移动端首屏必须装得下 CTA**:`e2e/uj-11-home-conversion.spec.ts` 断言 390×844 下
|
||||
* `hero-cta` 的 `y + height ≤ 844`。所以黑底面板在移动档收窄内边距、副图 `lg` 起才出现。
|
||||
* 2. **h1 仍是文档里第一个 h1**(`check:headings` + 多个 e2e 以 `h1` 首个定位首屏)。
|
||||
* 3. **红仍不进正文**:首屏红只落在 eyebrow 短线与主 CTA 面上(≤10% 面积纪律)。
|
||||
*
|
||||
* 无 CMS 数据时 `heading` / `subheading` / 两组 CTA 文案全部走常量兜底,一条不硬写在 JSX 里。
|
||||
*/
|
||||
function HomeHero({ heroData }: { heroData?: Row | null }) {
|
||||
const heading = (heroData?.heading as string) || (heroData?.headingBottom as string)
|
||||
|| '让每一家企业都拥有数据驱动的决策能力';
|
||||
@@ -86,44 +110,103 @@ function HomeHero({ heroData }: { heroData?: Row | null }) {
|
||||
sizes="100vw"
|
||||
className="pointer-events-none absolute inset-0 -z-10 object-cover object-center"
|
||||
/>
|
||||
{/* 压暗是为白字可读(实测两家都靠渐变保可读),不是「暗黑滤镜」 */}
|
||||
{/* 压暗是为白字可读(两家对标都靠渐变保可读),不是「暗黑滤镜」。
|
||||
**方向随视口换**:桌面文字块在左、副图在右 ⇒ 从左到右;移动端文字块占满整宽、
|
||||
且底图右侧偏亮(窗光与浅色地面),横向渐变会让右半边的字压在亮处 ——
|
||||
实测 390 宽下「系统落地」一行几乎不可读。故移动档改为从上到下(下部压暗),
|
||||
`md` 起恢复横向。这不是审美选择,是「文字必须压在够暗的底上」的可读性要求。
|
||||
|
||||
**移动档的强度是量出来的,不是调出来的**:把 hero 内文字临时置 `visibility:hidden`、
|
||||
截「只剩底色」的图,再逐像素取文字盒内**最亮**的底色(pixel-accurate,非估算),
|
||||
算出半透明文字合成后的真实对比度。初版移动档 `80/60/85` 的最亮底色是
|
||||
rgb(108,104,95)(L=0.139),`text-white/75` 合成后仅 **3.94:1**、
|
||||
`text-white/70` 仅 **3.67:1** —— 均破 AA 4.5:1。**两道现有门禁都测不到它**:
|
||||
axe 对压在图片上的文字只出 incomplete(无法判定),`check:contrast` 只断言令牌配对。
|
||||
改 `85/80/88` 后最亮底色降到 L≈0.03,`/75` 合成后 ≥7:1(复测见 lessons-learned)。 */}
|
||||
<div
|
||||
aria-hidden="true"
|
||||
className="pointer-events-none absolute inset-0 -z-10 bg-gradient-to-b from-[#0B0A08]/70 via-[#0B0A08]/45 to-[#0B0A08]/80"
|
||||
className="pointer-events-none absolute inset-0 -z-10 bg-gradient-to-b from-[#0B0A08]/85 via-[#0B0A08]/80 to-[#0B0A08]/90 md:bg-gradient-to-r md:from-[#0B0A08]/80 md:via-[#0B0A08]/45 md:to-[#0B0A08]/25"
|
||||
/>
|
||||
{/* 软版斜线纹:全站唯一允许出现在「非接缝」位置的纹理,面积 ≤ 280×280 */}
|
||||
<HatchField tone="soft" className="absolute right-0 top-0 hidden h-56 w-56 lg:block" />
|
||||
|
||||
<div className="container-x flex min-h-[74vh] flex-col items-center justify-center py-24 text-center md:min-h-[80vh] md:py-28">
|
||||
<span className="text-[13px] font-medium tracking-[0.2em] text-white/70">
|
||||
{COMPANY_INFO.displayName} · 数字化转型伙伴
|
||||
</span>
|
||||
<div className="container-x relative flex min-h-[74vh] items-center py-14 md:min-h-[80vh] md:py-20">
|
||||
<div className="grid w-full items-center gap-10 lg:grid-cols-12 lg:gap-8">
|
||||
{/* 黑底文字块 —— 对标静止态拼贴里的 642×184 黑块那一层。
|
||||
半透明而非纯黑:底图仍要透出来,否则退化成「黑底 + 图当背景」。 */}
|
||||
<div className="lg:col-span-7">
|
||||
{/* ⚠ 不透明度只能取 Tailwind opacity scale 内的值(0/5/10/…/95/100)。
|
||||
本轮亲手复现了 P0-2 那个坑:初版写 `bg-[#0B0A08]/92`,class 在源码里、
|
||||
computed 却是 rgba(0,0,0,0) —— 面板整块透明,白字直接压在图与亮窗上。
|
||||
结构性守卫:`npm run check:grammar` 的 **R20**(任意值 alpha 必须落在 scale 内)。 */}
|
||||
<div className="bg-transparent p-7 sm:p-9 md:bg-[#0B0A08]/95 md:p-10 lg:p-12">
|
||||
{/* eyebrow:把「你是谁、到哪一步」前移到首屏,走与「内测中 / 共创中」
|
||||
同一族的状态签语法。两项都取常量单一真源,不在此硬写日期或状态。 */}
|
||||
<div className="flex items-center gap-3">
|
||||
<span aria-hidden="true" className="h-px w-8 shrink-0 bg-brand" />
|
||||
<span className="text-[13px] font-medium tracking-[0.15em] text-white/75">
|
||||
{COMPANY_INFO.foundedFull}成立 · {EARLY_ACCESS.label}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<h1 className="mt-6 max-w-5xl text-4xl font-bold leading-[1.04] tracking-tight text-balance text-white sm:text-5xl md:text-6xl lg:text-[5rem] lg:leading-[1.02]">
|
||||
{heading}
|
||||
</h1>
|
||||
{/* 字号档位对齐对标的 40/700 模块标题(本仓桌面 5xl=63px 偏大,
|
||||
故桌面取 44px;statement 档留给收束 CTA 的字重分裂)。 */}
|
||||
<h1 className="mt-6 max-w-xl text-[2rem] font-bold leading-[1.16] tracking-tight text-balance text-white sm:text-4xl md:text-5xl lg:text-[2.75rem] lg:leading-[1.14]">
|
||||
{heading}
|
||||
</h1>
|
||||
|
||||
{subheading && (
|
||||
<p className="mt-7 max-w-2xl text-base leading-relaxed text-white/75 md:text-lg">
|
||||
{subheading}
|
||||
</p>
|
||||
)}
|
||||
{subheading && (
|
||||
<p className="mt-5 max-w-lg text-base leading-relaxed text-white/75">
|
||||
{subheading}
|
||||
</p>
|
||||
)}
|
||||
|
||||
<div className="mt-10 flex flex-wrap items-center justify-center gap-4">
|
||||
<CTAButton href={ctaHref} dataTestId="hero-cta">{ctaLabel}</CTAButton>
|
||||
<CTAButton
|
||||
href={secondaryHref}
|
||||
variant="secondary"
|
||||
className="border-white/40 bg-transparent text-white hover:border-white hover:bg-white/10"
|
||||
>
|
||||
{secondaryLabel}
|
||||
</CTAButton>
|
||||
<div className="mt-8 flex flex-wrap items-center gap-4">
|
||||
<CTAButton href={ctaHref} dataTestId="hero-cta">{ctaLabel}</CTAButton>
|
||||
<CTAButton
|
||||
href={secondaryHref}
|
||||
variant="secondary"
|
||||
className="border-white/40 bg-transparent text-white hover:border-white hover:bg-white/10"
|
||||
>
|
||||
{secondaryLabel}
|
||||
</CTAButton>
|
||||
</div>
|
||||
|
||||
{/* 承诺句走单一真源,不在此硬写数字 */}
|
||||
{/* ⚠ 不透明度是量出来的:`/70` 在移动档实测合成对比度仅 **2.44:1**(最亮底色
|
||||
rgb(154,138,127)),破 AA 4.5:1。/85 合成后 ≈4.9:1。这类「压在图上的半透明
|
||||
小字」两道现有门禁都测不到 —— 见紧邻 scrim 注释里的量法。 */}
|
||||
<p className="mt-7 text-sm text-white/85">
|
||||
{INQUIRY_RESPONSE_COMMITMENT.text} · {FREE_FIRST_CONSULT.text}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 右手错位副图 + 双 V —— 对标拼贴的第二张照片与角标。
|
||||
移动/平板隐藏:首屏宽度装不下两块,且 uj-11 要求 CTA 留在 844 折线内。 */}
|
||||
<div className="relative hidden lg:col-span-5 lg:block">
|
||||
{/* 斜线纹压在副图左上角:ADR-0009 决策三允许的两种用法之一是「黑底/ink 底纹理」,
|
||||
这里是深色影像上的纹理叠加。面积 160×160,远低于单块 ≤640×520 的上限。
|
||||
全站各块的实际面积纪律见收束段那处的注释(唯一越界项在那里,不在这里)。 */}
|
||||
<HatchField className="absolute -left-8 -top-8 z-10 h-40 w-40" />
|
||||
<div className="relative ml-auto w-[88%] translate-y-8">
|
||||
<div className="relative aspect-[3/4] overflow-hidden bg-[#141210]">
|
||||
<Image
|
||||
src="/images/home/industry-manufacturing.webp"
|
||||
alt=""
|
||||
aria-hidden="true"
|
||||
fill
|
||||
sizes="(min-width: 1024px) 30vw, 100vw"
|
||||
className="object-cover"
|
||||
/>
|
||||
</div>
|
||||
{/* 双 V 落在副图左下角外侧:对标把它放在拼贴的接缝上,指向「还有下文」 */}
|
||||
<DoubleChevron
|
||||
direction="down"
|
||||
size="sm"
|
||||
className="absolute -bottom-10 -left-7 text-white/90"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 承诺句走单一真源,不在此硬写数字 */}
|
||||
<p className="mt-9 text-sm text-white/60">
|
||||
{INQUIRY_RESPONSE_COMMITMENT.text} · {FREE_FIRST_CONSULT.text}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
@@ -344,8 +427,13 @@ function HomeCta({ heroData }: { heroData?: Row | null }) {
|
||||
const ctaHref = (heroData?.ctaHref as string) || '/contact';
|
||||
return (
|
||||
<section className="relative isolate overflow-hidden bg-bg-secondary" data-testid="home-cta">
|
||||
{/* 右半幅斜线纹:实测收束段把纹理放在灰带之外、与灰带的直角边相接 */}
|
||||
<HatchField className="absolute right-0 top-0 hidden h-full w-[38%] md:block" />
|
||||
{/* 右半幅斜线纹:实测收束段把纹理放在灰带之外、与灰带的直角边相接。
|
||||
⚠ 面积纪律(ADR-0009 决策三:单块 ≤640×520)—— 原实现是 `h-full w-[38%]`,
|
||||
在 1600 视口实测 **606×569**,高度越界 49px;而它越界的成因是「高度跟着段落长」,
|
||||
段落一改高就再越界,是一条没有上界的声明。现改为封顶:高度 max 520、宽度 max 640。
|
||||
顺带补一条实测口径:对标那三块纹理是 642×514 / 571×625 / 579×409,
|
||||
全部约 600 宽、**都不是全出血**,所以封顶不是妥协,而是与对标一致。 */}
|
||||
<HatchField className="absolute right-0 top-0 hidden h-full max-h-[520px] w-[38%] max-w-[640px] md:block" />
|
||||
<div className="container-x relative py-20 md:py-28">
|
||||
<ScrollReveal>
|
||||
<div className="max-w-2xl">
|
||||
@@ -436,7 +524,8 @@ export default function HomeContentV17({
|
||||
{/* 接缝:黑底舞台 → 白底成果段。纹理块用负外边距**跨**在交界上(上一半压黑、
|
||||
下一半压白)—— 对标用纹理接缝代替渐变,这是它最好认的一个手法。 */}
|
||||
<div aria-hidden="true" className="relative z-10 container-x -mb-6 -mt-10">
|
||||
<HatchField className="h-20 w-full sm:w-[60%]" />
|
||||
{/* 同上:宽度封顶 640(对标三块接缝纹理均约 600 宽,不是全出血)。这条接缝高 80px。 */}
|
||||
<HatchField className="h-20 w-full max-w-[640px] sm:w-[60%]" />
|
||||
</div>
|
||||
|
||||
<ResultsSlot state={resultsState} />
|
||||
|
||||
+10
-2
@@ -273,8 +273,16 @@ body {
|
||||
CTA 之后各放了一条**独立的 120px 空模块**(实测两条 `.o-module` 高度均为 120px、
|
||||
内部零内容、padding 为 0)—— 它的节奏不靠段内 padding,而靠一条命名的空白带。
|
||||
记成令牌而不是让各段自定 py,是为了让「呼吸」可数、可比对、可被闸看见。
|
||||
7.5rem 在根字号 16px 下 = 120px,与实测口径一致。 */
|
||||
--spacer-band: 7.5rem;
|
||||
|
||||
★ 2026-11-24 更正(本条此前写错过,且错法是可复算的):
|
||||
原值 `7.5rem` 的注释称「16px 根字号下 = 120px」—— 数值本身没错,**锚错断点了**。
|
||||
对标读数取于 1600×900 桌面,而本仓 `html{font-size}` 在 ≥1024px 是 **18px**
|
||||
(globals.css 断点表 16/17/18),于是 7.5rem 实测渲染 **135px**,比对标大 12.5%。
|
||||
空白带存在的全部理由就是「与对标的 120px 可比对」,差 15px 即失去可比性。
|
||||
现取 `20/3 rem`:× 18px = **120px**(桌面,比对口径);平板 17px → 113.3px、
|
||||
移动 16px → 106.7px,随根字号等比缩放是刻意的(与其它 rem 间距同族)。
|
||||
机器判据:src/components/ui/band-spacer.test.tsx(读本文件、按 18px 复算)。 */
|
||||
--spacer-band: 6.6667rem;
|
||||
|
||||
/* 圆角系统 —— 0–4px 记档(2026-10-16 对标实测收口)
|
||||
Bain & Company(archive 2026-08-31, 1600×846)与 Porsche Consulting(live)两家的
|
||||
|
||||
@@ -205,12 +205,18 @@ function HeaderContent() {
|
||||
onClick={() => setIsOpen(false)}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
{/* ⚠ 不透明度只可取 Tailwind opacity scale 内的值(/95 合法,/98 不合法)。
|
||||
2026-11-24 审计实测:`bg-bg-primary/98` 的 `/98` 不在 scale 里,编译器
|
||||
**静默不生成**该规则(同族 /95 正常生成),于是抽屉面板背景是
|
||||
rgba(0,0,0,0) —— 抽屉文字直接压在首页深色建筑照与朱砂 CTA 上。
|
||||
「class 写在源码里」与「CSS 真的存在」是两件事,grep 只能验到前者。
|
||||
回归判据:e2e/chrome-persistence.spec.ts「移动抽屉的面板背景不得是透明的」。 */}
|
||||
<motion.div
|
||||
initial={{ x: '100%' }}
|
||||
animate={{ x: 0 }}
|
||||
exit={{ x: '100%' }}
|
||||
transition={{ duration: 0.25, ease: [0.22, 1, 0.36, 1] }}
|
||||
className="absolute top-16 right-0 bottom-0 left-0 bg-bg-primary/98 backdrop-blur-xl overflow-y-auto"
|
||||
className="absolute top-16 right-0 bottom-0 left-0 bg-bg-primary/95 backdrop-blur-xl overflow-y-auto"
|
||||
id="mobile-menu"
|
||||
role="navigation"
|
||||
aria-label="移动端导航"
|
||||
|
||||
@@ -111,7 +111,13 @@ export function MegaDropdown({ label, groups, isOpen, isActive, viewAllHref, onT
|
||||
transition={{ duration: 0.15, ease: [0.22, 1, 0.36, 1] }}
|
||||
className="absolute top-full left-1/2 -translate-x-1/2 pt-2 w-[640px] z-50"
|
||||
>
|
||||
<div className="bg-bg-primary backdrop-blur-xl rounded-none border border-border-primary p-6">
|
||||
{/* ⚠ 面板高度必须封顶。2026-11-24 审计实测:原实现无任何 max-h,`能力` 面板在
|
||||
1280×720 下高 946px、`overflow-y: visible`,把底部「查看全部能力」与
|
||||
「睿视 NovaVis」裁掉 289px 且无处可滚 —— 而「产品矩阵」是通往 `/products`
|
||||
的唯一路径(产品已退出一级导航),等于在主流笔记本尺寸上把整块产品矩阵藏掉。
|
||||
封顶取 `100vh - 6rem`:让出页头上方留白(pt-2)与视口的呼吸,不足时面板自身滚动。
|
||||
回归判据:e2e/chrome-persistence.spec.ts「能力 mega 面板在 1280x720 下不被裁切」。 */}
|
||||
<div className="bg-bg-primary backdrop-blur-xl rounded-none border border-border-primary p-6 max-h-[calc(100vh-6rem)] overflow-y-auto overscroll-contain">
|
||||
{groups.map((group, groupIndex) => (
|
||||
<div key={group.id} className={groupIndex > 0 ? 'mt-6 pt-6 border-t border-border-primary' : ''}>
|
||||
<div className="flex items-center gap-2 mb-3">
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
import { readFileSync } from 'fs';
|
||||
import path from 'path';
|
||||
import { BandSpacer } from './band-spacer';
|
||||
|
||||
/**
|
||||
* 空白带的判据分两层,缺一层就会漏掉 2026-11-24 抓到的那类缺陷:
|
||||
*
|
||||
* ① 组件层:高度必须走 `h-band`(映射 `--spacer-band`),不得写 `h-[120px]` 字面量 ——
|
||||
* 根字号随断点取 16/17/18,字面量会让这条带子与其它 rem 间距脱钩。
|
||||
* ② **令牌层:`--spacer-band` 必须在桌面根字号下真的等于 120px。**
|
||||
* 这是本轮实际发生的错误:原值 `7.5rem`,注释写「16px 根字号下 = 120px」,
|
||||
* 而本仓 ≥1024px 的根字号是 18px ⇒ 实测渲染 135px,比对标的 120px 大 12.5%。
|
||||
* 组件层测试当时全绿(它只验 class 名),因为**缺陷在于令牌值与它声称的读数不符**,
|
||||
* 而不在于组件怎么用它。所以这里直接读 globals.css 复算,锚在桌面那一档。
|
||||
*
|
||||
* 为什么用「读文件 + 算乘法」而不是渲染后量 getBoundingClientRect:
|
||||
* jsdom 不做布局,量出来恒为 0;而 Playwright 侧的视觉基线只能告诉你「变了」,
|
||||
* 不能告诉你「120 是哪个断点的口径」。算式进单测,读数才是可复算的。
|
||||
*/
|
||||
|
||||
const GLOBALS_CSS = path.join(process.cwd(), 'src/app/globals.css');
|
||||
const rawCss = readFileSync(GLOBALS_CSS, 'utf-8');
|
||||
|
||||
/**
|
||||
* 先剥注释再解析。不剥会得出两个假结论:
|
||||
* - 注释里的 `7.5rem` 会被当成现行令牌值读到(本次改动的说明里就引用了它);
|
||||
* - 注释里出现的 `html {` 一类片段会打乱块边界。
|
||||
* 块注释替换成等量换行,行号不漂移(与 check-visual-grammar 的 stripComments 同一条纪律)。
|
||||
*/
|
||||
const css = rawCss.replace(/\/\*[\s\S]*?\*\//g, (m) => '\n'.repeat(m.match(/\n/g)?.length ?? 0));
|
||||
|
||||
/** 取 `--<name>: <n><rem|px>;` 的声明(只认 rem/px;别的单位说明写法变了,按不可度量处理) */
|
||||
function readToken(name: string): { value: number; unit: 'rem' | 'px' } | null {
|
||||
const m = new RegExp(`^\\s*${name}\\s*:\\s*([\\d.]+)(rem|px)\\s*;`, 'm').exec(css);
|
||||
if (!m?.[1] || !m[2]) return null;
|
||||
return { value: Number(m[1]), unit: m[2] as 'rem' | 'px' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 逐字符扫一遍,记录每个 `html { font-size: Npx }` 被哪一档 `@media (min-width: N)` 包裹。
|
||||
*
|
||||
* 为什么不用正则「`html {` 后紧跟 font-size」:globals.css 开头还有一个只设背景色的
|
||||
* `html { }`,基础块里 `scroll-behavior` 与 7 行注释也排在 font-size 之前 ——
|
||||
* 两种简单写法分别读到 null 与 null(或错读成 17px)。嵌套关系只有按花括号游标才可靠。
|
||||
*/
|
||||
function rootFontSizes(): Array<{ px: number; minWidth: number | null }> {
|
||||
const out: Array<{ px: number; minWidth: number | null }> = [];
|
||||
/** 每层花括号的语境:若是 min-width 媒体查询就记下断点,否则 null */
|
||||
const stack: Array<number | null> = [];
|
||||
let selector = '';
|
||||
let body = '';
|
||||
let inHtmlBlock = false;
|
||||
|
||||
for (let i = 0; i < css.length; i++) {
|
||||
const ch = css[i]!;
|
||||
if (ch === '{') {
|
||||
const media = /@media\s*\(min-width:\s*(\d+)px\)\s*$/.exec(selector.trim());
|
||||
// 当前选择器是否是 html(允许 `html, body` 之类列表里的首个)
|
||||
const isHtml = /(^|[,{}])\s*html\s*$/.test(selector.trim());
|
||||
stack.push(media?.[1] ? Number(media[1]) : null);
|
||||
inHtmlBlock = isHtml;
|
||||
body = '';
|
||||
selector = '';
|
||||
continue;
|
||||
}
|
||||
if (ch === '}') {
|
||||
if (inHtmlBlock) {
|
||||
const fm = /font-size:\s*(\d+)px/.exec(body);
|
||||
if (fm?.[1]) {
|
||||
const minWidth = [...stack].reverse().find((v) => v !== null) ?? null;
|
||||
out.push({ px: Number(fm[1]), minWidth });
|
||||
}
|
||||
inHtmlBlock = false;
|
||||
}
|
||||
stack.pop();
|
||||
selector = '';
|
||||
body = '';
|
||||
continue;
|
||||
}
|
||||
if (inHtmlBlock) body += ch;
|
||||
else selector += ch;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
const ROOT_FONT_SIZES = rootFontSizes();
|
||||
|
||||
function fontSizeAt(minWidth: number | null): number | null {
|
||||
return ROOT_FONT_SIZES.find((r) => r.minWidth === minWidth)?.px ?? null;
|
||||
}
|
||||
|
||||
describe('BandSpacer', () => {
|
||||
it('高度走 --spacer-band 的 h-band,而不是 h-[120px] 字面量', () => {
|
||||
const { container } = render(<BandSpacer />);
|
||||
const el = container.firstElementChild as HTMLElement;
|
||||
expect(el.className).toContain('h-band');
|
||||
expect(el.className).not.toMatch(/h-\[\d+px\]/);
|
||||
});
|
||||
|
||||
it('纯空白:aria-hidden,不携带任何文本', () => {
|
||||
const { container } = render(<BandSpacer />);
|
||||
const el = container.firstElementChild as HTMLElement;
|
||||
expect(el).toHaveAttribute('aria-hidden', 'true');
|
||||
expect(el.textContent).toBe('');
|
||||
});
|
||||
|
||||
/**
|
||||
* 前提先行:三档根字号必须仍是 16 / 17 / 18。
|
||||
* 如果这条先红,下面的 120px 算式就是在用一个不存在的口径背书 ——
|
||||
* 与「先断言被污染那段 DOM 真渲染了」是同一条纪律。
|
||||
*/
|
||||
it('前提:根字号三档仍是移动 16 / 平板 17 / 桌面 18(算式的地基)', () => {
|
||||
expect(fontSizeAt(null)).toBe(16);
|
||||
expect(fontSizeAt(640)).toBe(17);
|
||||
expect(fontSizeAt(1024)).toBe(18);
|
||||
});
|
||||
|
||||
it('令牌在桌面根字号下算出 120px(对标实测值,±1px 吸收取整)', () => {
|
||||
const token = readToken('--spacer-band');
|
||||
if (!token) throw new Error('--spacer-band 未在 globals.css 中以 rem/px 声明');
|
||||
const rootDesktop = fontSizeAt(1024);
|
||||
if (rootDesktop === null) throw new Error('未能解析 ≥1024px 断点的 html font-size');
|
||||
|
||||
const renderedPx = token.unit === 'rem' ? token.value * rootDesktop : token.value;
|
||||
const drift = Math.abs(renderedPx - 120);
|
||||
if (drift > 1) {
|
||||
throw new Error(
|
||||
`--spacer-band 实测渲染 ${renderedPx.toFixed(2)}px(${token.value}${token.unit} × 根 ${rootDesktop}px),` +
|
||||
`对标实测 120px。空白带的全部理由是「可与对标比对」,差 ${(renderedPx - 120).toFixed(2)}px 即失去可比性。`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('敏感性自证:7.5rem 在 18px 根字号下必然违反上一条(历史错误可被复算)', () => {
|
||||
// 不依赖改文件 —— 证明判据咬得住「7.5rem × 18px = 135px ≠ 120px」这个真实犯过的错。
|
||||
expect(Math.abs(7.5 * 18 - 120)).toBeGreaterThan(1);
|
||||
});
|
||||
});
|
||||
@@ -15,6 +15,13 @@ import { cn } from '@/lib/utils';
|
||||
* 原站是用 `<img>` 指定宽高的,因此**本身就是非等比拉伸**的 —— 这里用
|
||||
* `preserveAspectRatio="none"` 忠实还原那个观感,而不是"顺手修正"成等比。
|
||||
*
|
||||
* ⚠ **不要把这个组件描述成「逐字移植」**(2026-11-24 审计更正)。逐字的只有 `d` 路径
|
||||
* 与两档原物的 viewBox 数字;**渲染出来的 SVG viewBox 是重新推导的** —— 原物是两份独立
|
||||
* `<img>` 各自定位,这里用一份 SVG 内两枚 `<path>` + `transform` 表达那个 0.34 偏移,
|
||||
* 所以包围盒必须含偏移量:right 实测 `150.08×145`(= 112×1.34)、down `23.938×29.48`
|
||||
* (= 22×1.34)。这是**同构再造**,不是逐字。`check:grammar` R18 只查「有没有第二份手抄」,
|
||||
* 查不出「第一份的包围盒与自己声称的原物不同」—— 所以这条注释是它唯一的防线。
|
||||
*
|
||||
* 静止,不做动画:对标原物挂了 `pulseVertical/pulseHorizontal 6s infinite` 的引导脉冲,
|
||||
* 但 CONTEXT.md:81 明令禁止循环装饰动画,且双 V 本身已经是「还有下文」的信号。
|
||||
* 这条裁定记在 ADR-0009;要开动画必须单独裁定并同时改 CONTEXT.md。
|
||||
|
||||
@@ -45,7 +45,18 @@ export function PageTransition({ children }: { children: React.ReactNode }) {
|
||||
// 切换 state 的机会被错过 ⇒ 同一个 motion.div 永久停在 exit 变体(实测 inline opacity:0;
|
||||
// translateY(-8px)),整页白屏,刷新(走 mounted=false 的裸 children 路径)才恢复。
|
||||
// 现在只保留入场:key 随 pathname 变化触发重挂,入场动画仍按令牌层 280ms 播放。
|
||||
// 回归守卫:e2e/client-navigation-visibility.spec.ts。
|
||||
// 回归守卫:e2e/client-navigation-visibility.spec.ts、e2e/chrome-persistence.spec.ts。
|
||||
//
|
||||
// ★ 2026-11-24(chrome-persistence 审计):这里**不能**再常驻 `willChange: 'transform, opacity'`。
|
||||
// `will-change: transform` 会让本元素成为 `position: fixed` 后代的**包含块**(与 transform/filter
|
||||
// 同族语义),于是所有 fixed 定位的站点外壳都改成「相对本文档高度的祖先」定位:
|
||||
// · `<header>` 写的是 fixed,实测 scrollY=1500 时 top=-1495.34 —— 页头随页面滚走了,
|
||||
// 连带 `isScrolled`(80→64)成为纯视觉空转;
|
||||
// · 移动抽屉的 `fixed inset-0` 被拉成文档高度(11381px,视口仅 844),既锁不住页面、
|
||||
// 又无法自身滚动。
|
||||
// 删掉 style 后 fixed 恢复相对视口。framer-motion 在动画进行时自己会写 will-change,
|
||||
// 动画结束再撤掉 —— 那是「按需」,与这里的「常驻」不是一回事。回归判据见
|
||||
// e2e/chrome-persistence.spec.ts「页头在滚动 Npx 后仍吸附视口顶部」两条用例。
|
||||
const reducedVariants = {
|
||||
initial: { opacity: 1, y: 0, scale: 1 },
|
||||
animate: { opacity: 1, y: 0, scale: 1, transition: { duration: 0 } },
|
||||
@@ -58,10 +69,6 @@ export function PageTransition({ children }: { children: React.ReactNode }) {
|
||||
variants={variants}
|
||||
initial={shouldReduceMotion ? false : 'initial'}
|
||||
animate="animate"
|
||||
style={{
|
||||
willChange: 'transform, opacity',
|
||||
backfaceVisibility: 'hidden',
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
|
||||
Reference in new issue
Block a user