feat(tokens): 视觉语法收口到对标实测——圆角 0–4 记档、彩色阴影退役、卡片去 lift
依据是实测而非口味。Bain & Company(archive 快照 2026-08-31, 1600×846)与 Porsche Consulting(live 国际站)的 getComputedStyle 抽样收敛到同一条: **两家全站 border-radius 均为 0**,且面/字色近乎单色 (Bain 字色仅 #000/#FFF/#CC0000/#767676;Porsche 面色 #FFF/#000/#D6001D/#F2F2F2, 红出现 4 次且全部是按钮底、无一次是阴影或背景)。本仓此前的「中度软化」 3→32px 八档 + 三枚品牌红阴影 + 卡片 hover 抬升,三件全是对标没有的语法。 本轮按「借语法、不借色相」执行:保留 #C41E3A 色相与朱砂条,只收口形状与层次。 圆角 - --radius-xs/sm 3/6→0、md/lg 8/12→2、xl/2xl/3xl 18/24/32→4,新增 --radius-cta: 0 - **--radius-full 保持 9999 不动**:它承载真圆(avatar/switch/slider/radio-group/ progress/scroll-area/skeleton),一并归零会把所有旋钮与头像方角化。这条是 check:grammar R2/R9 的正向守卫 —— 刻意做成「仪器坏了它仍要失败」的那一维 - --badge-radius 由 var(--radius-full) 改指 var(--radius-cta)(实测该令牌零消费者, 留档不复用,删除动作留给死码族 DEC-P-2 统一处理) - button.tsx 的 sm/default/lg/xl 走 rounded-cta,icon 档保持 rounded-full(功能形状) 彩色阴影 - --shadow-brand / --shadow-brand-hover / --shadow-glow 三枚退役(实测前两者仅 2 处、 后者 0 处消费者),消费方回落中性档 - 同批发现并修掉一处暖化漏网:阴影基色仍是冷墨 rgba(10,14,20,α)=#0A0E14, 而暖墨 #141210 早已落地 —— globals.css 16 处 + 业务 2 处。check:token-twins 抓不到它, 因为阴影是字面量 rgba、没有 -rgb 孪生兄弟可对照 卡片 - .bain-card hover 去 translateY(-4px) 与阴影增长,改为 hairline→rule + 底色微移 - --card-shadow-hover / --card-transition 随之退役(前者仅 :hover 消费、后者零消费者) 新增信息线令牌 --color-border-rule #8A8377 hover 边框是「告诉用户这个可交互」的信息,按品牌 P4 三档拆分不能用界灰 #C3BDB1 (实测对卡底仅 1.78,不达非文本 3:1)。#8A8377 由我自己算:对白 3.75、对纸 #FBF9F5 3.57、对暗底 #141210 4.89 —— 两主题都过 3:1,且 -rgb 孪生已同步(44/44)。 动效 - 补 --transition-hover: 150ms 并接进 Tailwind duration 档。动效四原则 CONTEXT.md:76 早就写了 hover 150ms,仓库从来没有这个档(BRAND-MANUAL §6 冲突 C-1)。 抬升与光晕去掉后 hover 成了唯一的可交互提示,没档可用等于语法自相矛盾 - cta-button 的 transition-all duration-200(裸字面量)一并改为 transition-colors duration-hover CTA 两轨(实测尺寸之间取值:Bain 20/32+14px、Porsche 13/24+16px → px-7 py-3.5 + text-sm/500) - 实心/描边两轨都直角;不做 text-transform(中文无大小写)、不补字距(Bain 实测 letterSpacing: normal,它的大写感来自全大写本身) - 箭头只保留在 inline 文字链轨:两家按钮实测都是纯文字 - 描边轨静止边框用 border-border-rule,不用 ink/20(≈1.54 不达 3:1) - 改动半径实测:63 处 <CTAButton> 调用,其中 36 处不写 variant ⇒ 落默认 primary, 24 处 secondary、3 处 dark、0 处 inline 新闸 npm run check:grammar(9 条规则)+ check:grammar:selftest(9/9 双向自证) - 闸只看代码:扫描前统一剥注释。不剥的话,解释「为什么退出 rounded-full」的文档注释 本身会被判红,于是只剩两条出路 —— 改措辞去绕闸(应试,闸就此失去解释力)或把闸调瞎 - 每条规则报分母;分母为 0 ⇒ exit 2 判「未能度量」,不算通过 - 退出码分档 0/1/2,避免闸自身崩溃与判红共用 exit 1 而吞掉同批已算好的打印 顺带删死码 hero-section-v2.tsx(200 行、单一导出、全站零生产引用,仅被自己的 3 个测试 dynamic import)+ 那 3 个测试。留测试会让死码继续占覆盖率分母,并被误读成「有活在跑」。 KNOWN-RED: test:visual —— 全局令牌改动没有"爆炸半径"可言,页面级 130 张基线预期全部churn。 按计划 §10 只在 #3–#9 落地后一次性重捕(需 AUTH-VISUAL 单独授权),不按笔重写以免归因失效。 门禁实测:type-check EXIT=0 · check:grammar 9/9 · check:grammar:selftest 9/9 · check:token-twins 44/44 · check:contrast 44/44 · check:brand-token 0 违规 · check:motion 23→22(--transition-* 采集数 6→7,假红已消)· 全量 jest 143 套件 / 1769 例通过
This commit is contained in:
1 parent
d346301405
commit
81daedbea1
8 files changed
+387
-96
No files matched your search
@@ -122,7 +122,8 @@ export function PressableButton({
|
||||
}: PressableButtonProps) {
|
||||
const baseStyles = {
|
||||
primary:
|
||||
'bg-brand text-white shadow-sm hover:shadow-brand-hover',
|
||||
// hover 阴影走中性档:彩色阴影(--shadow-brand-hover)已随对标语法收口退役
|
||||
'bg-brand text-white shadow-sm hover:shadow-md',
|
||||
secondary:
|
||||
'bg-bg-elevated text-ink border border-border-primary hover:border-brand/30 hover:shadow-md',
|
||||
ghost:
|
||||
|
||||
@@ -306,30 +306,6 @@ describe('CTASection', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('HeroSectionV2', () => {
|
||||
it('should render hero heading and content', async () => {
|
||||
const { HeroSectionV2 } = await import('./hero-section-v2');
|
||||
render(<HeroSectionV2 />);
|
||||
expect(screen.getByText('企业数字化转型服务商')).toBeInTheDocument();
|
||||
expect(screen.getByText('预约咨询')).toBeInTheDocument();
|
||||
expect(screen.getByText('探索产品')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render journey steps', async () => {
|
||||
const { HeroSectionV2 } = await import('./hero-section-v2');
|
||||
render(<HeroSectionV2 />);
|
||||
// These labels appear in both CAPABILITIES and JOURNEY_STEPS, use getAllByText
|
||||
expect(screen.getAllByText('需求沟通').length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getAllByText('方案诊断').length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getAllByText('敏捷交付').length).toBeGreaterThanOrEqual(1);
|
||||
expect(screen.getAllByText('长期陪跑').length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('should provide CTA link to contact', async () => {
|
||||
const { HeroSectionV2 } = await import('./hero-section-v2');
|
||||
render(<HeroSectionV2 />);
|
||||
const links = screen.getAllByTestId('static-link');
|
||||
const contactLink = links.find(l => l.getAttribute('href') === '/contact');
|
||||
expect(contactLink).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
// HeroSectionV2 的三个用例随组件本体一同删除(2026-10-16):
|
||||
// 该组件全站零生产引用(仅被本测试文件 dynamic import),属 qa-tracker DEC-P-2 死码族。
|
||||
// 保留测试会让死码继续占用覆盖率分母,并在视觉上被误读为「有活在跑」。
|
||||
@@ -11,7 +11,7 @@ const buttonVariants = cva(
|
||||
variants: {
|
||||
variant: {
|
||||
primary:
|
||||
'bg-brand text-white shadow-sm hover:bg-brand-hover hover:shadow-brand-hover hover:-translate-y-px active:translate-y-0 active:scale-[0.97] active:shadow-sm transition-all duration-fast ease-standard',
|
||||
'bg-brand text-white shadow-sm hover:bg-brand-hover hover:shadow-md hover:-translate-y-px active:translate-y-0 active:scale-[0.97] active:shadow-sm transition-all duration-fast ease-standard',
|
||||
secondary:
|
||||
'bg-dark-bg text-white shadow-sm hover:bg-dark-bg-secondary hover:shadow-md hover:-translate-y-px active:translate-y-0 active:scale-[0.97] active:shadow-sm transition-all duration-fast ease-standard',
|
||||
outline:
|
||||
@@ -24,10 +24,13 @@ const buttonVariants = cva(
|
||||
'bg-error text-white shadow-sm hover:bg-error-hover hover:-translate-y-px active:translate-y-0 active:scale-[0.97] transition-all duration-fast ease-standard',
|
||||
},
|
||||
size: {
|
||||
sm: 'h-9 rounded-full px-3 text-xs font-medium',
|
||||
default: 'h-11 rounded-full px-5 py-2 font-medium',
|
||||
lg: 'h-12 rounded-full px-6 text-base font-semibold',
|
||||
xl: 'h-14 rounded-full px-8 text-base font-semibold',
|
||||
/** 文字按钮一律直角(rounded-cta = 0):Bain 与 Porsche 实测按钮 border-radius 均为 0。
|
||||
* icon 保持圆(rounded-full)—— 它是「功能性的圆」不是装饰圆角,与 avatar/开关钮同类,
|
||||
* check:grammar 的 R2/R9 就是为把这两类分开而写的(一并归零会方角化所有圆形控件)。 */
|
||||
sm: 'h-9 rounded-cta px-3 text-xs font-medium',
|
||||
default: 'h-11 rounded-cta px-5 py-2 font-medium',
|
||||
lg: 'h-12 rounded-cta px-6 text-base font-semibold',
|
||||
xl: 'h-14 rounded-cta px-8 text-base font-semibold',
|
||||
icon: 'h-11 w-11 rounded-full',
|
||||
},
|
||||
},
|
||||
|
||||
@@ -8,23 +8,32 @@ import { StaticLink } from '@/components/ui/static-link';
|
||||
/**
|
||||
* CTAButton — 全站统一的「行动召唤」组件
|
||||
*
|
||||
* 设计意图(见 .impeccable.md / Phase B P5):
|
||||
* - Pill 化(rounded-full),与项目 Button 组件 size 体系一致
|
||||
* - 品牌箭头签名化:内置 ArrowRight,hover 时 translate-x 形成微交互
|
||||
* - 四变体覆盖全站 CTA 场景,避免"全是大红 pill"的 UI 噪音:
|
||||
* - primary:品牌红填充 pill + 大箭头(hero 主行动 / 底部大 CTA)
|
||||
* - secondary:描边墨色 pill + 大箭头(浅色 section 次行动 / 跳转按钮)
|
||||
* - dark:描边浅色 pill + 大箭头(深色区块(bg-dark-bg)内的次行动,如 brand/team 底部 CTA)
|
||||
* - inline:透明 + 小箭头 + 文字色(卡片内"了解更多"轻量次行动)
|
||||
* 语法来源(2026-10-16 对标实测,非口味):
|
||||
* - Bain & Company(archive 2026-08-31)主 CTA 实测 = `padding: 20px 32px`、`font-size: 14px`、
|
||||
* `font-weight: 500`、`letter-spacing: normal`、**`border-radius: 0`**、1px solid #D8D8D8、
|
||||
* `text-transform: uppercase`、白底 + #CC0000 文字。**纯文字,无箭头。**
|
||||
* - Porsche Consulting(live)实心按钮实测 = `padding: 13px 24px 12px 21px`、`font-size: 16px`、
|
||||
* **`border-radius: 0`**、#D6001D 底 + 白字。**也纯文字。**
|
||||
* 它的「More Insights」是 24px 文字链轨,箭头只出现在这一轨上。
|
||||
*
|
||||
* dark 变体于 2026-08-31 P5 批次 4 新增:brand/team 底部深色 CTA 区块的次行动此前用
|
||||
* text-dark-text-primary + border-dark-border 手写描边,现统一进组件,避免深色背景上误用
|
||||
* secondary(text-ink)导致不可见。
|
||||
* - 200-300ms transition(动效四原则区间内)
|
||||
* - 主行动(primary)触达品牌红 #C41E3A 单电压,遵循"每页 ≥ 3 处品牌红触达点,面积 ≤ 10%"约束
|
||||
* 由此得本组件的四条约束:
|
||||
* 1. **两轨都直角**(`rounded-cta` = 0px)。原 `rounded-full` 胶囊是本仓自造语法,两家都没有。
|
||||
* 2. **不做 `text-transform`**:中文无大小写,uppercase 那维借不过来;也不补字距 ——
|
||||
* Bain 实测 `letterSpacing: normal`,它的大写感来自全大写本身,不是追踪。
|
||||
* 3. **箭头只在 inline(文字链轨)**:实心/描边两轨是按钮,按钮在两家都是纯文字。
|
||||
* 4. **描边轨的静止边框用 `border-border-rule`(#8A8377,对卡底实测 3.75)**,
|
||||
* 不用 `ink/20`(≈1.54,不达非文本 3:1)。hover 才提到墨档。
|
||||
*
|
||||
* 抽离自 src/app/(marketing)/home-content-v15.tsx (2026-08-31),原 primary/secondary 行为完全保留;
|
||||
* 新增 inline 变体支持次行动场景;data-testid 透传避免破坏既有测试快照。
|
||||
* 变体(四档,覆盖全站 CTA 场景,避免"全是大红实心"的噪音):
|
||||
* - primary:朱砂实心(hero 主行动 / 底部大 CTA)
|
||||
* - secondary:描边(浅色 section 次行动 / 跳转)
|
||||
* - dark:深色区块(bg-dark-bg)内的次行动 —— 2026-08-31 P5 批次 4 新增,
|
||||
* 避免深色底上误用 secondary(text-ink)导致不可见
|
||||
* - inline:透明文字链 + 小箭头(卡片内「了解更多」轻量次行动,对标 Porsche 的 More- Insights 轨)
|
||||
*
|
||||
* 用量(2026-10-16 实测,改动半径用):63 处调用 ⇒ 36 处不写 variant(落默认 primary)、
|
||||
* 24 处 secondary、3 处 dark、0 处 inline(inline 由首页 v16 的文字链轨开始使用)。
|
||||
* 机器判据:npm run check:grammar(R3 cta 档为 0 / R4 本文件零 rounded-full)。
|
||||
*/
|
||||
export type CTAButtonVariant = 'primary' | 'secondary' | 'dark' | 'inline';
|
||||
|
||||
@@ -38,22 +47,23 @@ export interface CTAButtonProps {
|
||||
innerClassName?: string;
|
||||
}
|
||||
|
||||
/** 两轨共用的尺寸档:Bain 20/32+14px 与 Porsche 13/24+16px 之间取 px-7 py-3.5 + text-sm/500 */
|
||||
const CTA_SIZE = 'px-7 py-3.5 text-sm font-medium';
|
||||
|
||||
const VARIANT_STYLES: Record<CTAButtonVariant, string> = {
|
||||
primary:
|
||||
'bg-brand text-white hover:bg-brand-hover px-10 py-4 font-semibold text-base',
|
||||
`bg-brand text-white hover:bg-brand-hover rounded-cta ${CTA_SIZE}`,
|
||||
secondary:
|
||||
'text-ink border border-ink/20 hover:border-ink/40 hover:bg-ink/5 px-10 py-4 font-semibold text-base',
|
||||
`bg-bg-primary text-text-primary border border-border-rule rounded-cta hover:border-border-dark hover:bg-bg-secondary ${CTA_SIZE}`,
|
||||
dark:
|
||||
'text-dark-text-primary border border-dark-border hover:border-dark-text-muted hover:bg-white/5 px-10 py-4 font-semibold text-base',
|
||||
`bg-transparent text-dark-text-primary border border-dark-border rounded-cta hover:border-dark-text-muted hover:bg-white/5 ${CTA_SIZE}`,
|
||||
inline:
|
||||
'text-text-primary hover:text-brand-ink px-0 py-0 font-medium text-sm bg-transparent border-0',
|
||||
};
|
||||
|
||||
const ARROW_STYLES: Record<CTAButtonVariant, string> = {
|
||||
primary: 'w-5 h-5 transition-transform duration-normal group-hover:translate-x-2',
|
||||
secondary: 'w-5 h-5 transition-transform duration-normal group-hover:translate-x-2',
|
||||
dark: 'w-5 h-5 transition-transform duration-normal group-hover:translate-x-2',
|
||||
inline: 'w-4 h-4 transition-transform duration-normal group-hover:translate-x-1',
|
||||
/** 箭头只在文字链轨出现;实心/描边两轨按实测为纯文字 */
|
||||
const ARROW_STYLES: Partial<Record<CTAButtonVariant, string>> = {
|
||||
inline: 'w-4 h-4 transition-transform duration-hover group-hover:translate-x-1',
|
||||
};
|
||||
|
||||
export function CTAButton({
|
||||
@@ -64,20 +74,19 @@ export function CTAButton({
|
||||
dataTestId,
|
||||
innerClassName,
|
||||
}: CTAButtonProps) {
|
||||
const isPill = variant !== 'inline';
|
||||
const arrow = ARROW_STYLES[variant];
|
||||
return (
|
||||
<StaticLink
|
||||
href={href}
|
||||
data-testid={dataTestId}
|
||||
className={cn(
|
||||
'group inline-flex items-center gap-3 transition-all duration-200',
|
||||
isPill ? 'rounded-full' : '',
|
||||
'group inline-flex items-center gap-3 transition-colors duration-hover',
|
||||
VARIANT_STYLES[variant],
|
||||
className
|
||||
)}
|
||||
>
|
||||
<span className={cn(innerClassName)}>{children}</span>
|
||||
<ArrowRight className={ARROW_STYLES[variant]} />
|
||||
{arrow ? <ArrowRight className={arrow} aria-hidden="true" /> : null}
|
||||
</StaticLink>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user