diff --git a/apps/tutorial/design-typography.html b/apps/tutorial/design-typography.html new file mode 100644 index 0000000..5a18d7e --- /dev/null +++ b/apps/tutorial/design-typography.html @@ -0,0 +1,12 @@ + + + + + + 设计系统 · 字体 · 一套字阶,两种强调 + + +
+ + + diff --git a/apps/tutorial/src/lib/ui.tsx b/apps/tutorial/src/lib/ui.tsx index 9e22572..cc3cc41 100644 --- a/apps/tutorial/src/lib/ui.tsx +++ b/apps/tutorial/src/lib/ui.tsx @@ -6,10 +6,11 @@ import { CHAPTERS } from './chapters' import '../styles/tokens.css' /** 设计系统四册(自 design-lab 迁入) */ -export type DesignKey = 'design-colors' | 'design-symbols' | 'design-components' | 'design-examples' +export type DesignKey = 'design-colors' | 'design-typography' | 'design-symbols' | 'design-components' | 'design-examples' const DESIGN: { href: string; label: string; key: DesignKey }[] = [ { href: '/design-colors.html', label: '颜色', key: 'design-colors' }, + { href: '/design-typography.html', label: '字体', key: 'design-typography' }, { href: '/design-symbols.html', label: '符号形状', key: 'design-symbols' }, { href: '/design-components.html', label: '组件', key: 'design-components' }, { href: '/design-examples.html', label: '样例', key: 'design-examples' }, diff --git a/apps/tutorial/src/pages/design-typography/App.tsx b/apps/tutorial/src/pages/design-typography/App.tsx new file mode 100644 index 0000000..3f2bc16 --- /dev/null +++ b/apps/tutorial/src/pages/design-typography/App.tsx @@ -0,0 +1,61 @@ +/** 设计系统 · 字体册——字阶与两种强调。 + * 全部样式直接用 tokens.css 的字体系统(所见即 token)。 */ +import { Page, Section } from '../../lib/ui' + +/* 字阶:名称 / token / 规格 / 用途 / 活样 */ +const SCALE = [ + { n: '正文 content', token: 'text-content', spec: '16px / 1.75(浏览器默认)', use: '全站基准——步骤与认知基础正文', sample: 把 16px 当正文,浏览器默认字号即设计基准。, cls: '' }, + { n: '三级标题 t3', token: 'text-t3', spec: '18px / 1.5', use: '步骤标题、积木名', sample: 组件是界面拼接的最小单位, cls: '' }, + { n: '二级标题 t2', token: 'text-t2', spec: '22px / 1.45', use: '次级标题(区块级,预留)', sample: 用组件拼出可增删的 todo, cls: '' }, + { n: '一级标题 t1', token: 'text-t1', spec: '28px / 1.3', use: '页面主标题、章头', sample: 第 1 章 · 快速开始, cls: '' }, + { n: '辅助 small', token: 'text-small', spec: '12px / 1.65', use: '卡片内辅助正文(积木三句话)', sample: 静态文件服务:把目录里的文件原样返回的那层服务。, cls: '' }, + { n: '小字 · 边缘可忽略', token: 't-small-mute', spec: '12px 灰', use: '注记、页脚——看不清也无妨', sample: 散落只在卡片附近空当,密度 ≤ 8/屏, cls: 't-small-mute' }, + { n: '小字 · 缩小但加强', token: 't-small-strong', spec: '12px 加粗 + 字距', use: 'Section 标签、靶子三行、验收标签', sample: ▲ 目标:让第一个网页跑起来, cls: 't-small-strong' }, + { n: '大字 · 大而弱', token: 't-display', spec: '64px @ ink 10%', use: '章头幽灵章号——存在但不抢戏', sample: 05, cls: 't-display' }, +] + +const RULES = [ + { n: '同尺寸,两种强调', why: '小字要么「边缘可忽略」(灰、常规),要么「缩小但加强」(加粗、收字距)——没有中间态;大字同理:t1 大而强是主标题,display 大而弱是背景字。强调是二选一,不是渐变。' }, + { n: '正文不小于 16', why: '16px=浏览器默认=正文字号。比它小的只允许承载「丢了也不影响理解」的内容(mute)或「标签式短语」(strong);成段阅读的内容永远 ≥16。' }, + { n: '标题只用 t1–t3', why: '三级标题覆盖页面→区块→条目。不自造字号:新层级先问「能不能并进现有三级」,多数时候是内容该拆,不是字号该加。' }, +] + +export function App() { + return ( + +
+
+ {SCALE.map((s) => ( +
+
+
{s.n}
+
{s.token}
+
+
+ {s.sample} +
+
{s.spec} · {s.use}
+
+ ))} +
+
+
+
+ {RULES.map((r, i) => ( +
+
+ {i + 1} + {r.n} +
+

{r.why}

+
+ ))} +
+
+
+ ) +} diff --git a/apps/tutorial/src/pages/design-typography/main.tsx b/apps/tutorial/src/pages/design-typography/main.tsx new file mode 100644 index 0000000..a3fd25e --- /dev/null +++ b/apps/tutorial/src/pages/design-typography/main.tsx @@ -0,0 +1,4 @@ +import { createRoot } from 'react-dom/client' +import { App } from './App' + +createRoot(document.getElementById('root')!).render()