[阶段7] 前端重做:31 项指标全部露出,配色经色盲校验

原来仪表板只有 4 张卡片和 4 张图,31 项指标里绝大多数没有出口。

信息架构重组为 7 个页面(原 5 个):
- 今日   按活动 / 心率压力 / 睡眠呼吸三组展示 16 项指标
- 趋势   15 组指标可切换,5 档时间窗口(最长一年)
- 睡眠   新增。分期堆叠图 + 夜间血氧/呼吸/压力
- 成就   新增。奖励徽章按年份分组、个人纪录、运动记录
- 建议 / 同步 / 设置 保持

配色(依据 dataviz 规范,用校验器实测而非目测):
- 采用验证过的分类色板并按既定 slot 顺序取色 —— 顺序本身就是
  色盲安全机制,不是审美选择,因此只取不循环
- 浅色 worst adjacent CVD ΔE 9.1 / 常视觉 22.9
  深色 worst adjacent CVD ΔE 8.4 / 常视觉 19.8,两档全部通过
- 浅色表面下 aqua 2.74:1、yellow 2.11:1 低于 3:1,按规范提供
  "relief":每张图都带表格视图,且图例始终与文字标签同现
- 深色不是自动反色,是同色相针对深色表面重新取阶并单独校验
- 状态色(good/warning/serious/critical)保留专用,绝不当作
  第 N 个系列色;且始终图标 + 文字同现,不靠颜色单独表意

图表规范:
- 单一 y 轴,绝不双轴;量纲不同的指标拆成不同图
- 2px 线宽、4px 圆角柱端锚定基线、堆叠段间 2px 表面色间隙、
  悬停标记 2px 表面色描边
- 两系列以上必有图例,单系列不加(标题已经点明)
- 折线 connectNulls,设备漏记的日子不把线打断
- 数值文字一律用文字色令牌,不染系列色

其他:
- 主题切换(自动/浅色/深色),选择写入 localStorage 并标在 <html>
- 导航改为顶部横向,移动端可横滑
- 表格、徽章、空状态等组件统一到设计令牌

验证方式: DOM 审计确认 2px 线宽、圆角为 A 4,4 弧、堆叠段
2px 间隙、图例数量与系列数匹配、两档主题令牌各自解析到校验过的色值。

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
ericwyuan
2026-08-23 21:17:08 +08:00
parent cbbff61082
commit ad88ec7e41
20 changed files with 2131 additions and 767 deletions

View File

@@ -1,129 +1,93 @@
.layout {
display: flex;
flex-direction: column;
min-height: 100vh;
background-color: #f5f5f5;
background: var(--surface-0);
}
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 2rem;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
background: var(--surface-1);
border-bottom: 1px solid var(--border);
position: sticky;
top: 0;
z-index: 20;
}
.header-content {
max-width: 1400px;
.header-inner {
max-width: 1180px;
margin: 0 auto;
padding: 0 1.5rem;
display: flex;
align-items: center;
gap: 1.5rem;
height: 56px;
}
.logo {
font-size: 1.8rem;
font-weight: bold;
margin-bottom: 0.5rem;
font-size: 0.95rem;
font-weight: 680;
color: var(--text-primary);
text-decoration: none;
white-space: nowrap;
}
.tagline {
font-size: 0.9rem;
opacity: 0.9;
}
.container {
.nav {
display: flex;
gap: 0.15rem;
flex: 1;
max-width: 1400px;
width: 100%;
margin: 0 auto;
gap: 2rem;
padding: 2rem;
overflow-x: auto;
scrollbar-width: none;
}
.sidebar {
width: 250px;
background: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
height: fit-content;
position: sticky;
top: 2rem;
}
.nav-list {
list-style: none;
padding: 0;
}
.nav::-webkit-scrollbar { display: none; }
.nav-link {
display: flex;
align-items: center;
gap: 0.75rem;
padding: 1rem 1.5rem;
padding: 0.4rem 0.7rem;
border-radius: 7px;
color: var(--text-secondary);
text-decoration: none;
color: #333;
border-left: 3px solid transparent;
transition: all 0.3s ease;
font-size: 0.88rem;
white-space: nowrap;
transition: background 0.15s ease, color 0.15s ease;
}
.nav-link:hover {
background-color: #f5f5f5;
border-left-color: #667eea;
background: var(--surface-0);
color: var(--text-primary);
}
.nav-link.active {
background-color: #f0f0ff;
border-left-color: #667eea;
color: #667eea;
background: var(--accent-soft);
color: var(--accent);
font-weight: 600;
}
.icon {
font-size: 1.2rem;
.theme-toggle {
background: none;
border: 1px solid var(--border);
color: var(--text-secondary);
border-radius: 7px;
padding: 0.3rem 0.6rem;
font-size: 0.76rem;
cursor: pointer;
font-family: inherit;
white-space: nowrap;
}
.label {
flex: 1;
.theme-toggle:hover {
border-color: var(--border-strong);
color: var(--text-primary);
}
.content {
flex: 1;
background: white;
border-radius: 8px;
padding: 2rem;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
max-width: 1180px;
margin: 0 auto;
padding: 1.75rem 1.5rem 4rem;
}
.footer {
text-align: center;
padding: 2rem;
color: #666;
font-size: 0.9rem;
border-top: 1px solid #eee;
}
@media (max-width: 768px) {
.container {
flex-direction: column;
padding: 1rem;
}
.sidebar {
width: 100%;
position: static;
}
.nav-list {
display: flex;
gap: 0.5rem;
overflow-x: auto;
}
.nav-link {
flex: 1;
min-width: 100px;
font-size: 0.9rem;
}
.logo {
font-size: 1.4rem;
}
@media (max-width: 720px) {
.header-inner {
gap: 0.75rem;
padding: 0 0.9rem;
}
.logo { font-size: 0.85rem; }
.content { padding: 1.25rem 0.9rem 3rem; }
}