From 163e2c5ed88456a10b7a05460570bac750d02c10 Mon Sep 17 00:00:00 2001 From: zhangxiang Date: Tue, 3 Nov 2026 10:17:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(design):=20=E7=AD=BE=E5=90=8D=E4=BB=B6?= =?UTF-8?q?=E5=8E=9F=E8=AF=AD=EF=BC=88=E6=96=9C=E7=BA=BF=E7=BA=B9/?= =?UTF-8?q?=E5=8F=8CV/=E6=96=9C=E6=9D=A0/=E7=A9=BA=E7=99=BD=E5=B8=A6?= =?UTF-8?q?=EF=BC=89+=20R18=E2=80=93R19=20=E9=97=A8=E7=A6=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 三件几何都是 2026-11-03 对 Porsche Consulting 中国站首页放大到像素级确认的原物, 换掉色相后逐字移植(朱砂 #C41E3A 取代 #D6001D,ADR-0008 决策一已裁定): - HatchField 斜线纹。原物是 20×20 SVG 平铺 + rotate(140deg) + 1px 横线。 换 CSS 等价形,两处换算写进组件与 :root 注释: 角度 140deg(CSS 渐变线方向 = A-180 ≡ -40° ≡ 140°,直线有 180° 对称)、 垂距 12.86px(= 20 × sin140°,照抄 20px 会让纹理稀掉一半)。 - DoubleChevron **两枚不同的形,不是一枚旋转**:向下(23.938×22 路径,第二枚下偏 26/77)用于黑段与图角;向右(112×145 路径,第二枚右偏 36/106)用于 收束段。两份原物路径首段逐字保留,第二枚走 transform 而非重画。 渲染框取自实测包围盒;原站用 指定宽高、本身就是非等比拉伸, 故 preserveAspectRatio="none" 是忠实还原,不是偷懒。 - SlashMark 18×17 平行四边形(原 img_divider.svg),供 01/04 计数器与 › 前导符。 - BandSpacer 对标首页两条独立 120px 空模块(内部零内容、padding 0)。本仓 20+ 段 都自带 py-16 md:py-24,所以**只新增**这条带子、不把段内 padding 归零。 裁定:双 V 静止。原物挂了 pulseVertical/pulseHorizontal 6s infinite 的引导脉冲, 但 CONTEXT.md:81 禁循环装饰动画,且双 V 本身已是「还有下文」的信号。记入 ADR-0009。 门禁 - R18 营销面零签名件字面量(tile_hatching / rotate(140 / 三枚路径首段),上限 0 即硬禁 —— 之前全仓零命中,登记非零上限等于给第二份纹样真源预开名额。 - R19 营销面零 font-extrabold(800),棘轮 21。字重纪律只约束声明档与模块标题: 实测 font-medium 77 / font-semibold 68 处是标签与元信息在用,一刀切成 400/700 是 145 处无视觉收益的大迁移,不做。 两处顺带修复(都在本分支基线就红,非本次引入) - image-module.tsx 引用了不存在的 ImageRatioKey(真源导出的是 ImageRatio)。 - 该文件与 image-ratios.ts、display-statement.tsx 此前只存在于工作树未入库, 而 index.ts 已导出 image-ratios ⇒ 单独看是断的。随本提交一并入库。 验证:check:grammar --selftest 全部两侧自证通过(R13–R19 各自「上限不判红/上限+1 判红」); check:grammar EXIT=0(19/19,R18 实测 0、R19 实测 21);type-check EXIT=0; jest ui/{hatch-field,double-chevron,slash-mark} 17/17。 --- scripts/check-visual-grammar.mjs | 61 ++++++++++--- src/app/globals.css | 47 ++++++++++ src/components/ui/band-spacer.tsx | 17 ++++ src/components/ui/display-statement.tsx | 57 ++++++++++++ src/components/ui/double-chevron.test.tsx | 67 ++++++++++++++ src/components/ui/double-chevron.tsx | 80 +++++++++++++++++ src/components/ui/hatch-field.test.tsx | 39 +++++++++ src/components/ui/hatch-field.tsx | 43 +++++++++ src/components/ui/image-module.tsx | 101 ++++++++++++++++++++++ src/components/ui/slash-mark.test.tsx | 55 ++++++++++++ src/components/ui/slash-mark.tsx | 52 +++++++++++ src/lib/constants/image-ratios.ts | 35 ++++++++ 12 files changed, 643 insertions(+), 11 deletions(-) create mode 100644 src/components/ui/band-spacer.tsx create mode 100644 src/components/ui/display-statement.tsx create mode 100644 src/components/ui/double-chevron.test.tsx create mode 100644 src/components/ui/double-chevron.tsx create mode 100644 src/components/ui/hatch-field.test.tsx create mode 100644 src/components/ui/hatch-field.tsx create mode 100644 src/components/ui/image-module.tsx create mode 100644 src/components/ui/slash-mark.test.tsx create mode 100644 src/components/ui/slash-mark.tsx create mode 100644 src/lib/constants/image-ratios.ts diff --git a/scripts/check-visual-grammar.mjs b/scripts/check-visual-grammar.mjs index 0cd33d62..dc0998a5 100644 --- a/scripts/check-visual-grammar.mjs +++ b/scripts/check-visual-grammar.mjs @@ -88,11 +88,16 @@ const MARKETING_TEST_RE = /\.(test|spec)\.tsx?$/; const MARKETING_FLOOR = 60; /** - * R13–R17 的**存量上限**(现取 2026-11-02:营销面 78 个 .tsx,排除 .test/.spec 与 _archive)。 + * R13–R19 的**存量上限**(R13–R17 现取 2026-11-02;R18/R19 现取 2026-11-03: + * 营销面 78 个 .tsx,排除 .test/.spec 与 _archive)。 * 每条只许减不许加;跌破即提示下调(同 R10 棘轮的纪律,防止「闸还在、存量已被自己删空」 * 退化成永久豁免)。清零后把上限登记为 0,判据即变成硬禁。 + * + * R18 是**硬禁**(0):签名件(斜线纹 / 双 V / 斜杠)在 2026-11-03 之前全仓零命中, + * 没有「存量」可言 —— 登记一个非零上限等于给第二份纹样真源预开一个名额。 + * R19 是棘轮(21):营销面实测 21 处 font-extrabold,先登记再随模板批逐页清。 */ -const MARKETING_HIT_CEILINGS = { R13: 71, R14: 21, R15: 21, R16: 26, R17: 53 }; +const MARKETING_HIT_CEILINGS = { R13: 71, R14: 21, R15: 21, R16: 26, R17: 53, R18: 0, R19: 21 }; /** * 判据正则一律**不带 g 旗标**。 @@ -108,6 +113,15 @@ const HOVER_LIFT_RE = /hover:-translate-y\b/; const DECOR_SHADOW_RE = /(?:hover:shadow(?:-[a-z0-9]+)?(?::\[[^\]]+\])?|\bshadow-(?:2xl|xl|lg)\b)/; const BRAND_SURFACE_RE = /\bbg-brand-(?:soft|section)\b/; const FONT_BLACK_RE = /\bfont-black\b/; +const FONT_EXTRA_BOLD_RE = /\bfont-extrabold\b/; +/** + * 签名件(斜线纹 / 双 V / 斜杠)的**字面量**。锛的是实测原物的可辨认片段: + * `tile_hatching` —— 对标那张 20×20 SVG 平铺图的名字; + * `rotate(140` —— 那张图的 patternTransform(本仓正确的等价形是 CSS 变量,不写角度字面量); + * `M22 14.204` / `M70.09 0` / `M15.2539` —— 三枚原物的路径首段。 + * 命中即意味着有人绕开了 ui/ 下的原语,把手抄的第二份纹样塞进了营销页。 + */ +const SIGNATURE_LITERAL_RE = /tile_hatching|rotate\(\s*140|M22 14\.204|M70\.09 0|M15\.2539/; /** * 数命中数。**必须每次新建 RegExp**:带 g 的正则是状态机,复用同一个实例时 @@ -436,6 +450,26 @@ function checkGrammar(rawText, rawFiles, twConfig = "", opts = {}) { red: r17Count > ceilings.R17 ? [`营销面 font-black ${r17Count} 处 > 上限 ${ceilings.R17}(声明档走 text-statement + font-bold / font-normal 的字重分裂)`] : [], note: `实测 ${r17Count} 处 · 上限 ${ceilings.R17}${r17Count < ceilings.R17 ? " ⇒ 请把上限下调" : ""}` }); + // R18 签名件只能有一个真源。斜线纹 / 双 V / 斜杠三件在 ui/ 下各有原语 + // (hatch-field / double-chevron / slash-mark),营销页只允许 import 它们。 + // 手抄一份路径或背景图 = 第二个真源,以后改几何就会一半新一半旧,而闸看不见 —— + // 这正是本仓「两套 gutter 同时在线」那一类病的同型。上限登记 0,即硬禁。 + const r18Files = marketingFiles.filter(([, f]) => countHits(f, SIGNATURE_LITERAL_RE) > 0); + const r18Count = marketingFiles.reduce((a, [, f]) => a + countHits(f, SIGNATURE_LITERAL_RE), 0); + rule({ id: "R18", name: "营销面零签名件字面量(只许走 ui/ 原语)", denominator: rScan, + red: r18Count > ceilings.R18 + ? [`营销面手抄纹样 ${r18Count} 处 > 上限 ${ceilings.R18}(${r18Files.map(([p]) => p).join(", ")})—— 斜线纹走 HatchField、双 V 走 DoubleChevron、斜杠走 SlashMark`] + : [], + note: `实测 ${r18Count} 处 / ${r18Files.length} 文件 · 上限 ${ceilings.R18}` }); + + // R19 字重集合的第二轴。800 不是对标的字重(实测只有 400/700),也不是本仓 + // 声明档的字重(那是 700 + 400 的**字重分裂**)。保留为棘轮而非硬禁,是因为 + // 21 处存量全在模板批的清单里,随 P4 逐页清;清完把上限降到 0 即变硬禁。 + const r19Count = marketingFiles.reduce((a, [, f]) => a + countHits(f, FONT_EXTRA_BOLD_RE), 0); + rule({ id: "R19", name: "营销面零 font-extrabold(800)", denominator: rScan, + red: r19Count > ceilings.R19 ? [`营销面 font-extrabold ${r19Count} 处 > 上限 ${ceilings.R19}(层级走字号 × 字重两轴:声明档 700/400 分裂,不用更粗的中间档)`] : [], + note: `实测 ${r19Count} 处 · 上限 ${ceilings.R19}${r19Count < ceilings.R19 ? " ⇒ 请把上限下调" : ""}` }); + return results; } @@ -506,37 +540,42 @@ function selftest() { * 夹具一律带 `opts.floor = 0`:合成样本只有一两个文件, * 不关掉地板就会把「扫描面太小」的红混进这一维,读数不再单义。 */ - const dirty = `
`; + const dirty = `
`; const inScope = (rel) => new Map([[rel, dirty]]); const hitRed = (rel, id, ceiling) => checkGrammar(cssText, inScope(rel), "", { floor: 0, hitCeilings: { [id]: ceiling } }) .find((x) => x.id === id).red.length; - const scopeBad = ["R13", "R14", "R15", "R16", "R17"].filter( + const scopeIds = ["R13", "R14", "R15", "R16", "R17", "R18", "R19"]; + const scopeBad = scopeIds.filter( (id) => hitRed("src/app/(marketing)/x.tsx", id, 0) === 0); - const scopeOver = ["R13", "R14", "R15", "R16", "R17"].filter( + const scopeOver = scopeIds.filter( (id) => hitRed("src/components/ui/x.tsx", id, 0) > 0); if (scopeBad.length || scopeOver.length) { - console.log(` ✗ R13–R17 扫描面不自证:营销面漏抓 ${scopeBad.join(",") || "无"}、越界误报 ${scopeOver.join(",") || "无"} ⇒ 上面所有绿灯不作数`); + console.log(` ✗ R13–R19 扫描面不自证:营销面漏抓 ${scopeBad.join(",") || "无"}、越界误报 ${scopeOver.join(",") || "无"} ⇒ 上面所有绿灯不作数`); return 1; } - console.log(" ✓ R13–R17 双向:营销面已知违规全判红、ui/ 同名内容不误报(R2 的功能圆未被牵连)"); + console.log(" ✓ R13–R19 双向:营销面已知违规全判红、ui/ 同名内容不误报(R2 的功能圆与三件原语未被牵连)"); // 数量维:上限处不判红 / 上限+1 判红(同 R10 的构造法)。 // 只关地板、**不覆盖上限** —— 第一版在这里塞了 hitCeilings:{[id]:9999}, // 于是两个情景都恒不判红、棘轮自证永远失败。用登记上限本身才是测那条规则。 + const HIT_FIXTURE = { + R13: "rounded-full", R14: "hover:-translate-y-1", R15: "shadow-lg", + R16: "bg-brand-soft", R17: "font-black", R18: "tile_hatching", R19: "font-extrabold", + }; const ratchetBad = []; for (const [id, ceiling] of Object.entries(MARKETING_HIT_CEILINGS)) { - const fixture = { R13: "rounded-full", R14: "hover:-translate-y-1", R15: "shadow-lg", R16: "bg-brand-soft", R17: "font-black" }[id]; + const fixture = HIT_FIXTURE[id]; const at = (n) => checkGrammar(cssText, new Map([ ["src/app/(marketing)/n.tsx", `
`], ]), "", { floor: 0 }).find((x) => x.id === id).red.length; if (at(ceiling) !== 0 || at(ceiling + 1) === 0) ratchetBad.push(`${id}@${ceiling}/${ceiling + 1}`); } if (ratchetBad.length) { - console.log(` ✗ R13–R17 棘轮不自证:${ratchetBad.join(" ")} 处「上限不判红/上限+1 判红」不成立 ⇒ 上面所有绿灯不作数`); + console.log(` ✗ R13–R19 棘轮不自证:${ratchetBad.join(" ")} 处「上限不判红/上限+1 判红」不成立 ⇒ 上面所有绿灯不作数`); return 1; } - console.log(` ✓ R13–R17 棘轮双向:按 ${Object.entries(MARKETING_HIT_CEILINGS).map(([k, v]) => `${k}=${v}`).join(" ")} 各自成立`); + console.log(` ✓ R13–R19 棘轮双向:按 ${Object.entries(MARKETING_HIT_CEILINGS).map(([k, v]) => `${k}=${v}`).join(" ")} 各自成立`); /** * R12 两侧自证:对账表必须**既能抓到漂移、又不在等值时误报**。 @@ -590,7 +629,7 @@ function main() { } const r = checkGrammar(text, files, twConfig, { jsSources }); - const unmeasurable = r.filter((x) => x.denominator === 0 && x.id !== "R7" && !/^R1[3-7]$/.test(x.id)); + const unmeasurable = r.filter((x) => x.denominator === 0 && x.id !== "R7" && !/^R1[3-9]$/.test(x.id)); const red = r.filter((x) => x.red.length > 0); console.log("视觉语法对账(Bain 2026-08-31 快照 + Porsche live 实测语法)"); diff --git a/src/app/globals.css b/src/app/globals.css index 2860843f..996bec5c 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -353,6 +353,29 @@ body { --aspect-square: 1; --aspect-tile: 1.42; + /* === 斜线纹(hatch)几何(2026-11-02 对标实测 · 逐字换算)=== + 对标原物是一个 SVG 平铺背景:`` + 一条 `M0 10h20z` 的 1px 横线, + 描边色 hsla(352,100%,42%),外层 ``。 + 这里换成一个**不依赖位图资产**的 CSS 等价形,两处换算必须逐字成立: + ① 角度:SVG 把**水平线**旋转 140°;CSS `repeating-linear-gradient(A,…)` 的线方向 + 是 `A-180`,故 A=140 时线方向 -40° ≡ 140°(直线有 180° 对称)⇒ 角度取 140deg。 + ② 间距:20×20 的方格点上、过点画 theta 角的平行线,垂距 = 20·|sin theta| + (theta=90 时垂距 20 ✓)。theta=140° ⇒ 20 × 0.6428 = **12.86px**。 + 照抄 20px 会让纹理稀掉一半 —— 这是「看起来差不多」与实际对不上的典型位。 + --hatch-color 走 --color-brand(双通道:此处是**面**,故用不随主题翻转的底色通道)。 */ + --hatch-tile: 20px; + --hatch-angle: 140deg; + --hatch-period: 12.86px; + --hatch-stroke: 1px; + --hatch-color: var(--color-brand); + /* 浅底/小面积场景的软版:品牌红 45%。对 #FFFFFF 合成后 ≈ #E3A3AF,非文字元素按 + WCAG 1.4.11 只需 3:1,实测合成色对白底 2.04:1 —— 故「软版」**只允许**做纹理, + 不得承载任何可读信息,也不得单独充当分隔线(那是 graphic-object 语义,需要 3:1)。 */ + --hatch-color-soft: rgba(196, 30, 58, 0.45); + /* 双 V 的偏移比例:实测向下双 V 垂直偏移 26/77、向右双 V 水平偏移 36/106,两档均 ≈0.34 */ + --chevron-offset-ratio: 0.34; + /* === 组件令牌层(Component Tokens)=== */ /* 按钮 */ --btn-height-sm: 2.25rem; @@ -1169,6 +1192,30 @@ html[data-theme='dark'] body { .row-span-1 { grid-row: span 1 / span 1; } .row-span-2 { grid-row: span 2 / span 2; } .row-span-3 { grid-row: span 3 / span 3; } + + /* === 签名件:斜线纹(hatch)=== + 2026-11-02 对标实测的 CSS 等价形。几何推导见 :root 里 --hatch-* 那段注释: + 角度 140deg(渐变角,线方向 −40° ≡ 140°)、垂距 12.86px(= 20 × sin140°)、描边 1px。 + + 为什么做成 class 而不是组件内联 style:这份 background-image 表达式要同时被 + HatchField 与「接缝块」两种用法消费,写在组件里就会出现第二份字面量 —— + 而 R18 正是为了「纹样只能有一个真源」而存在。 + + 面积纪律(DESIGN.md「朱砂信号」):每段 ≤ 1 处、单块 ≤ 640×520、绝不压正文。 */ + .hatch-field { + background-image: repeating-linear-gradient( + var(--hatch-angle), + transparent 0 calc(var(--hatch-period) - var(--hatch-stroke)), + var(--hatch-color) calc(var(--hatch-period) - var(--hatch-stroke)) var(--hatch-period) + ); + } + .hatch-field--soft { + background-image: repeating-linear-gradient( + var(--hatch-angle), + transparent 0 calc(var(--hatch-period) - var(--hatch-stroke)), + var(--hatch-color-soft) calc(var(--hatch-period) - var(--hatch-stroke)) var(--hatch-period) + ); + } } /* ===== 动画关键帧 ===== */ diff --git a/src/components/ui/band-spacer.tsx b/src/components/ui/band-spacer.tsx new file mode 100644 index 00000000..e0e597dc --- /dev/null +++ b/src/components/ui/band-spacer.tsx @@ -0,0 +1,17 @@ +/** + * 空白带(Band Spacer)—— 把「呼吸」变成一个可数、可比对、可被闸看见的结构件。 + * + * 实测出处:Porsche Consulting 中国站首页有**两条独立的 120px 空模块** + * (`.o-module` 高度均为 120px、内部零内容、padding 为 0),分别在编辑块之后与 + * CTA 之后。也就是说它的段距不靠「每段自带 py-24」累加,而靠一条命名过的空白。 + * + * 本仓的既有 20+ 段都自带 `py-16 md:py-24`(那是 Bootstrap 式节奏,改不动也不该改), + * 所以这里**只新增**这条带子,不去把段内 padding 归零 —— 归零会让全站段距失去定义。 + * 这条偏差记在 ADR-0009 的「已知偏差」里。 + * + * 高度走 `--spacer-band`(7.5rem = 根字号 16px 下的 120px),不写 `h-[120px]`: + * 根字号随断点取 16/17/18,字面量在桌面会变成 120px 而其他间距已按 rem 放大。 + */ +export function BandSpacer({ className }: { className?: string }) { + return