| name | html-design-system |
| description | Visual specification for HTML artifacts. Defines color palette, typography, spacing system, and component styles for dark-themed standalone HTML deliverables. |
HTML Design System
HTML artifact 的视觉规范。
色彩系统(深色主题基准)
| Token | Value | 用途 |
|---|
--bg | #1e1e2e | 页面背景 |
--surface | #2a2a3d | 卡片、面板背景 |
--surface-2 | #33334a | 二级表面(hover、嵌套) |
--text | #e0e0ef | 正文 |
--text-muted | #9090a8 | 次要文字、注释 |
--accent | #7aa2f7 | 主强调色(链接、按钮) |
--success | #4caf78 | 成功状态、正向数据 |
--warning | #f0a830 | 警告、中等风险 |
--danger | #e05c5c | 错误、高风险 |
--code-bg | #252535 | 代码块背景 |
--border | #3a3a52 | 分隔线、卡片边框 |
排版
- 正文:
system-ui, -apple-system, "Segoe UI", "PingFang SC", sans-serif,16px / 行高 1.6
- 代码:
"JetBrains Mono", "Fira Code", Menlo, monospace,14px / 行高 1.5
- 标题梯度:
- H1 = 2rem,weight 700
- H2 = 1.5rem,weight 600
- H3 = 1.25rem,weight 600
- H4 = 1rem,weight 600 + color
--text-muted
间距系统(4px 基准)
允许值:8px / 12px / 16px / 24px / 32px / 48px
- 卡片内边距 24px
- section 之间间距 48px
- 同级元素间距 16px
组件样式
卡片
background: var(--surface);
border: 1px solid var(--border);
border-radius: 12px;
padding: 24px;
高亮卡片(用于 TL;DR / 定义)
background: linear-gradient(135deg, rgba(122,162,247,0.15), rgba(122,162,247,0.05));
border-left: 4px solid var(--accent);
表格
- 表头:
background: var(--surface-2),font-weight: 600
- 偶数行:
background: rgba(255,255,255,0.02)
- 单元格内边距 12px 16px
代码块
- 圆角 8px,内边距 16px
<pre> 内 font-family: var(--font-mono)
- 行号灰色
var(--text-muted),正文 var(--text)
徽章 / Chip
- 圆角 6px,内边距 4px 10px,字号 12px
- 颜色按语义:success/warning/danger 各自背景透明度 0.15,文字使用对应纯色
响应式
- 默认桌面优先
@media (max-width: 768px):导航抽屉化(默认折叠,顶部汉堡按钮展开)、主区单列、字号 -1px、padding 减半
全局布局:左侧导航 + 主内容(强制)
所有 artifact 必须采用「左侧固定导航 + 右侧滚动主内容」的二栏布局,禁止使用纯单列布局。Bundle 中每个子页面同样要有该布局。
结构
<body>
<aside class="side-nav">
<header class="brand">
<h1>[Topic Title]</h1>
<p class="meta">[content_type] · [生成时间]</p>
</header>
<nav>
<ul>
<li><a href="#section-id" class="active">章节名</a></li>
</ul>
</nav>
<footer class="side-nav-footer">[可选:源信息、版本、按钮]</footer>
</aside>
<main class="content">
<section id="section-id">...</section>
</main>
</body>
CSS 基线
body {
margin: 0;
display: grid;
grid-template-columns: 280px 1fr;
min-height: 100vh;
background: var(--bg);
color: var(--text);
font-family: var(--font-sans);
}
.side-nav {
position: sticky; top: 0;
height: 100vh;
overflow-y: auto;
background: var(--surface);
border-right: 1px solid var(--border);
padding: 24px 16px;
display: flex; flex-direction: column;
}
.side-nav .brand h1 { font-size: 1.1rem; margin: 0 0 4px; }
.side-nav .brand .meta { color: var(--text-muted); font-size: 12px; margin: 0 0 24px; }
.side-nav nav ul { list-style: none; padding: 0; margin: 0; }
.side-nav nav a {
display: block; padding: 8px 12px;
color: var(--text-muted); text-decoration: none;
border-radius: 6px; font-size: 14px;
border-left: 2px solid transparent;
}
.side-nav nav a:hover { background: var(--surface-2); color: var(--text); }
.side-nav nav a.active {
color: var(--accent);
background: rgba(122,162,247,0.1);
border-left-color: var(--accent);
}
.side-nav-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--border); }
.content { padding: 48px 56px; max-width: 1100px; }
.content section { scroll-margin-top: 24px; margin-bottom: 64px; }
@media (max-width: 768px) {
body { grid-template-columns: 1fr; }
.side-nav {
position: fixed; left: 0; top: 0; bottom: 0;
width: 280px; transform: translateX(-100%);
transition: transform 0.2s; z-index: 50;
}
body.nav-open .side-nav { transform: translateX(0); }
.content { padding: 24px; }
.nav-toggle { position: fixed; top: 16px; left: 16px; z-index: 60; }
}
必备 JS(自动高亮 + 移动端切换)
const links = document.querySelectorAll('.side-nav nav a[href^="#"]');
const sections = [...links].map(a => document.querySelector(a.getAttribute('href')));
const io = new IntersectionObserver(entries => {
entries.forEach(e => {
if (e.isIntersecting) {
const id = e.target.id;
links.forEach(a => a.classList.toggle('active', a.getAttribute('href') === '#' + id));
}
});
}, { rootMargin: '-30% 0px -60% 0px' });
sections.filter(Boolean).forEach(s => io.observe(s));
document.querySelector('.nav-toggle')?.addEventListener('click', () => {
document.body.classList.toggle('nav-open');
});
Bundle 模式(ultra-plan)
- 左侧导航同时包含当前页章节锚点和Bundle 其他页面跳转两组链接,分两个区段
- 当前页用
.active,其他页链接显示文件名
泳道图 SVG 规范
泳道图 SVG 规范
- lane 列宽:固定 240px(可按 lane 数横向溢出,配合全屏查看)
- lane 列头:高 48px,背景
var(--surface-2),居中粗体标签
- lane 分隔线:1px
var(--border) 虚线
- step 矩形:宽 ~200px、高 ~48px,圆角 8px,背景
var(--accent) 透明度 0.2,边框 var(--accent)
- 跨 lane 箭头:1.5px 实线
var(--accent),箭头标记 <marker>,label 位于箭头中点上方 6px
- 垂直时间轴:左侧可选竖向轴标注
T1 T2 T3...,便于阅读
节点最少示例
<figure class="zoomable">
<button class="fs-btn">⛶</button>
<svg viewBox="0 0 720 600" xmlns="http://www.w3.org/2000/svg">
</svg>
</figure>
全屏查看
触发按钮样式
.zoomable { position: relative; }
.fs-btn {
position: absolute; top: 8px; right: 8px;
width: 32px; height: 32px;
background: var(--surface-2); color: var(--text);
border: 1px solid var(--border); border-radius: 6px;
cursor: pointer; font-size: 16px;
z-index: 2;
}
.fs-btn:hover { background: var(--accent); color: var(--bg); }
全屏激活态
body.fs-active { overflow: hidden; }
body.fs-active::after {
content: ""; position: fixed; inset: 0;
background: rgba(0,0,0,0.85); z-index: 99;
}
.fs-active-zone {
position: fixed !important; inset: 24px !important;
z-index: 100; overflow: auto;
background: var(--bg); border-radius: 12px;
padding: 32px;
box-shadow: 0 24px 48px rgba(0,0,0,0.6);
}
.fs-active-zone svg,
.fs-active-zone pre,
.fs-active-zone table { max-width: none; }
.fs-active-zone .fs-btn::before { content: "✕ "; }
适用对象
凡可能"过大"的内容必须套 .zoomable:
- 所有 SVG 图表
- 行数 > 30 的代码块
- 列数 > 6 或行数 > 12 的表格
- 含 Bundle 的导航地图