[阶段10] 前端以 Framework7 重建,采用 iOS 原生形态
按要求废弃手写外壳,改用 Framework7 React(theme=ios)。参照 PeakWatch 的信息架构与卡片语言。 保留(这些是资产,不该重来): - 数据层 services/api.ts、聚合 lib/aggregate.ts、参考区间 lib/ranges.ts - 图表组件 Chart / Ring / Sparkline / BandBar / MetricCard / MetricStrip - 经校验的配色令牌(色盲安全 + 对比度,浅深两档) 替换: - 路由与外壳交给 F7:五个 Tab 各自独立导航栈,推入详情页不影响其他 Tab - 页面转场、橡皮筋滚动、大标题折叠、半透明栏 —— 这些正是换框架的理由, 手写做不像 - 底部标签栏改用 F7 Toolbar,触控目标与安全区由框架处理 配色接入: - 新增 f7theme.css 把我们的令牌映射到 F7 的 CSS 变量,让它的导航栏/ 列表/面板与我们的图表同属一套设计,而不是两种视觉打架 - F7 的深色靠 .dark 类,我们的靠 data-theme,两者在 App 里同步切换 fix: 图标显示为原始名称(squ/hea/cale…) - iconIos/iconMd 引用的是 framework7-icons 字体,没装就只会渲染出名字 其他: - tsconfig moduleResolution 改为 bundler —— F7 用 exports 映射, node 解析方式找不到它的类型 - 登录页不套 Tab 外壳,未登录时不该出现导航 桌面与手机都要好看:内容在宽屏收进 1100px 居中列并加密卡片列数, 窄屏走底部标签栏;两档都已实机核对。 bundle 190KB -> 399KB,是换取原生手感的代价。 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,93 +0,0 @@
|
||||
.layout {
|
||||
min-height: 100vh;
|
||||
background: var(--surface-0);
|
||||
}
|
||||
|
||||
.header {
|
||||
background: var(--surface-1);
|
||||
border-bottom: 1px solid var(--border);
|
||||
position: sticky;
|
||||
top: 0;
|
||||
z-index: 20;
|
||||
}
|
||||
|
||||
.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: 0.95rem;
|
||||
font-weight: 680;
|
||||
color: var(--text-primary);
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.nav {
|
||||
display: flex;
|
||||
gap: 0.15rem;
|
||||
flex: 1;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
|
||||
.nav::-webkit-scrollbar { display: none; }
|
||||
|
||||
.nav-link {
|
||||
padding: 0.4rem 0.7rem;
|
||||
border-radius: 7px;
|
||||
color: var(--text-secondary);
|
||||
text-decoration: none;
|
||||
font-size: 0.88rem;
|
||||
white-space: nowrap;
|
||||
transition: background 0.15s ease, color 0.15s ease;
|
||||
}
|
||||
|
||||
.nav-link:hover {
|
||||
background: var(--surface-0);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.nav-link.active {
|
||||
background: var(--accent-soft);
|
||||
color: var(--accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
||||
.theme-toggle:hover {
|
||||
border-color: var(--border-strong);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.content {
|
||||
max-width: 1180px;
|
||||
margin: 0 auto;
|
||||
padding: 1.75rem 1.5rem 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; }
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Link, useLocation } from 'react-router-dom';
|
||||
import { FEATURES } from '../features';
|
||||
import './Layout.css';
|
||||
|
||||
interface LayoutProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
const NAV = [
|
||||
{ path: '/', label: '今日' },
|
||||
{ path: '/daily', label: '每日数据' },
|
||||
{ path: '/trends', label: '趋势' },
|
||||
{ path: '/sleep', label: '睡眠' },
|
||||
{ path: '/achievements', label: '成就' },
|
||||
...(FEATURES.ai ? [{ path: '/recommendations', label: '建议' }] : []),
|
||||
{ path: '/sync', label: '同步' },
|
||||
{ path: '/settings', label: '设置' },
|
||||
];
|
||||
|
||||
type Theme = 'light' | 'dark' | 'system';
|
||||
|
||||
/* Dark mode is a deliberate, validated palette rather than an inverted one, so
|
||||
the choice is stamped on <html> and the tokens swap in one place. */
|
||||
function useTheme(): [Theme, (t: Theme) => void] {
|
||||
const [theme, setTheme] = useState<Theme>(
|
||||
() => (localStorage.getItem('ghl_theme') as Theme) || 'system'
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
const root = document.documentElement;
|
||||
if (theme === 'system') root.removeAttribute('data-theme');
|
||||
else root.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('ghl_theme', theme);
|
||||
}, [theme]);
|
||||
|
||||
return [theme, setTheme];
|
||||
}
|
||||
|
||||
function Layout({ children }: LayoutProps) {
|
||||
const location = useLocation();
|
||||
const [theme, setTheme] = useTheme();
|
||||
|
||||
const cycle = () =>
|
||||
setTheme(theme === 'system' ? 'light' : theme === 'light' ? 'dark' : 'system');
|
||||
|
||||
const themeLabel = { system: '跟随系统', light: '浅色', dark: '深色' }[theme];
|
||||
|
||||
return (
|
||||
<div className="layout">
|
||||
<header className="header">
|
||||
<div className="header-inner">
|
||||
<Link to="/" className="logo">Garmin Health Lab</Link>
|
||||
|
||||
<nav className="nav" aria-label="主导航">
|
||||
{NAV.map((item) => {
|
||||
const active =
|
||||
item.path === '/'
|
||||
? location.pathname === '/'
|
||||
: location.pathname.startsWith(item.path);
|
||||
return (
|
||||
<Link
|
||||
key={item.path}
|
||||
to={item.path}
|
||||
className={`nav-link ${active ? 'active' : ''}`}
|
||||
aria-current={active ? 'page' : undefined}
|
||||
>
|
||||
{item.label}
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
|
||||
<button
|
||||
className="theme-toggle"
|
||||
onClick={cycle}
|
||||
title={`主题:${themeLabel}`}
|
||||
aria-label={`切换主题,当前${themeLabel}`}
|
||||
>
|
||||
{theme === 'dark' ? '深色' : theme === 'light' ? '浅色' : '自动'}
|
||||
</button>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main className="content">{children}</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Layout;
|
||||
@@ -1,18 +0,0 @@
|
||||
import React from 'react';
|
||||
import { Navigate } from 'react-router-dom';
|
||||
|
||||
interface ProtectedRouteProps {
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
function ProtectedRoute({ children }: ProtectedRouteProps) {
|
||||
const token = localStorage.getItem('ghl_token');
|
||||
|
||||
if (!token) {
|
||||
return <Navigate to="/login" replace />;
|
||||
}
|
||||
|
||||
return <>{children}</>;
|
||||
}
|
||||
|
||||
export default ProtectedRoute;
|
||||
470
client/src/components/Screen.css
Normal file
470
client/src/components/Screen.css
Normal file
@@ -0,0 +1,470 @@
|
||||
/* Sections ---------------------------------------------------------------- */
|
||||
.sec {
|
||||
margin-bottom: 1.5rem;
|
||||
}
|
||||
|
||||
.sec-title {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
gap: 0.5rem;
|
||||
margin: 0 0 0.65rem;
|
||||
font-size: 0.78rem;
|
||||
font-weight: 650;
|
||||
letter-spacing: 0.05em;
|
||||
text-transform: uppercase;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.sec-count {
|
||||
font-weight: 400;
|
||||
letter-spacing: 0;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
.sec-link {
|
||||
margin: 0.7rem 0 0;
|
||||
font-size: 0.83rem;
|
||||
}
|
||||
|
||||
.sec-link a { color: var(--accent); text-decoration: none; }
|
||||
.sec-link a:active { opacity: 0.6; }
|
||||
|
||||
/* Desktop keeps the same cards but gets more of them per row, so a wide
|
||||
window is filled with content instead of whitespace. */
|
||||
@media (min-width: 861px) {
|
||||
.page-inner .mcard-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
|
||||
}
|
||||
.page-inner .chart-grid {
|
||||
grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
|
||||
}
|
||||
}
|
||||
|
||||
/* Chrome bits shared by screens ------------------------------------------- */
|
||||
.screen-error {
|
||||
background: color-mix(in srgb, var(--status-critical) 12%, var(--surface-1));
|
||||
border: 1px solid color-mix(in srgb, var(--status-critical) 35%, transparent);
|
||||
color: var(--status-critical);
|
||||
padding: 0.8rem 1rem;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
.screen-ok {
|
||||
background: color-mix(in srgb, var(--status-good) 12%, var(--surface-1));
|
||||
border: 1px solid color-mix(in srgb, var(--status-good) 35%, transparent);
|
||||
color: var(--text-primary);
|
||||
padding: 0.8rem 1rem;
|
||||
border-radius: 12px;
|
||||
margin-bottom: 1rem;
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
.screen-empty {
|
||||
text-align: center;
|
||||
padding: 3rem 1.5rem;
|
||||
background: var(--surface-1);
|
||||
border: 1px dashed var(--border-strong);
|
||||
border-radius: 14px;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.screen-empty p { margin: 0 0 1.1rem; }
|
||||
|
||||
.screen-note {
|
||||
text-align: center;
|
||||
padding: 1.75rem 1rem;
|
||||
color: var(--text-muted);
|
||||
background: var(--surface-1);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
font-size: 0.88rem;
|
||||
}
|
||||
|
||||
.screen-disclaimer {
|
||||
margin: 2rem 0 0;
|
||||
padding-top: 1rem;
|
||||
border-top: 1px solid var(--border);
|
||||
font-size: 0.75rem;
|
||||
color: var(--text-muted);
|
||||
text-align: center;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
/* Segmented control, the iOS filter pattern. */
|
||||
.segmented-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.6rem;
|
||||
margin-bottom: 0.6rem;
|
||||
}
|
||||
|
||||
.segmented-label {
|
||||
font-size: 0.74rem;
|
||||
color: var(--text-muted);
|
||||
flex-shrink: 0;
|
||||
min-width: 2.2em;
|
||||
}
|
||||
|
||||
.segmented {
|
||||
display: flex;
|
||||
background: var(--surface-2);
|
||||
border-radius: 9px;
|
||||
padding: 2px;
|
||||
gap: 2px;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.segmented::-webkit-scrollbar { display: none; }
|
||||
|
||||
.segmented button {
|
||||
flex: 1;
|
||||
min-width: max-content;
|
||||
border: none;
|
||||
background: none;
|
||||
color: var(--text-secondary);
|
||||
font-family: inherit;
|
||||
font-size: 0.8rem;
|
||||
padding: 0.34rem 0.7rem;
|
||||
border-radius: 7px;
|
||||
cursor: pointer;
|
||||
white-space: nowrap;
|
||||
transition: background 0.18s var(--ease), color 0.18s var(--ease);
|
||||
}
|
||||
|
||||
.segmented button.on {
|
||||
background: var(--surface-1);
|
||||
color: var(--text-primary);
|
||||
font-weight: 600;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.segmented button { transition: none; }
|
||||
}
|
||||
|
||||
/* Day navigation (每日数据) ------------------------------------------------ */
|
||||
.day-nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.day-btn {
|
||||
width: 40px;
|
||||
height: 36px;
|
||||
border-radius: 9px;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--surface-1);
|
||||
color: var(--text-secondary);
|
||||
font-size: 1.15rem;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
transition: background 0.15s var(--ease), color 0.15s var(--ease);
|
||||
}
|
||||
|
||||
.day-btn:active:not(:disabled) { transform: scale(0.94); }
|
||||
.day-btn:disabled { opacity: 0.35; cursor: default; }
|
||||
|
||||
.day-input {
|
||||
flex: 1;
|
||||
padding: 0.5rem 0.7rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 9px;
|
||||
background: var(--surface-1);
|
||||
color: var(--text-primary);
|
||||
font-family: inherit;
|
||||
font-size: 0.9rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.day-summary {
|
||||
margin: 0 0 1.1rem;
|
||||
font-size: 0.8rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.toggle-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.45rem;
|
||||
font-size: 0.82rem;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
|
||||
/* Metric list (每日数据) --------------------------------------------------- */
|
||||
.metric-list {
|
||||
margin: 0;
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
overflow: hidden;
|
||||
background: var(--surface-1);
|
||||
}
|
||||
|
||||
.metric-row {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
padding: 0.62rem 0.9rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
border-right: 1px solid var(--border);
|
||||
}
|
||||
|
||||
.metric-row dt {
|
||||
color: var(--text-secondary);
|
||||
font-size: 0.84rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.1rem;
|
||||
}
|
||||
|
||||
.metric-hint { color: var(--text-muted); font-size: 0.7rem; }
|
||||
.metric-row dd { margin: 0; white-space: nowrap; text-align: right; }
|
||||
.metric-value { color: var(--text-primary); font-weight: 620; font-size: 1rem; }
|
||||
.metric-unit { color: var(--text-muted); font-size: 0.72rem; margin-left: 0.22rem; }
|
||||
.metric-empty { color: var(--text-muted); font-size: 0.8rem; }
|
||||
|
||||
/* Metric picker (趋势) ----------------------------------------------------- */
|
||||
.metric-picker {
|
||||
background: var(--surface-1);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
padding: 0.85rem 1rem;
|
||||
margin-bottom: 1.1rem;
|
||||
}
|
||||
|
||||
.picker-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 0.6rem;
|
||||
}
|
||||
|
||||
.picker-actions { display: flex; gap: 0.85rem; }
|
||||
|
||||
.link-button {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--accent);
|
||||
font-size: 0.78rem;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.picker-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
|
||||
|
||||
.chip {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.3rem;
|
||||
padding: 0.32rem 0.72rem;
|
||||
border-radius: 999px;
|
||||
font-size: 0.79rem;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
border: 1px solid var(--border);
|
||||
transition: all 0.15s var(--ease);
|
||||
}
|
||||
|
||||
.chip.on {
|
||||
background: var(--accent-soft);
|
||||
border-color: color-mix(in srgb, var(--accent) 40%, transparent);
|
||||
color: var(--accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.chip.off { background: var(--surface-0); color: var(--text-muted); }
|
||||
.chip:active { transform: scale(0.96); }
|
||||
.chip-mark { font-size: 0.72em; opacity: 0.85; }
|
||||
|
||||
.chart-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr;
|
||||
gap: 0.85rem;
|
||||
}
|
||||
|
||||
.chart-stats {
|
||||
display: flex;
|
||||
gap: 0.85rem;
|
||||
flex-wrap: wrap;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.chart-stats b { color: var(--text-primary); font-weight: 620; }
|
||||
|
||||
/* Badges / tables ---------------------------------------------------------- */
|
||||
.badge-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.badge {
|
||||
background: var(--surface-1);
|
||||
border: 1px solid var(--border);
|
||||
border-left: 3px solid var(--series-4);
|
||||
border-radius: 11px;
|
||||
padding: 0.65rem 0.8rem;
|
||||
}
|
||||
|
||||
.badge-name { font-size: 0.84rem; font-weight: 600; color: var(--text-primary); line-height: 1.4; }
|
||||
.badge-meta { margin-top: 0.28rem; font-size: 0.72rem; color: var(--text-muted); display: flex; gap: 0.45rem; }
|
||||
.badge-count { color: var(--accent); font-weight: 600; }
|
||||
|
||||
.table-wrap {
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
overflow: auto;
|
||||
background: var(--surface-1);
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.data-table { width: 100%; border-collapse: collapse; font-size: 0.83rem; }
|
||||
|
||||
.data-table th, .data-table td {
|
||||
padding: 0.58rem 0.8rem;
|
||||
border-bottom: 1px solid var(--border);
|
||||
text-align: left;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.data-table thead th {
|
||||
background: var(--surface-2);
|
||||
color: var(--text-muted);
|
||||
font-size: 0.72rem;
|
||||
font-weight: 650;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.04em;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.data-table tbody th { color: var(--text-primary); font-weight: 550; }
|
||||
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-primary); }
|
||||
.data-table tbody tr:last-child th, .data-table tbody tr:last-child td { border-bottom: none; }
|
||||
|
||||
.metric-tabs {
|
||||
display: flex;
|
||||
gap: 0.4rem;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 1.1rem;
|
||||
}
|
||||
|
||||
.metric-tab {
|
||||
padding: 0.34rem 0.8rem;
|
||||
border: 1px solid var(--border);
|
||||
background: var(--surface-1);
|
||||
border-radius: 999px;
|
||||
font-size: 0.81rem;
|
||||
color: var(--text-secondary);
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
.metric-tab.active {
|
||||
background: var(--accent-solid);
|
||||
border-color: var(--accent-solid);
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
/* Sync page ---------------------------------------------------------------- */
|
||||
.sync-container { display: grid; gap: 1rem; }
|
||||
|
||||
.status-card, .sync-actions, .info-box {
|
||||
background: var(--surface-1);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
padding: 1.1rem;
|
||||
}
|
||||
|
||||
.status-card h3, .info-box h4 {
|
||||
margin: 0 0 0.85rem;
|
||||
font-size: 0.92rem;
|
||||
font-weight: 650;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.status-info { display: flex; flex-direction: column; gap: 0.45rem; }
|
||||
|
||||
.status-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: baseline;
|
||||
gap: 1rem;
|
||||
padding: 0.52rem 0.7rem;
|
||||
background: var(--surface-0);
|
||||
border-radius: 9px;
|
||||
font-size: 0.86rem;
|
||||
}
|
||||
|
||||
.status-item .label { color: var(--text-muted); font-size: 0.8rem; }
|
||||
.status-item .value { color: var(--text-primary); font-weight: 550; text-align: right; }
|
||||
.value.status-idle { color: var(--status-good); }
|
||||
.value.status-syncing { color: var(--accent); }
|
||||
.value.status-error { color: var(--status-critical); }
|
||||
|
||||
.status-item.error {
|
||||
background: color-mix(in srgb, var(--status-critical) 8%, var(--surface-0));
|
||||
border: 1px solid color-mix(in srgb, var(--status-critical) 25%, transparent);
|
||||
}
|
||||
|
||||
.status-item.error .value { color: var(--status-critical); font-weight: 400; font-size: 0.78rem; word-break: break-word; }
|
||||
|
||||
.sync-choices { display: flex; gap: 0.5rem; flex-wrap: wrap; }
|
||||
.mfa-card { border-color: var(--accent); background: var(--accent-soft); }
|
||||
.code-input { font-size: 1.35rem; letter-spacing: 0.3em; text-align: center; }
|
||||
.mfa-buttons { display: flex; gap: 0.6rem; }
|
||||
.progress-block { display: flex; flex-direction: column; gap: 0.5rem; }
|
||||
.progress-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.88rem; color: var(--text-primary); }
|
||||
.progress-count { font-variant-numeric: tabular-nums; color: var(--text-secondary); font-size: 0.8rem; }
|
||||
.progress-bar { height: 6px; background: var(--surface-0); border-radius: 999px; overflow: hidden; }
|
||||
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.4s var(--ease); }
|
||||
.info-box ul { margin: 0; padding-left: 1.15rem; color: var(--text-secondary); line-height: 1.85; font-size: 0.84rem; }
|
||||
.cmd { background: var(--surface-0); border: 1px solid var(--border); color: var(--text-primary); padding: 0.8rem; border-radius: 9px; font-size: 0.76rem; line-height: 1.75; overflow-x: auto; margin: 0; font-family: Menlo, Monaco, monospace; }
|
||||
.field-hint { font-size: 0.77rem; color: var(--text-muted); line-height: 1.7; margin: 0; }
|
||||
|
||||
.form-group { display: flex; flex-direction: column; gap: 0.4rem; margin-bottom: 0.9rem; }
|
||||
.form-group label { font-size: 0.83rem; font-weight: 600; color: var(--text-secondary); }
|
||||
.form-group input {
|
||||
padding: 0.65rem 0.8rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 10px;
|
||||
font-size: 0.95rem;
|
||||
font-family: inherit;
|
||||
background: var(--surface-0);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
.form-group input:focus { outline: none; border-color: var(--accent); }
|
||||
|
||||
/* Settings ----------------------------------------------------------------- */
|
||||
.settings-section { margin-bottom: 1.75rem; padding-bottom: 1.25rem; border-bottom: 1px solid var(--border); }
|
||||
.settings-section:last-child { border-bottom: none; }
|
||||
.settings-section h3 { font-size: 0.95rem; font-weight: 650; color: var(--text-primary); margin: 0 0 0.5rem; }
|
||||
.settings-hint { color: var(--text-muted); font-size: 0.84rem; line-height: 1.75; margin-bottom: 0.9rem; }
|
||||
.settings-list { margin: 0; padding-left: 1.2rem; color: var(--text-secondary); line-height: 1.9; font-size: 0.86rem; }
|
||||
.btn-danger {
|
||||
background: var(--surface-1);
|
||||
color: var(--status-critical);
|
||||
border: 1px solid color-mix(in srgb, var(--status-critical) 40%, transparent);
|
||||
padding: 0.6rem 1.15rem;
|
||||
border-radius: 10px;
|
||||
font-size: 0.9rem;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.day-btn:active:not(:disabled), .chip:active { transform: none; }
|
||||
.progress-fill { transition: none; }
|
||||
}
|
||||
64
client/src/components/Screen.tsx
Normal file
64
client/src/components/Screen.tsx
Normal file
@@ -0,0 +1,64 @@
|
||||
import { ReactNode, useEffect, useState } from 'react';
|
||||
import { Page, Navbar, NavRight, Link, f7 } from 'framework7-react';
|
||||
import { apiClient } from '../services/api';
|
||||
import './Screen.css';
|
||||
|
||||
interface ScreenProps {
|
||||
title: string;
|
||||
subtitle?: string;
|
||||
/** Shown as an iOS large title that collapses on scroll. */
|
||||
large?: boolean;
|
||||
/** Back chevron instead of the app's utility links. */
|
||||
backLink?: boolean;
|
||||
/** Skip the auth gate (the login screen itself). */
|
||||
open?: boolean;
|
||||
right?: ReactNode;
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Common page chrome.
|
||||
*
|
||||
* Every screen is an F7 `<Page>` so it inherits the platform behaviour we
|
||||
* switched to Framework7 for — sliding transitions, rubber-band scrolling,
|
||||
* collapsing large titles — while the content inside stays ours.
|
||||
*/
|
||||
function Screen({
|
||||
title, subtitle, large = true, backLink, open, right, children,
|
||||
}: ScreenProps) {
|
||||
const [authed, setAuthed] = useState(() => apiClient.isAuthenticated());
|
||||
|
||||
useEffect(() => {
|
||||
if (open || authed) return;
|
||||
// Router navigation rather than a redirect component: F7 owns history.
|
||||
f7.views.current.router.navigate('/login/', { reloadAll: true });
|
||||
}, [authed, open]);
|
||||
|
||||
useEffect(() => {
|
||||
const onStorage = () => setAuthed(apiClient.isAuthenticated());
|
||||
window.addEventListener('storage', onStorage);
|
||||
return () => window.removeEventListener('storage', onStorage);
|
||||
}, []);
|
||||
|
||||
if (!open && !authed) return <Page />;
|
||||
|
||||
return (
|
||||
<Page>
|
||||
<Navbar large={large} transparent={large} title={title} subtitle={subtitle} backLink={backLink ? '返回' : undefined}>
|
||||
<NavRight>
|
||||
{right ?? (
|
||||
<>
|
||||
<Link href="/sleep/" iconIos="f7:moon_stars" tooltip="睡眠" />
|
||||
<Link href="/sync/" iconIos="f7:arrow_2_circlepath" tooltip="同步" />
|
||||
<Link href="/settings/" iconIos="f7:gear_alt" tooltip="设置" />
|
||||
</>
|
||||
)}
|
||||
</NavRight>
|
||||
</Navbar>
|
||||
|
||||
<div className="page-inner">{children}</div>
|
||||
</Page>
|
||||
);
|
||||
}
|
||||
|
||||
export default Screen;
|
||||
57
client/src/components/charts/BandBar.css
Normal file
57
client/src/components/charts/BandBar.css
Normal file
@@ -0,0 +1,57 @@
|
||||
.bandbar {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
border-radius: 999px;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.bandbar.vertical {
|
||||
flex-direction: column-reverse;
|
||||
height: 100%;
|
||||
width: 6px;
|
||||
}
|
||||
|
||||
.bandbar-seg:first-child { border-radius: 999px 0 0 999px; }
|
||||
.bandbar-seg:last-child { border-radius: 0 999px 999px 0; }
|
||||
.bandbar.vertical .bandbar-seg:first-child { border-radius: 0 0 999px 999px; }
|
||||
.bandbar.vertical .bandbar-seg:last-child { border-radius: 999px 999px 0 0; }
|
||||
|
||||
.bandbar-seg {
|
||||
height: 100%;
|
||||
/* Bands are muted so the marker, not the track, is what the eye lands on. */
|
||||
opacity: 0.42;
|
||||
}
|
||||
|
||||
.bandbar.vertical .bandbar-seg {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.tone-good { background: var(--status-good); }
|
||||
.tone-warning { background: var(--status-warning); }
|
||||
.tone-serious { background: var(--status-serious); }
|
||||
.tone-critical { background: var(--status-critical); }
|
||||
|
||||
/* A 2px surface ring keeps the marker legible wherever it lands. */
|
||||
.bandbar-marker {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 50%;
|
||||
background: var(--text-primary);
|
||||
border: 2px solid var(--surface-1);
|
||||
transform: translate(-50%, -50%);
|
||||
transition: left 0.9s var(--ease), bottom 0.9s var(--ease);
|
||||
}
|
||||
|
||||
.bandbar.vertical .bandbar-marker {
|
||||
top: auto;
|
||||
left: 50%;
|
||||
transform: translate(-50%, 50%);
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.bandbar-marker { transition: none; }
|
||||
}
|
||||
79
client/src/components/charts/BandBar.tsx
Normal file
79
client/src/components/charts/BandBar.tsx
Normal file
@@ -0,0 +1,79 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Band, Range } from '../../lib/ranges';
|
||||
import { usePrefersReducedMotion } from '../../lib/motion';
|
||||
import './BandBar.css';
|
||||
|
||||
interface BandBarProps {
|
||||
range: Range;
|
||||
value: number | null;
|
||||
/** Vertical layout for compact rows of metrics. */
|
||||
vertical?: boolean;
|
||||
height?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* The reference bands as a segmented track, with a marker at the current value.
|
||||
*
|
||||
* This is what turns a bare number into a judgement the reader can check: the
|
||||
* marker's position shows *why* the value earned its label. The band colours
|
||||
* come from the reserved status palette, and the label itself is always
|
||||
* rendered as text beside the bar — colour never carries the verdict alone.
|
||||
*/
|
||||
function BandBar({ range, value, vertical = false, height = 6 }: BandBarProps) {
|
||||
const reduced = usePrefersReducedMotion();
|
||||
const [settled, setSettled] = useState(reduced);
|
||||
|
||||
useEffect(() => {
|
||||
if (reduced) return;
|
||||
const id = requestAnimationFrame(() => setSettled(true));
|
||||
return () => cancelAnimationFrame(id);
|
||||
}, [reduced]);
|
||||
|
||||
const min = range.min ?? 0;
|
||||
const max = range.max ?? range.bands[range.bands.length - 2]?.max ?? 100;
|
||||
const span = max - min || 1;
|
||||
|
||||
// Segment widths are proportional to how much of the scale each band covers,
|
||||
// so a wide "normal" band looks wide — equal-width segments would misstate
|
||||
// how much room there is inside each verdict.
|
||||
const segments = range.bands.map((band: Band, i) => {
|
||||
const lower = i === 0 ? min : range.bands[i - 1].max;
|
||||
const upper = Math.min(band.max === Infinity ? max : band.max, max);
|
||||
return { band, size: (Math.max(0, upper - lower) / span) * 100 };
|
||||
});
|
||||
|
||||
const position =
|
||||
value == null ? null : Math.min(100, Math.max(0, ((value - min) / span) * 100));
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`bandbar ${vertical ? 'vertical' : ''}`}
|
||||
style={vertical ? { width: height } : { height }}
|
||||
role="img"
|
||||
aria-label={
|
||||
value == null ? '暂无数据' : `当前 ${value},参考区间 ${range.goodFrom}~${range.goodTo}`
|
||||
}
|
||||
>
|
||||
{segments.map(({ band, size }, i) => (
|
||||
<span
|
||||
key={i}
|
||||
className={`bandbar-seg tone-${band.tone}`}
|
||||
style={vertical ? { height: `${size}%` } : { width: `${size}%` }}
|
||||
/>
|
||||
))}
|
||||
|
||||
{position != null && (
|
||||
<span
|
||||
className="bandbar-marker"
|
||||
style={
|
||||
vertical
|
||||
? { bottom: settled ? `${position}%` : '0%' }
|
||||
: { left: settled ? `${position}%` : '0%' }
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default BandBar;
|
||||
124
client/src/components/charts/MetricCard.css
Normal file
124
client/src/components/charts/MetricCard.css
Normal file
@@ -0,0 +1,124 @@
|
||||
.mcard {
|
||||
background: var(--surface-1);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
padding: 0.9rem 1rem 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.45rem;
|
||||
text-align: left;
|
||||
font-family: inherit;
|
||||
width: 100%;
|
||||
box-shadow: var(--shadow);
|
||||
transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease),
|
||||
border-color 0.2s var(--ease);
|
||||
}
|
||||
|
||||
.mcard.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.mcard:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: var(--shadow-lift);
|
||||
border-color: var(--border-strong);
|
||||
}
|
||||
|
||||
.mcard-head {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
min-height: 20px;
|
||||
}
|
||||
|
||||
.mcard-label {
|
||||
font-size: 0.82rem;
|
||||
color: var(--text-secondary);
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.mcard-chevron {
|
||||
color: var(--text-muted);
|
||||
font-size: 1.1rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
/* Proportional figures: tabular-nums would make a large standalone value look
|
||||
loose. Tabular is reserved for columns that must align. */
|
||||
.mcard-value {
|
||||
font-size: 1.85rem;
|
||||
font-weight: 660;
|
||||
line-height: 1.05;
|
||||
color: var(--text-primary);
|
||||
letter-spacing: -0.015em;
|
||||
}
|
||||
|
||||
.mcard-unit {
|
||||
font-size: 0.72rem;
|
||||
font-weight: 400;
|
||||
color: var(--text-muted);
|
||||
margin-left: 0.2rem;
|
||||
}
|
||||
|
||||
.mcard-verdict {
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
gap: 0.5rem;
|
||||
font-size: 0.76rem;
|
||||
}
|
||||
|
||||
.mcard-tone {
|
||||
font-weight: 650;
|
||||
display: inline-flex;
|
||||
align-items: baseline;
|
||||
gap: 0.25rem;
|
||||
}
|
||||
|
||||
.mcard-tone.tone-good { background: none; color: var(--status-good); }
|
||||
.mcard-tone.tone-warning { background: none; color: var(--status-warning); }
|
||||
.mcard-tone.tone-serious { background: none; color: var(--status-serious); }
|
||||
.mcard-tone.tone-critical { background: none; color: var(--status-critical); }
|
||||
|
||||
.mcard-target {
|
||||
color: var(--text-muted);
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.mcard-detail {
|
||||
font-size: 0.76rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
/* Two columns, the way the phone apps lay these out. */
|
||||
.mcard-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
|
||||
gap: 0.75rem;
|
||||
}
|
||||
|
||||
.mcard-grid > * {
|
||||
animation: tile-in 0.42s var(--ease) both;
|
||||
}
|
||||
|
||||
.mcard-grid > *:nth-child(2) { animation-delay: 45ms; }
|
||||
.mcard-grid > *:nth-child(3) { animation-delay: 90ms; }
|
||||
.mcard-grid > *:nth-child(4) { animation-delay: 135ms; }
|
||||
.mcard-grid > *:nth-child(5) { animation-delay: 180ms; }
|
||||
.mcard-grid > *:nth-child(n + 6) { animation-delay: 220ms; }
|
||||
|
||||
@media (max-width: 560px) {
|
||||
.mcard-grid { grid-template-columns: repeat(2, 1fr); }
|
||||
.mcard { padding: 0.75rem 0.8rem 0.85rem; border-radius: 12px; }
|
||||
.mcard-value { font-size: 1.45rem; }
|
||||
.mcard-target { display: none; }
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.mcard { transition: none; animation: none; }
|
||||
.mcard:hover { transform: none; }
|
||||
.mcard-grid > * { animation: none; }
|
||||
}
|
||||
86
client/src/components/charts/MetricCard.tsx
Normal file
86
client/src/components/charts/MetricCard.tsx
Normal file
@@ -0,0 +1,86 @@
|
||||
import { ReactNode } from 'react';
|
||||
import { classify, formatTarget } from '../../lib/ranges';
|
||||
import { useCountUp } from '../../lib/motion';
|
||||
import BandBar from './BandBar';
|
||||
import Sparkline from './Sparkline';
|
||||
import './MetricCard.css';
|
||||
|
||||
/* Status is icon + word + colour, never colour alone — the light-surface
|
||||
status steps sit below 3:1 by design. */
|
||||
const TONE_ICON: Record<string, string> = {
|
||||
good: '✓',
|
||||
warning: '!',
|
||||
serious: '↓',
|
||||
critical: '!',
|
||||
};
|
||||
|
||||
interface MetricCardProps {
|
||||
/** Key into RANGES; when absent the card shows no verdict. */
|
||||
metric?: string;
|
||||
label: string;
|
||||
value: number | null | undefined;
|
||||
unit?: string;
|
||||
decimals?: number;
|
||||
/** Recent history, drawn as an inline sparkline when supplied. */
|
||||
trend?: Array<number | null | undefined>;
|
||||
/** Extra line under the value. */
|
||||
detail?: ReactNode;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
function MetricCard({
|
||||
metric, label, value, unit, decimals = 0, trend, detail, onClick,
|
||||
}: MetricCardProps) {
|
||||
const numeric = typeof value === 'number' ? value : null;
|
||||
const animated = useCountUp(numeric);
|
||||
const verdict = metric ? classify(metric, numeric) : null;
|
||||
|
||||
const display =
|
||||
numeric == null
|
||||
? '—'
|
||||
: (animated ?? numeric).toLocaleString(undefined, {
|
||||
minimumFractionDigits: 0,
|
||||
maximumFractionDigits: decimals,
|
||||
});
|
||||
|
||||
const Tag = onClick ? 'button' : 'div';
|
||||
|
||||
return (
|
||||
<Tag
|
||||
className={`mcard ${onClick ? 'clickable' : ''}`}
|
||||
onClick={onClick}
|
||||
type={onClick ? 'button' : undefined}
|
||||
>
|
||||
<div className="mcard-head">
|
||||
<span className="mcard-label">{label}</span>
|
||||
{trend && trend.some((v) => v != null) ? (
|
||||
<Sparkline values={trend} label={`${label}近期走势`} width={54} height={18} />
|
||||
) : (
|
||||
onClick && <span className="mcard-chevron" aria-hidden="true">›</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="mcard-value">
|
||||
{display}
|
||||
{unit && numeric != null && <span className="mcard-unit">{unit}</span>}
|
||||
</div>
|
||||
|
||||
{verdict && numeric != null ? (
|
||||
<>
|
||||
<div className="mcard-verdict">
|
||||
<span className={`mcard-tone tone-${verdict.band.tone}`}>
|
||||
<span aria-hidden="true">{TONE_ICON[verdict.band.tone]}</span>
|
||||
{verdict.band.label}
|
||||
</span>
|
||||
<span className="mcard-target">参考 {formatTarget(verdict.range)}</span>
|
||||
</div>
|
||||
<BandBar range={verdict.range} value={numeric} />
|
||||
</>
|
||||
) : (
|
||||
detail && <div className="mcard-detail">{detail}</div>
|
||||
)}
|
||||
</Tag>
|
||||
);
|
||||
}
|
||||
|
||||
export default MetricCard;
|
||||
72
client/src/components/charts/MetricStrip.css
Normal file
72
client/src/components/charts/MetricStrip.css
Normal file
@@ -0,0 +1,72 @@
|
||||
.strip-card {
|
||||
background: var(--surface-1);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
padding: 1rem 1.1rem 1.1rem;
|
||||
box-shadow: var(--shadow);
|
||||
}
|
||||
|
||||
.strip-title {
|
||||
margin: 0 0 0.9rem;
|
||||
font-size: 0.85rem;
|
||||
font-weight: 650;
|
||||
color: var(--text-secondary);
|
||||
}
|
||||
|
||||
.strip {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
|
||||
gap: 0.6rem;
|
||||
}
|
||||
|
||||
.strip-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.35rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.strip-icon {
|
||||
font-size: 1.05rem;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.strip-meter {
|
||||
height: 46px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
background: var(--surface-0);
|
||||
border-radius: 999px;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.strip-meter-empty {
|
||||
display: block;
|
||||
width: 5px;
|
||||
height: 100%;
|
||||
background: var(--border);
|
||||
border-radius: 999px;
|
||||
}
|
||||
|
||||
.strip-value {
|
||||
font-size: 1.02rem;
|
||||
font-weight: 650;
|
||||
color: var(--text-primary);
|
||||
line-height: 1.1;
|
||||
}
|
||||
|
||||
.strip-unit {
|
||||
font-size: 0.68rem;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.strip-tone {
|
||||
font-size: 0.66rem;
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.strip-tone.tone-good { background: none; color: var(--status-good); }
|
||||
.strip-tone.tone-warning { background: none; color: var(--status-warning); }
|
||||
.strip-tone.tone-serious { background: none; color: var(--status-serious); }
|
||||
.strip-tone.tone-critical { background: none; color: var(--status-critical); }
|
||||
60
client/src/components/charts/MetricStrip.tsx
Normal file
60
client/src/components/charts/MetricStrip.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
import { classify } from '../../lib/ranges';
|
||||
import BandBar from './BandBar';
|
||||
import './MetricStrip.css';
|
||||
|
||||
export interface StripItem {
|
||||
metric?: string;
|
||||
icon: string;
|
||||
label: string;
|
||||
value: number | null | undefined;
|
||||
unit?: string;
|
||||
decimals?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* A row of small metrics, each with its position in its own reference band.
|
||||
*
|
||||
* Denser than a card per metric, and useful precisely because the bands make
|
||||
* five unrelated units comparable at a glance: the reader is comparing "where
|
||||
* in range", not the raw numbers.
|
||||
*/
|
||||
function MetricStrip({ items, title }: { items: StripItem[]; title?: string }) {
|
||||
return (
|
||||
<section className="strip-card">
|
||||
{title && <h3 className="strip-title">{title}</h3>}
|
||||
<div className="strip">
|
||||
{items.map((item) => {
|
||||
const numeric = typeof item.value === 'number' ? item.value : null;
|
||||
const verdict = item.metric ? classify(item.metric, numeric) : null;
|
||||
return (
|
||||
<div className="strip-item" key={item.label}>
|
||||
<span className="strip-icon" aria-hidden="true">{item.icon}</span>
|
||||
<div className="strip-meter">
|
||||
{verdict ? (
|
||||
<BandBar range={verdict.range} value={numeric} vertical height={5} />
|
||||
) : (
|
||||
<span className="strip-meter-empty" />
|
||||
)}
|
||||
</div>
|
||||
<div className="strip-value">
|
||||
{numeric == null
|
||||
? '—'
|
||||
: numeric.toLocaleString(undefined, {
|
||||
maximumFractionDigits: item.decimals ?? 0,
|
||||
})}
|
||||
</div>
|
||||
<div className="strip-unit">{item.unit ?? item.label}</div>
|
||||
{verdict && (
|
||||
<div className={`strip-tone tone-${verdict.band.tone}`}>
|
||||
{verdict.band.label}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
export default MetricStrip;
|
||||
Reference in New Issue
Block a user