示例工程 55-design-system
55-design-system/app/index.html
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Aster Design System</title>
<link rel="stylesheet" href="tokens.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="app">
<header class="site-header">
<span class="brand">ASTER DS</span>
<nav aria-label="页面导航">
<a href="#buttons">按钮</a>
<a href="#cards">卡片</a>
<a href="#forms">表单</a>
<a href="#notes">约定</a>
</nav>
</header>
<main class="page">
<p class="eyebrow">DESIGN SYSTEM / 01</p>
<h1>把 token 变成组件</h1>
<p class="lead">
按钮、卡片、表单只引用 token;变体与状态写进类名,不靠页面覆盖。
</p>
<section class="panel" id="buttons">
<h2>1. 按钮</h2>
<p>三种语气、三种尺寸、五种状态。</p>
<div class="row">
<button class="c-button" type="button">主要操作</button>
<button class="c-button c-button--ghost" type="button">次要操作</button>
<button class="c-button c-button--danger" type="button">危险操作</button>
<button class="c-button c-button--sm" type="button">小号</button>
<button class="c-button" type="button" disabled>禁用</button>
</div>
<div class="row">
<button class="c-button c-button--loading" type="button" aria-busy="true">
<span class="c-button__spinner" aria-hidden="true"></span>
保存中
</button>
<button class="c-button c-button--ghost c-button--sm" type="button">小号次要</button>
</div>
</section>
<section class="panel" id="cards">
<h2>2. 卡片</h2>
<p>基础卡与 featured 变体;内容只负责填充。</p>
<div class="card-grid">
<article class="c-card">
<span class="c-badge">BASE</span>
<h3>基础卡片</h3>
<p>边框、圆角、阴影来自 token。</p>
<a class="c-link" href="#cards">查看</a>
</article>
<article class="c-card c-card--featured">
<span class="c-badge c-badge--brand">FEATURED</span>
<h3>推荐卡片</h3>
<p>featured 只改变量与强调边。</p>
<a class="c-link" href="#cards">查看</a>
</article>
</div>
</section>
<section class="panel" id="forms">
<h2>3. 表单</h2>
<p>标签、输入、提示、错误四种状态。</p>
<form class="form" novalidate>
<div class="c-field">
<label class="c-field__label" for="name">姓名</label>
<input class="c-field__input" id="name" type="text" value="林小满" />
<p class="c-field__hint">用于称呼。</p>
</div>
<div class="c-field c-field--invalid">
<label class="c-field__label" for="email">工作邮箱</label>
<input
class="c-field__input"
id="email"
type="email"
value="not-an-email"
aria-invalid="true"
aria-describedby="email-error"
/>
<p class="c-field__error" id="email-error">请输入有效的邮箱地址。</p>
</div>
<div class="c-field">
<label class="c-field__label" for="role">角色</label>
<select class="c-field__input" id="role">
<option>前端工程师</option>
<option>设计师</option>
</select>
</div>
</form>
</section>
<section class="panel" id="notes">
<h2>4. 约定</h2>
<ul class="notes">
<li>组件类以 <code>c-</code> 开头,变体用 <code>--</code>。</li>
<li>只有组件层能改组件外观;页面不要直接覆盖内部元素。</li>
<li>状态优先用原生属性,必要时加 <code>--loading</code> 等变体。</li>
<li>每个交互目标至少 44px 高。</li>
</ul>
</section>
</main>
<footer class="site-footer">
<p>Aster Design System · 2026</p>
<p>token → component</p>
</footer>
</div>
</body>
</html>