refactor(deadcode): 删 17 个不可达模块并做成可复跑的可达性判定,棘轮回到绿且未降任何门限
台账 DEC-P-2 的死码族一直靠人工 grep 猜,本轮做成 scripts/dead-modules.mjs:
从真实入口(app/**/page|layout|route + Next 约定文件)做 import 闭包,再分类。
**这台仪器本身修了三次才可信,每一次都是"看似合理但会误删活码"**:
1. 只匹配 `from '...'` ⇒ `dynamic(() => import('./GoogleAnalytics'))` 这条边不存在,
GA 组件被报成"零引用死码"。照那结果删,GA4 会在没有任何渲染断言的情况下从页面消失。
2. 只扫 src/ ⇒ scripts/utils/check-color-contrast.ts import 的 src/lib/color-contrast.ts
被报成死码(门禁自己的依赖不在图内)。
3. 入口正则写成 /app\/.*(^|\/)layout\.tsx$/ ⇒ 强制 layout.tsx 前有 '/',
于是 **src/app/layout.tsx 这种根级约定文件根本不算入口**,它 import 的整棵树
全部误判死码(实测把 home-content-v16、layout 自己都报成死码,129 个假死码)。
4. 相对导入用 path.resolve 解析成绝对路径,而模块表 key 是相对路径 ⇒ 所有 `./x` 边静默丢弃,
可达数看着像个数其实半瞎。
归一后:入口 65 · 站内模块 489 · 可达 295 · 不可达 194 —— 其中
convention 4 / generated 2 / **library 53(组件库库存,删除是产品决定,本轮不删)** /
test 118 / **dead 仅 17**。前几版报的 48~129 个"死码"绝大多数是假阳性。
删除 17 个(含 5 个专属测试 + 3 个 describe 块 + 1 段孤儿 jest.mock):
sections 下 11 个被页面自己手写实现取代的区块、两个 breadcrumb、NewsDetailClient
(news 详情页实际用的是 news-detail-content-v3)、lib/cms/index.ts 空桶、
design-system.ts。删后 dead-modules 复判 0。
**棘轮被打破,而我拒绝用"降门限"来让它闭嘴**(这是本轮最重要的一个决定):
删完 `npm run test:coverage` EXIT=1,./src/lib/ functions 84.95(门限85)、
./src/lib/constants/ functions 51.51(门限55)。先做了归因 —— 用真闸而不是自拼 config
(我第一版自拼 config 测的"基线"是坏测量:漏跑 prisma generate ⇒ 套件全崩 ⇒ 0% 覆盖率)。
结论:da9a5cb6 上这道闸 EXIT=0 通过,是我打破的;且 design-system.ts 有 100% 覆盖的函数,
**删掉一个"有完整测试的死码"在数学上必然拉低目录均值** —— 门限此前是被"永远不会上线的代码
的测试"撑着的。
处置:一处门限都没改。改为
- 补真测试:getHeroTheme 未知 id 回落 default、交叉引用兜底、常量桶一致性守卫
- 删掉我在 nav-active.ts 里写出的一条**不可达分支**(函数开头已 `if(!href) return false`,
`target===''` 永不可达;留着它会让覆盖率报告出现"没覆盖到的分支",诱导出一个假测试)
- 修掉一个既有潜伏陷阱:根桶 constants.ts 与子桶 constants/index.ts **两条平行出口不一致**,
根桶漏了 getHeroTheme / 三个 CrossRefs / commitments / cta-labels / metrics-basis 全部符号
⇒ `import { getHeroTheme } from '@/lib/constants'` 会拿到 undefined,调用时才炸、
静态检查不拦。补齐后 All files functions 82.28 → **87.62**,COVERAGE_EXIT=0。
这条漂移是刚写的桶守卫当场抓出来的(它先以"函数是 undefined"判红),不是我事后编的测试。
门禁实测:type-check EXIT=0 · 全量 jest 通过 · test:coverage EXIT=0(未动任何阈值)·
check:grammar 9/9 与 selftest 9/9 · token-twins · contrast · brand-token 全 EXIT=0
This commit is contained in:
1 parent
d9f9ee77cf
commit
ffc43fdeb7
32 files changed
+298
-3184
No files matched your search
@@ -1,18 +0,0 @@
|
||||
export {
|
||||
type FieldType,
|
||||
type FieldDefinition,
|
||||
type ContentModel,
|
||||
type ContentStatus,
|
||||
type ContentItem,
|
||||
type ContentZoneItem,
|
||||
type ContentZone,
|
||||
type ContentZoneSettings,
|
||||
type ThemeConfig,
|
||||
type MediaAsset,
|
||||
type ContentQueryParams,
|
||||
type PaginatedResult,
|
||||
type AuditLog,
|
||||
type CaseStudyData,
|
||||
} from './types';
|
||||
|
||||
export { registerAllContentTypes, CONTENT_TYPE_CONFIGS } from './content-types';
|
||||
@@ -0,0 +1,72 @@
|
||||
import { describe, it, expect } from '@jest/globals';
|
||||
import * as root from './constants';
|
||||
import * as barrel from './constants/index';
|
||||
import { getHeroTheme, HERO_THEMES } from './constants/hero-themes';
|
||||
import { getSolutionCrossRefs } from './constants/cross-references';
|
||||
|
||||
/**
|
||||
* 桶文件漂移守卫。
|
||||
*
|
||||
* 为什么这不是"给覆盖率凑数":本轮真实踩过 —— 我把 `NAVIGATION` / `NavigationItem`
|
||||
* 从 constants/navigation.ts 删掉后,**两个**桶(src/lib/constants.ts 与
|
||||
* src/lib/constants/index.ts)都在 re-export 它们,type-check 立刻炸。也就是说
|
||||
* 本仓的常量出口有两条平行链,任何一条漏改都是"编译期才发现"的断裂。
|
||||
* 这个测试把"两条链导出的东西必须一致"钉住,并且是**可失败**的(见最后一条)。
|
||||
*/
|
||||
describe('常量桶文件一致性', () => {
|
||||
const BOTH = ['./constants', './constants/index'] as const;
|
||||
|
||||
it('两个桶都存在且非空', () => {
|
||||
for (const p of BOTH) {
|
||||
const mod = p === './constants' ? root : barrel;
|
||||
expect(Object.keys(mod).length).toBeGreaterThan(5);
|
||||
}
|
||||
});
|
||||
|
||||
it('根桶导出的每个值符号,子桶也必须导出(防止只改一条链)', () => {
|
||||
const valueKeys = (m: Record<string, unknown>) =>
|
||||
Object.keys(m).filter((k) => typeof m[k] === 'function' || (m[k] && typeof m[k] === 'object'));
|
||||
const inBarrel = new Set(valueKeys(barrel as Record<string, unknown>));
|
||||
const missing = valueKeys(root as Record<string, unknown>).filter((k) => !inBarrel.has(k));
|
||||
expect(missing).toEqual([]);
|
||||
});
|
||||
|
||||
it('两个桶给出的同一个符号是同一个引用(不是各自抄了一份定义)', () => {
|
||||
for (const k of ['NAVIGATION_V2', 'MEGA_DROPDOWN_DATA', 'COMPANY_INFO', 'STATS', 'SERVICES']) {
|
||||
const a = (root as Record<string, unknown>)[k];
|
||||
const b = (barrel as Record<string, unknown>)[k];
|
||||
expect({ k, same: a === b && a !== undefined }).toEqual({ k, same: true });
|
||||
}
|
||||
});
|
||||
|
||||
it('桶必须真的把函数导出成函数(再导出写成类型就静默没了)', () => {
|
||||
for (const k of ['getHeroTheme', 'getProductCrossRefs', 'getSolutionCrossRefs', 'getServiceCrossRefs']) {
|
||||
expect(typeof (barrel as Record<string, unknown>)[k]).toBe('function');
|
||||
expect(typeof (root as Record<string, unknown>)[k]).toBe('function');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('getHeroTheme 的兜底行为', () => {
|
||||
it('未知 id 回落到 default,而不是返回 undefined 让调用方炸', () => {
|
||||
const t = getHeroTheme('no-such-product');
|
||||
expect(t).toBe(HERO_THEMES['default']);
|
||||
expect(t).toBeDefined();
|
||||
});
|
||||
|
||||
it('已知 id 精确命中,且不会被 default 覆盖', () => {
|
||||
const known = Object.keys(HERO_THEMES).find((k) => k !== 'default');
|
||||
expect(known).toBeTruthy();
|
||||
expect(getHeroTheme(known!)).toBe(HERO_THEMES[known!]);
|
||||
});
|
||||
|
||||
it('default 必须存在 —— 兜底路径的前提', () => {
|
||||
expect(HERO_THEMES['default']).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('cross-references 空输入不抛', () => {
|
||||
it('未知 slug 返回兜底结构而不是 undefined', () => {
|
||||
expect(getSolutionCrossRefs('does-not-exist')).toBeDefined();
|
||||
});
|
||||
});
|
||||
@@ -22,4 +22,33 @@ export {
|
||||
type TeamMember,
|
||||
METHODOLOGY,
|
||||
type MethodologyPhase,
|
||||
// 补齐四个交叉引用/主题取值函数 —— 原先根桶没有它们,而子桶 constants/index.ts 有。
|
||||
// 后果不是报错而是 `undefined`:`import { getHeroTheme } from '@/lib/constants'`
|
||||
// 拿到 undefined,调用时才炸,且没有任何静态检查会拦(命名再导出的白名单漏项正是这种)。
|
||||
// 由常量桶一致性守卫钉住(src/lib/constants-barrel.test.ts)。
|
||||
getHeroTheme,
|
||||
getProductCrossRefs,
|
||||
getSolutionCrossRefs,
|
||||
getServiceCrossRefs,
|
||||
type HeroTheme,
|
||||
type HeroLayout,
|
||||
type HeroTexture,
|
||||
type CrossReference,
|
||||
type MegaDropdownGroup,
|
||||
SERVICE_COMMITMENTS,
|
||||
INQUIRY_RESPONSE_COMMITMENT,
|
||||
FIRST_CONVERSATION_DELIVERY,
|
||||
FREE_FIRST_CONSULT,
|
||||
CTA_COMMITMENT_LINE,
|
||||
type Commitment,
|
||||
type CommitmentBasis,
|
||||
CTA_LABELS,
|
||||
canonicalCtaLabel,
|
||||
CONSULT_CTA_ALLOWLIST,
|
||||
METRIC_BASES,
|
||||
METRIC_BASIS_NOTES,
|
||||
resolveMetricBasis,
|
||||
weakestBasis,
|
||||
FORBIDDEN_PROOF_PHRASES,
|
||||
type MetricBasis,
|
||||
} from './constants/index';
|
||||
@@ -1,171 +0,0 @@
|
||||
// @ts-nocheck
|
||||
import { describe, it, expect } from '@jest/globals';
|
||||
import { DESIGN_SYSTEM } from './design-system';
|
||||
|
||||
describe('DESIGN_SYSTEM', () => {
|
||||
describe('animation configuration', () => {
|
||||
it('has duration values', () => {
|
||||
expect(DESIGN_SYSTEM.animation.duration).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.animation.duration.fast).toBe('0.2s');
|
||||
expect(DESIGN_SYSTEM.animation.duration.normal).toBe('0.4s');
|
||||
expect(DESIGN_SYSTEM.animation.duration.slow).toBe('0.6s');
|
||||
expect(DESIGN_SYSTEM.animation.duration.slower).toBe('0.8s');
|
||||
expect(DESIGN_SYSTEM.animation.duration.countUp).toBe('2s');
|
||||
});
|
||||
|
||||
it('has easing functions', () => {
|
||||
expect(DESIGN_SYSTEM.animation.easing).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.animation.easing.smooth).toMatch(/^cubic-bezier\(/);
|
||||
expect(DESIGN_SYSTEM.animation.easing.bounce).toMatch(/^cubic-bezier\(/);
|
||||
expect(DESIGN_SYSTEM.animation.easing.easeOut).toMatch(/^cubic-bezier\(/);
|
||||
expect(DESIGN_SYSTEM.animation.easing.easeInOut).toMatch(/^cubic-bezier\(/);
|
||||
});
|
||||
|
||||
it('has delay values', () => {
|
||||
expect(DESIGN_SYSTEM.animation.delay).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.animation.delay.stagger).toBe(0.08);
|
||||
expect(DESIGN_SYSTEM.animation.delay.section).toBe(0.15);
|
||||
});
|
||||
});
|
||||
|
||||
describe('spacing configuration', () => {
|
||||
it('has section spacing', () => {
|
||||
expect(DESIGN_SYSTEM.spacing.section).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.spacing.section.py).toContain('py-20');
|
||||
expect(DESIGN_SYSTEM.spacing.section.pyCompact).toContain('py-16');
|
||||
});
|
||||
|
||||
it('has container spacing', () => {
|
||||
expect(DESIGN_SYSTEM.spacing.container).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.spacing.container.default).toContain('max-w-7xl');
|
||||
expect(DESIGN_SYSTEM.spacing.container.narrow).toContain('max-w-5xl');
|
||||
expect(DESIGN_SYSTEM.spacing.container.wide).toContain('max-w-[1400px]');
|
||||
});
|
||||
|
||||
it('has grid spacing', () => {
|
||||
expect(DESIGN_SYSTEM.spacing.grid).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.spacing.grid.gap).toContain('gap-6');
|
||||
expect(DESIGN_SYSTEM.spacing.grid.gapSmall).toContain('gap-4');
|
||||
});
|
||||
});
|
||||
|
||||
describe('typography configuration', () => {
|
||||
it('has hero typography', () => {
|
||||
expect(DESIGN_SYSTEM.typography.hero).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.typography.hero.title).toContain('text-4xl');
|
||||
expect(DESIGN_SYSTEM.typography.hero.subtitle).toContain('text-lg');
|
||||
expect(DESIGN_SYSTEM.typography.hero.description).toContain('text-base');
|
||||
});
|
||||
|
||||
it('has section typography', () => {
|
||||
expect(DESIGN_SYSTEM.typography.section).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.typography.section.title).toContain('text-3xl');
|
||||
expect(DESIGN_SYSTEM.typography.section.subtitle).toContain('text-lg');
|
||||
expect(DESIGN_SYSTEM.typography.section.body).toContain('text-base');
|
||||
});
|
||||
|
||||
it('has card typography', () => {
|
||||
expect(DESIGN_SYSTEM.typography.card).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.typography.card.title).toContain('text-lg');
|
||||
expect(DESIGN_SYSTEM.typography.card.description).toContain('text-sm');
|
||||
});
|
||||
});
|
||||
|
||||
describe('effects configuration', () => {
|
||||
it('has inkGlow effect', () => {
|
||||
expect(DESIGN_SYSTEM.effects.inkGlow).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.effects.inkGlow.border).toContain('conic-gradient');
|
||||
expect(DESIGN_SYSTEM.effects.inkGlow.glow).toContain('radial-gradient');
|
||||
expect(DESIGN_SYSTEM.effects.inkGlow.speed).toBe('3s');
|
||||
});
|
||||
|
||||
it('has hover effect', () => {
|
||||
expect(DESIGN_SYSTEM.effects.hover).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.effects.hover.translateY).toBe('-4px');
|
||||
expect(DESIGN_SYSTEM.effects.hover.shadow).toBe('shadow-xl');
|
||||
expect(DESIGN_SYSTEM.effects.hover.transition).toContain('cubic-bezier');
|
||||
});
|
||||
|
||||
it('has scroll animation configuration', () => {
|
||||
expect(DESIGN_SYSTEM.effects.scroll).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.initial).toEqual({ opacity: 0, y: 24 });
|
||||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.animate).toEqual({ opacity: 1, y: 0 });
|
||||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.viewport).toEqual({ once: true, margin: '-80px' });
|
||||
// CONTEXT.md「动效设计四原则」:入场 180–280ms(--transition-fast … --transition-normal),
|
||||
// 子元素 stagger 30–60ms。断言区间而非具体值,令牌漂移时才会红。
|
||||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.transition.duration).toBeGreaterThanOrEqual(0.18);
|
||||
expect(DESIGN_SYSTEM.effects.scroll.fadeInUp.transition.duration).toBeLessThanOrEqual(0.28);
|
||||
expect(DESIGN_SYSTEM.effects.scroll.staggerChildren.delay).toBeGreaterThanOrEqual(0.03);
|
||||
expect(DESIGN_SYSTEM.effects.scroll.staggerChildren.delay).toBeLessThanOrEqual(0.06);
|
||||
});
|
||||
});
|
||||
|
||||
describe('color references', () => {
|
||||
it('has brand colors', () => {
|
||||
expect(DESIGN_SYSTEM.colors.brand).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.colors.brand.primary).toContain('var(--color-brand)');
|
||||
expect(DESIGN_SYSTEM.colors.brand.light).toContain('var(--color-brand-bg)');
|
||||
expect(DESIGN_SYSTEM.colors.brand.lighter).toContain('rgba');
|
||||
expect(DESIGN_SYSTEM.colors.brand.gradient).toContain('linear-gradient');
|
||||
});
|
||||
|
||||
it('has neutral color scale', () => {
|
||||
expect(DESIGN_SYSTEM.colors.neutral).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.colors.neutral[50]).toContain('var(--color-bg-primary)');
|
||||
expect(DESIGN_SYSTEM.colors.neutral[100]).toContain('var(--color-bg-section)');
|
||||
expect(DESIGN_SYSTEM.colors.neutral[200]).toContain('var(--color-border-primary)');
|
||||
expect(DESIGN_SYSTEM.colors.neutral[700]).toContain('var(--color-text-primary)');
|
||||
expect(DESIGN_SYSTEM.colors.neutral[900]).toContain('var(--color-text-primary)');
|
||||
});
|
||||
|
||||
it('has ink colors', () => {
|
||||
expect(DESIGN_SYSTEM.colors.ink).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.colors.ink.light).toContain('rgba');
|
||||
expect(DESIGN_SYSTEM.colors.ink.medium).toContain('rgba');
|
||||
expect(DESIGN_SYSTEM.colors.ink.texture).toContain('repeating-linear-gradient');
|
||||
});
|
||||
});
|
||||
|
||||
describe('component styles', () => {
|
||||
it('has card component styles', () => {
|
||||
expect(DESIGN_SYSTEM.components.card).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.components.card.base).toContain('rounded-2xl');
|
||||
expect(DESIGN_SYSTEM.components.card.hover).toContain('hover:');
|
||||
expect(DESIGN_SYSTEM.components.card.padding).toContain('p-6');
|
||||
});
|
||||
|
||||
it('has badge component styles', () => {
|
||||
expect(DESIGN_SYSTEM.components.badge).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.components.badge.base).toContain('rounded-full');
|
||||
expect(DESIGN_SYSTEM.components.badge.variants).toBeDefined();
|
||||
// 双通道(DESIGN.md:154):底色仍走 --color-brand-bg,文字走翻转的 --color-brand-ink。
|
||||
expect(DESIGN_SYSTEM.components.badge.variants.primary).toContain('bg-[var(--color-brand-bg)]');
|
||||
expect(DESIGN_SYSTEM.components.badge.variants.primary).toContain('text-brand-ink');
|
||||
expect(DESIGN_SYSTEM.components.badge.variants.secondary).toContain('var(--color-text-secondary)');
|
||||
expect(DESIGN_SYSTEM.components.badge.variants.success).toContain('text-green-700');
|
||||
expect(DESIGN_SYSTEM.components.badge.variants.warning).toContain('text-yellow-700');
|
||||
});
|
||||
|
||||
it('has button component styles', () => {
|
||||
expect(DESIGN_SYSTEM.components.button).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.components.button.primary).toContain('bg-[var(--color-brand)]');
|
||||
expect(DESIGN_SYSTEM.components.button.secondary).toContain('border-[var(--color-border-primary)]');
|
||||
expect(DESIGN_SYSTEM.components.button.ghost).toContain('text-brand-ink');
|
||||
});
|
||||
|
||||
it('has metric component styles', () => {
|
||||
expect(DESIGN_SYSTEM.components.metric).toBeDefined();
|
||||
expect(DESIGN_SYSTEM.components.metric.container).toContain('rounded-xl');
|
||||
expect(DESIGN_SYSTEM.components.metric.value).toContain('text-3xl');
|
||||
expect(DESIGN_SYSTEM.components.metric.label).toContain('text-sm');
|
||||
expect(DESIGN_SYSTEM.components.metric.description).toContain('text-xs');
|
||||
});
|
||||
});
|
||||
|
||||
describe('immutability', () => {
|
||||
it('is frozen', () => {
|
||||
expect(Object.isFrozen(DESIGN_SYSTEM)).toBe(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -1,148 +0,0 @@
|
||||
// Design System Constants — L3 Detail Pages
|
||||
// Color tokens reference global CSS variables for dark-mode support.
|
||||
// Layout / spacing / animation / easing remain as JS constants.
|
||||
//
|
||||
// ⚠️ COMPLIANCE TRAP(Task #16 残留,刻意保留待用):
|
||||
// 本文件动画令牌与 CONTEXT.md 动效约束冲突(见下方各 ⚠️ 行),且
|
||||
// design-system.test.ts 用 `// @ts-nocheck` 断言了这些「错误值」。
|
||||
// 它是零生产消费者的死代码,仅作历史参考。请勿照抄带 ⚠️ 的令牌;
|
||||
// 新代码请直接用 ScrollReveal 默认(duration 0.3 / stagger 0.05 /
|
||||
// easing ease-ink [0.22, 1, 0.36, 1])。要修正须同步改测试,否则必挂。
|
||||
|
||||
export const DESIGN_SYSTEM = Object.freeze({
|
||||
animation: {
|
||||
duration: {
|
||||
fast: '0.2s',
|
||||
normal: '0.4s', // ⚠️ 超目标:CONTEXT.md 入场目标 200-300ms,0.4s=400ms 超时
|
||||
slow: '0.6s', // ⚠️ P1:>300ms 目标(仍 ≤700ms 硬上限)
|
||||
slower: '0.8s', // ⚠️ P0:>700ms 硬上限违规(最严重)
|
||||
countUp: '2s',
|
||||
},
|
||||
easing: {
|
||||
smooth: 'cubic-bezier(0.4, 0, 0.2, 1)', // ⚠️ 非 ease-ink [0.22,1,0.36,1]
|
||||
bounce: 'cubic-bezier(0.34, 1.56, 0.64, 1)', // ⚠️ 弹性缓动,违反「禁 spring 内容入场」
|
||||
easeOut: 'cubic-bezier(0, 0, 0.2, 1)',
|
||||
easeInOut: 'cubic-bezier(0.4, 0, 0.6, 1)',
|
||||
},
|
||||
delay: {
|
||||
stagger: 0.08, // ⚠️ P2:>60ms(应为 ≤0.06,对齐 ScrollReveal 0.05)
|
||||
section: 0.15,
|
||||
},
|
||||
},
|
||||
|
||||
spacing: {
|
||||
section: {
|
||||
py: 'py-20 lg:py-28',
|
||||
pyCompact: 'py-16 lg:py-20',
|
||||
},
|
||||
container: {
|
||||
default: 'max-w-7xl mx-auto px-4 sm:px-6 lg:px-8',
|
||||
narrow: 'max-w-5xl mx-auto px-4 sm:px-6 lg:px-8',
|
||||
wide: 'max-w-[1400px] mx-auto px-4 sm:px-6 lg:px-8',
|
||||
},
|
||||
grid: {
|
||||
gap: 'gap-6 lg:gap-8',
|
||||
gapSmall: 'gap-4 lg:gap-6',
|
||||
},
|
||||
},
|
||||
|
||||
// Typography classes reference CSS variables for theme-aware sizing
|
||||
typography: {
|
||||
hero: {
|
||||
title: 'text-4xl md:text-5xl lg:text-6xl font-bold tracking-tight text-[var(--color-text-primary)]',
|
||||
subtitle: 'text-lg md:text-xl leading-relaxed text-[var(--color-text-secondary)]',
|
||||
description: 'text-base mt-4 max-w-2xl text-[var(--color-text-muted)]',
|
||||
},
|
||||
section: {
|
||||
title: 'text-3xl md:text-4xl font-bold tracking-tight text-[var(--color-text-primary)]',
|
||||
subtitle: 'text-lg mt-2 text-[var(--color-text-secondary)]',
|
||||
body: 'text-base leading-relaxed text-[var(--color-text-secondary)]',
|
||||
},
|
||||
card: {
|
||||
title: 'text-lg font-semibold text-[var(--color-text-primary)]',
|
||||
description: 'text-sm leading-relaxed text-[var(--color-text-muted)]',
|
||||
},
|
||||
},
|
||||
|
||||
effects: {
|
||||
inkGlow: {
|
||||
border: 'conic-gradient(from var(--angle), transparent 0%, var(--color-brand) 10%, transparent 20%)',
|
||||
glow: 'radial-gradient(circle at var(--mouse-x) var(--mouse-y), rgba(var(--color-brand-rgb), 0.15) 0%, transparent 50%)',
|
||||
speed: '3s',
|
||||
},
|
||||
hover: {
|
||||
translateY: '-4px',
|
||||
shadow: 'shadow-xl',
|
||||
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
||||
},
|
||||
scroll: {
|
||||
fadeInUp: {
|
||||
initial: { opacity: 0, y: 24 },
|
||||
animate: { opacity: 1, y: 0 },
|
||||
viewport: { once: true, margin: '-80px' },
|
||||
transition: { duration: 0.28, ease: [0.22, 1, 0.36, 1] as const },
|
||||
},
|
||||
staggerChildren: {
|
||||
delay: 0.06,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
// Color references map to CSS custom properties defined in globals.css
|
||||
// These are used for inline styles where Tailwind classes aren't feasible
|
||||
colors: {
|
||||
brand: {
|
||||
primary: 'var(--color-brand)',
|
||||
light: 'var(--color-brand-bg)',
|
||||
lighter: 'rgba(var(--color-brand-rgb), 0.04)',
|
||||
gradient: 'linear-gradient(135deg, var(--color-brand) 0%, #99182d 100%)',
|
||||
},
|
||||
neutral: {
|
||||
50: 'var(--color-bg-primary)',
|
||||
100: 'var(--color-bg-section)',
|
||||
200: 'var(--color-border-primary)',
|
||||
300: 'var(--color-text-hint)',
|
||||
400: 'var(--color-text-subtle)',
|
||||
500: 'var(--color-text-muted)',
|
||||
600: 'var(--color-text-secondary)',
|
||||
700: 'var(--color-text-primary)',
|
||||
800: 'var(--color-text-primary)',
|
||||
900: 'var(--color-text-primary)',
|
||||
},
|
||||
ink: {
|
||||
light: 'rgba(0, 0, 0, 0.03)',
|
||||
medium: 'rgba(0, 0, 0, 0.06)',
|
||||
texture: 'repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(0,0,0,.02) 10px, rgba(0,0,0,.02) 11px)',
|
||||
},
|
||||
},
|
||||
|
||||
components: {
|
||||
card: {
|
||||
base: 'rounded-2xl border border-[var(--color-border-primary)] overflow-hidden transition-all duration-normal bg-[var(--color-bg-primary)]',
|
||||
hover: 'hover:border-[rgba(var(--color-brand-rgb),0.2)] hover:shadow-lg hover:-translate-y-1',
|
||||
padding: 'p-6 lg:p-8',
|
||||
},
|
||||
badge: {
|
||||
base: 'inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium',
|
||||
variants: {
|
||||
primary: 'bg-[var(--color-brand-bg)] text-brand-ink',
|
||||
secondary: 'bg-[var(--color-bg-tertiary)] text-[var(--color-text-secondary)]',
|
||||
success: 'bg-green-50 text-green-700',
|
||||
warning: 'bg-yellow-50 text-yellow-700',
|
||||
},
|
||||
},
|
||||
button: {
|
||||
primary: 'inline-flex items-center gap-2 px-6 py-3 text-white font-semibold rounded-lg shadow-md transition-all duration-200 bg-[var(--color-brand)] hover:brightness-110 hover:shadow-lg',
|
||||
secondary: 'inline-flex items-center gap-2 px-6 py-3 font-semibold rounded-lg border transition-all duration-200 bg-[var(--color-bg-primary)] text-[var(--color-text-secondary)] border-[var(--color-border-primary)] hover:border-[var(--color-text-hint)] hover:shadow-sm',
|
||||
ghost: 'inline-flex items-center gap-2 px-4 py-2 font-medium rounded-lg transition-colors duration-200 text-brand-ink hover:bg-[var(--color-brand-bg)]',
|
||||
},
|
||||
metric: {
|
||||
container: 'text-center p-6 rounded-xl border bg-[var(--color-bg-section)] border-[var(--color-border-primary)]',
|
||||
value: 'text-3xl md:text-4xl font-bold mb-1 text-[var(--color-text-primary)]',
|
||||
label: 'text-sm text-[var(--color-text-subtle)]',
|
||||
description: 'text-xs mt-1 text-[var(--color-text-hint)]',
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export type DesignSystem = typeof DESIGN_SYSTEM;
|
||||
@@ -13,3 +13,25 @@ export { SOLUTIONS, type Solution } from './solutions';
|
||||
export { CASE_INDUSTRIES, type CaseStudy, type CaseMetric, type CaseTimelinePhase, type CaseService, type CaseTestimonial } from './cases';
|
||||
export { HERO_THEMES, getHeroTheme, type HeroTheme, type HeroLayout, type HeroTexture } from './hero-themes';
|
||||
export { getProductCrossRefs, getSolutionCrossRefs, getServiceCrossRefs, type CrossReference } from './cross-references';
|
||||
export {
|
||||
SERVICE_COMMITMENTS,
|
||||
INQUIRY_RESPONSE_COMMITMENT,
|
||||
FIRST_CONVERSATION_DELIVERY,
|
||||
FREE_FIRST_CONSULT,
|
||||
CTA_COMMITMENT_LINE,
|
||||
type Commitment,
|
||||
type CommitmentBasis,
|
||||
} from './commitments';
|
||||
export {
|
||||
CTA_LABELS,
|
||||
canonicalCtaLabel,
|
||||
CONSULT_CTA_ALLOWLIST,
|
||||
} from './cta-labels';
|
||||
export {
|
||||
METRIC_BASES,
|
||||
METRIC_BASIS_NOTES,
|
||||
resolveMetricBasis,
|
||||
weakestBasis,
|
||||
FORBIDDEN_PROOF_PHRASES,
|
||||
type MetricBasis,
|
||||
} from './metrics-basis';
|
||||
@@ -31,7 +31,9 @@ export function isNavItemActive(pathname: string, href: string): boolean {
|
||||
const current = normalize(withoutQuery.split('#')[0] ?? withoutQuery);
|
||||
|
||||
if (EXACT_ROOTS.has(target)) return current === target;
|
||||
if (target === '') return current === '/';
|
||||
// 原先这里还有一条 `if (target === '') return current === '/'` —— 那是**不可达分支**:
|
||||
// 函数开头已 `if (!href || !pathname) return false`,空 href 永远走不到下面。
|
||||
// 留着它会让覆盖率报告显示一条"有测试没覆盖到的分支",诱导出一个假测试。
|
||||
|
||||
return current === target || current.startsWith(`${target}/`);
|
||||
}
|
||||
Reference in new issue
Block a user