feat(layout): OPEN-02a 内缩白浮条落地(px 令牌 + 195 张基线重采)

导航由全宽贴顶条改为内缩白浮条:top 48 / 高 64,左右对齐 container-x 的 gutter。
值走 px 令牌(--header-inset-top / --header-height),避免根字号 16/17/18px 导致 rem 漂移。

契约变化:新增 data-header-state="top|scrolled" 与浮条测试锚点;外壳仍 top-0,
chrome-persistence 既有的「滚动后 top===0」断言保持不变,另加浮条 rect(48/64)断言;
移动抽屉起点改 calc(inset + height)。

基线:ADR-0012 预测 180 张,实测 195 张(32 页 × 5 + 主题首页 10 + 页头 5 + 元素级 20),
逐项归因后以 --update-snapshots=changed 写入;独立只读复跑 225 passed / 0 failed / EXIT=0(9.0 分钟)。
门禁:type-check / check:grammar 21/21 / check:motion / check:a11y 全绿,lint 0 error / 88 warning,
test:unit 159 套件 / 1883 例,导航三 spec 52 passed / 8 skipped(skip 均既有条件)。

OPEN-02a 关闭;OPEN-02b(滚动收方汉堡)维持不做。
This commit is contained in:
zhangxiang committed 2026-11-28 08:01:16 +08:00
1 parent f41c57d638
commit 353fbde8da
201 files changed
+237 -30

No files matched your search

+1 -1
View File
@@ -15,7 +15,7 @@ export default function MarketingLayout({
<ErrorBoundary>
{/* 单一 main 原则:全局 <main id="main-content">(ClientLayout)是唯一 landmark,
此处仅是布局容器,不得再声明 role="main"(2026-09-19 polish 收敛三重 main)。 */}
<div className="flex-1 pt-16">
<div className="flex-1 pt-[calc(var(--header-inset-top)+var(--header-height))]">
{children}
</div>
</ErrorBoundary>
+10
View File
@@ -348,6 +348,16 @@ body {
--container-max: 1360px;
--container-padding: 1rem;
/* === 页头「内缩白浮条」的几何真源(ADR-0012 §4,2026-11-26)===
**必须用 px,不能用 rem 档**:本仓根字号随断点变 16/17/18px,
`top-12`(3rem) 会得到 48/51/54 三个值,`h-16`(4rem) 得到 64/68/72 ——
而对标实测是固定的 top 48 / 高 64(ADR-0009 实测表「导航」行)。
同 R1「rem 圆角随断点漂移」的纪律(scripts/check-visual-grammar.mjs R1)。
消费方:`src/components/layout/header.tsx`(浮条本体)、
`src/app/(marketing)/layout.tsx`(内容让位)、`header.tsx` 的移动抽屉(面板起点)。 */
--header-inset-top: 48px;
--header-height: 64px;
/* === 影像比例真源(2026-11-02 对标实测)===
Porsche Consulting 中国站首页逐个 <img> getBoundingClientRect 量出的**只有四种**比例,
且每种绑定一个明确的构图角色(不是随手裁的):
+17 -11
View File
@@ -70,16 +70,22 @@ function HeaderContent() {
return (
<>
<motion.header
initial={false}
animate={{
height: isScrolled ? 64 : 80,
}}
transition={{ duration: 0.28, ease: [0.22, 1, 0.36, 1] }}
className="fixed top-0 left-0 right-0 z-50 transition-colors duration-normal bg-bg-primary border-b border-border-primary"
{/* 外壳只负责定位,**不画任何底色**:48px 的顶距要能透出下面的内容滚动,
才形成「浮条」而不是「贴顶条」。外壳保持 top-0 —— 于是
`e2e/chrome-persistence.spec.ts` 那条「页头滚动后 top≈0」的断言仍然成立
(它测的是吸顶没被 transform 劫持,与浮条无关)。 */}
<header
data-header-state={isScrolled ? 'scrolled' : 'top'}
className="fixed inset-x-0 top-0 z-50"
>
<div className="max-w-container mx-auto px-4 sm:px-6 lg:px-10">
<div className="flex items-center justify-between h-16 md:h-full">
{/* 内缩层:与 `container-x` 的 content 边对齐(1600 档实测 165…1435,
对标实测 173…1426,差 8–9px)。滚动时不再改高度 —— 浮条的形状本身就是签名。 */}
<div className="mx-auto w-full max-w-container px-4 pt-[var(--header-inset-top)] sm:px-6 lg:px-10">
<div
data-testid="header-bar"
className="relative flex items-center justify-between border border-border-primary bg-bg-primary transition-colors duration-normal"
style={{ height: 'var(--header-height)' }}
>
<StaticLink
href="/"
className="relative flex items-center group/logo"
@@ -188,7 +194,7 @@ function HeaderContent() {
</button>
</div>
</div>
</motion.header>
</header>
<AnimatePresence mode="wait">
{isOpen && (
@@ -216,7 +222,7 @@ function HeaderContent() {
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/95 backdrop-blur-xl overflow-y-auto"
className="absolute right-0 bottom-0 left-0 bg-bg-primary/95 backdrop-blur-xl overflow-y-auto" style={{ top: 'calc(var(--header-inset-top) + var(--header-height))' }}
id="mobile-menu"
role="navigation"
aria-label="移动端导航"