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