From 9e550e34f9a4296bb8700e4ba092dd1270d4fa31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=85=E5=87=A4?= Date: Tue, 1 Dec 2026 03:11:02 -0400 Subject: [PATCH 1/3] feat: add BarList, SegmentedBar, StatusList, and Steps primitives --- skills/ui-owners/SKILL.md | 12 ++ src/components/bar-list/BarList.vue | 190 ++++++++++++++++++ src/components/bar-list/index.ts | 2 + src/components/segmented-bar/SegmentedBar.vue | 138 +++++++++++++ src/components/segmented-bar/index.ts | 1 + src/components/status-list/StatusList.vue | 116 +++++++++++ src/components/status-list/index.ts | 1 + src/components/steps/Steps.vue | 105 ++++++++++ src/components/steps/index.ts | 1 + src/index.ts | 4 + src/lib/data-tone.ts | 55 +++++ 11 files changed, 625 insertions(+) create mode 100644 src/components/bar-list/BarList.vue create mode 100644 src/components/bar-list/index.ts create mode 100644 src/components/segmented-bar/SegmentedBar.vue create mode 100644 src/components/segmented-bar/index.ts create mode 100644 src/components/status-list/StatusList.vue create mode 100644 src/components/status-list/index.ts create mode 100644 src/components/steps/Steps.vue create mode 100644 src/components/steps/index.ts create mode 100644 src/lib/data-tone.ts diff --git a/skills/ui-owners/SKILL.md b/skills/ui-owners/SKILL.md index 6c7d212..8433872 100644 --- a/skills/ui-owners/SKILL.md +++ b/skills/ui-owners/SKILL.md @@ -111,6 +111,14 @@ description: 在编写或修改任何设置页、Bot 详情页 Tab、弹窗/气 - **`MetricReadout` `[稳定]`** - 单个统计数值块:上方小字标签 + 下方等宽数字(`tabular-nums`)或状态点。Props:`label`、`value`、`sub`、`framed`(默认 `true` 带边框白卡,在已有表面上裸放时设 `false`)、`status: 'ok' | 'warn' | 'error'`;插槽:`#value`(自定义相对时间或等宽文本)。网格列数由调用方外层容器控制。 +- **`BarList` `[稳定]`** + - 单序列排行或多序列分组横向比例对比条(无全宽灰底轨道,与 `Progress` 单指标进度槽区分):顶部可选圆点图例(`series`),左侧为 `h-3.5 rounded-sm` 比例条,右侧为自动对齐小数位的等宽数值与单位(`tabular-nums`)。 +- **`SegmentedBar` `[稳定]`** + - 部分占整体的多段构成占比条(`h-3.5 rounded-sm`):上方分段色条与下方圆点明细行共享悬停联动弱化(`opacity-40`),自动计算百分比与数值读数。 +- **`StatusList` `[稳定]`** + - 带状态图标(`ok` / `warn` / `error` / `info` / `neutral`)的紧凑检查或键值对齐行:支持 `divided` 细线分隔、左侧副说明 `sub` 与右侧辅助 `meta` + 等宽状态结果。 +- **`Steps` `[稳定]`** + - 纵向编号与状态步骤流(`done` / `current` / `warn` / `upcoming`):左侧状态圆标与连接细线,右侧步骤标题、可选 `Badge` 与说明文案。 - **`PersonaTile` `[稳定]`** - 垂直居中的实体/新增磁贴卡片(`w-52 flex-col items-center`,`variant: 'entity' | 'add'`),是水平 `BackendCard` 的纵向对应物。 - **`CalloutBanner` `[稳定]`** @@ -164,6 +172,10 @@ description: 在编写或修改任何设置页、Bot 详情页 Tab、弹窗/气 | 同页堆叠多组自带边框的网格(如多组卡片) | `SectionGroup` | | 标签在上的垂直表单字段(含校验报错) | `FieldStack`(连续多个外包 `FormStack`) | | 单个统计数字/状态磁贴 | `MetricReadout`(外层网格由调用方排布) | +| 横向排行或多序列分组比例对比条 | `BarList`(单值进度用 `Progress`) | +| 部分占整体的多段占比构成条 | `SegmentedBar` | +| 带通过/告警/失败图标的检查对齐列表 | `StatusList` | +| 纵向阶段或操作步骤流 | `Steps` | | 垂直居中的角色/新增磁贴 | `PersonaTile` | | 警告或错误提示横幅 | `CalloutBanner` | | 设备码输入与一键复制跳转面板 | `DeviceCodePanel` | diff --git a/src/components/bar-list/BarList.vue b/src/components/bar-list/BarList.vue new file mode 100644 index 0000000..a79735a --- /dev/null +++ b/src/components/bar-list/BarList.vue @@ -0,0 +1,190 @@ + + + diff --git a/src/components/bar-list/index.ts b/src/components/bar-list/index.ts new file mode 100644 index 0000000..9b7c514 --- /dev/null +++ b/src/components/bar-list/index.ts @@ -0,0 +1,2 @@ +export { default as BarList, type BarListItem, type BarListSeries } from './BarList.vue' +export { type DataTone, formatDataValue } from '#/lib/data-tone' diff --git a/src/components/segmented-bar/SegmentedBar.vue b/src/components/segmented-bar/SegmentedBar.vue new file mode 100644 index 0000000..ddc4e48 --- /dev/null +++ b/src/components/segmented-bar/SegmentedBar.vue @@ -0,0 +1,138 @@ + + + diff --git a/src/components/segmented-bar/index.ts b/src/components/segmented-bar/index.ts new file mode 100644 index 0000000..cea0755 --- /dev/null +++ b/src/components/segmented-bar/index.ts @@ -0,0 +1 @@ +export { default as SegmentedBar, type SegmentedBarItem } from './SegmentedBar.vue' diff --git a/src/components/status-list/StatusList.vue b/src/components/status-list/StatusList.vue new file mode 100644 index 0000000..f304022 --- /dev/null +++ b/src/components/status-list/StatusList.vue @@ -0,0 +1,116 @@ + + + diff --git a/src/components/status-list/index.ts b/src/components/status-list/index.ts new file mode 100644 index 0000000..6486a3e --- /dev/null +++ b/src/components/status-list/index.ts @@ -0,0 +1 @@ +export { default as StatusList, type StatusListItem, type StatusListState } from './StatusList.vue' diff --git a/src/components/steps/Steps.vue b/src/components/steps/Steps.vue new file mode 100644 index 0000000..76c5163 --- /dev/null +++ b/src/components/steps/Steps.vue @@ -0,0 +1,105 @@ + + + diff --git a/src/components/steps/index.ts b/src/components/steps/index.ts new file mode 100644 index 0000000..6ad019e --- /dev/null +++ b/src/components/steps/index.ts @@ -0,0 +1 @@ +export { default as Steps, type StepItem, type StepStatus } from './Steps.vue' diff --git a/src/index.ts b/src/index.ts index 3df22d4..db24372 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,6 +4,7 @@ export * from './components/alert/index' export * from './components/auto-height/index' export * from './components/avatar/index' export * from './components/badge/index' +export * from './components/bar-list/index' export * from './components/breadcrumb/index' export * from './components/button/index' export * from './components/button-group/index' @@ -53,6 +54,7 @@ export * from './components/radio-group/index' export * from './components/range-calendar/index' export * from './components/scroll-area/index' export * from './components/segmented/index' +export * from './components/segmented-bar/index' export * from './components/select/index' export * from './components/separator/index' export * from './components/settings/index' @@ -62,6 +64,8 @@ export * from './components/skeleton/index' export * from './components/slider/index' export * from './components/sonner/index' export * from './components/spinner/index' +export * from './components/status-list/index' +export * from './components/steps/index' export * from './components/switch/index' export * from './components/table/index' export * from './components/tabs/index' diff --git a/src/lib/data-tone.ts b/src/lib/data-tone.ts new file mode 100644 index 0000000..42d3bb1 --- /dev/null +++ b/src/lib/data-tone.ts @@ -0,0 +1,55 @@ +export type DataTone = 'neutral' | 'blue' | 'emerald' | 'teal' | 'amber' | 'violet' | 'rose' + +export interface DataTonePalette { + solid: string + soft: string + border: string +} + +export const DATA_TONE_PALETTE: Record = { + blue: { solid: 'var(--accent-blue)', soft: 'var(--accent-blue-soft)', border: 'var(--accent-blue-border)' }, + emerald: { solid: 'var(--accent-green)', soft: 'var(--accent-green-soft)', border: 'var(--accent-green-border)' }, + teal: { solid: 'var(--accent-teal)', soft: 'var(--accent-teal-soft)', border: 'var(--accent-teal-border)' }, + amber: { solid: 'var(--accent-orange)', soft: 'var(--accent-orange-soft)', border: 'var(--accent-orange-border)' }, + violet: { solid: 'var(--accent-purple)', soft: 'var(--accent-purple-soft)', border: 'var(--accent-purple-border)' }, + rose: { solid: 'var(--accent-red)', soft: 'var(--accent-red-soft)', border: 'var(--accent-red-border)' }, + neutral: { solid: 'var(--muted-foreground)', soft: 'var(--muted)', border: 'var(--border-hairline)' }, +} + +const PREFIX_CURRENCY_UNITS = new Set(['$', 'US$', 'HK$', 'NT$', '¥', '¥', 'CN¥', 'JP¥', '€', '£', '₩']) +const TIGHT_SUFFIX_UNITS = new Set(['%', '×', '°', '°C', '°F']) + +export function isDataTone(value: unknown): value is DataTone { + return typeof value === 'string' && Object.hasOwn(DATA_TONE_PALETTE, value) +} + +export function resolveDataTone(tone: unknown, fallback: DataTone = 'blue'): DataTonePalette { + return isDataTone(tone) ? DATA_TONE_PALETTE[tone] : DATA_TONE_PALETTE[fallback] +} + +export function toSafeFiniteNumber(raw: unknown, fallback = 0): number { + if (raw === null || raw === undefined || raw === '') return fallback + const num = typeof raw === 'number' ? raw : Number(raw) + return Number.isFinite(num) ? (Object.is(num, -0) ? 0 : num) : fallback +} + +export function toOptionalPositiveNumber(raw: unknown): number | undefined { + if (raw === null || raw === undefined || raw === '') return undefined + const num = typeof raw === 'number' ? raw : Number(raw) + return Number.isFinite(num) && num > 0 ? num : undefined +} + +export function formatDataValue(value: number, unit?: string, minFractionDigits = 0): string { + const safeVal = Number.isFinite(value) ? (Object.is(value, -0) ? 0 : value) : 0 + const trimmedUnit = unit?.trim() + const minDigits = Math.max(0, Math.min(2, Math.trunc(minFractionDigits))) + const formatted = new Intl.NumberFormat(undefined, { + minimumFractionDigits: minDigits, + maximumFractionDigits: Math.max(2, minDigits), + }).format(trimmedUnit && PREFIX_CURRENCY_UNITS.has(trimmedUnit) ? Math.abs(safeVal) : safeVal) + + if (!trimmedUnit) return formatted + if (TIGHT_SUFFIX_UNITS.has(trimmedUnit)) return `${formatted}${trimmedUnit}` + if (PREFIX_CURRENCY_UNITS.has(trimmedUnit)) return `${safeVal < 0 ? '-' : ''}${trimmedUnit}${formatted}` + return `${formatted} ${trimmedUnit}` +} From 543e3d9dab1a276616bd8a272fe73c1b9f92cef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=B8=85=E5=87=A4?= Date: Tue, 1 Dec 2026 04:25:42 -0400 Subject: [PATCH 2/3] fix: address review feedback on hover layer, shared bar scale, and showcase specs --- showcase/specs/bar-list.ts | 63 +++++++++++++++++++ showcase/specs/index.ts | 8 +++ showcase/specs/segmented-bar.ts | 47 ++++++++++++++ showcase/specs/status-list.ts | 34 ++++++++++ showcase/specs/steps.ts | 28 +++++++++ src/components/bar-list/BarList.vue | 60 +++++++++--------- src/components/bar-list/index.ts | 4 +- src/components/segmented-bar/SegmentedBar.vue | 10 +-- src/components/status-list/StatusList.vue | 21 ++++--- src/components/status-list/index.ts | 2 +- src/components/steps/Steps.vue | 9 ++- src/components/steps/index.ts | 2 +- src/lib/data-tone.ts | 3 +- src/style.css | 17 +++++ 14 files changed, 258 insertions(+), 50 deletions(-) create mode 100644 showcase/specs/bar-list.ts create mode 100644 showcase/specs/segmented-bar.ts create mode 100644 showcase/specs/status-list.ts create mode 100644 showcase/specs/steps.ts diff --git a/showcase/specs/bar-list.ts b/showcase/specs/bar-list.ts new file mode 100644 index 0000000..b6acd4e --- /dev/null +++ b/showcase/specs/bar-list.ts @@ -0,0 +1,63 @@ +import type { ComponentSpec } from '../lib/spec' +import { h } from 'vue' +import { BarList, barListSortKeys, dataToneKeys } from '#/components/bar-list' + +export const barListSpec: ComponentSpec = { + id: 'bar-list', + name: 'BarList', + description: + 'Proportional horizontal comparison bars without a full-width background track, sharing one common readout column so bar lengths stay true to scale.', + descriptionZh: + '无全宽灰底轨道的横向比例对比条:共享统一的右侧数值列宽度,保证所有条形长度严格按同一比例尺绘制。', + controls: [ + { kind: 'string', key: 'title', label: 'Title', default: 'Throughput by tier' }, + { kind: 'enum', key: 'sort', label: 'Sort', options: barListSortKeys, default: 'desc', display: 'segmented' }, + { kind: 'enum', key: 'tone', label: 'Tone', options: dataToneKeys, default: 'blue' }, + { kind: 'boolean', key: 'grouped', label: 'Multi-series', default: false }, + ], + examples: [ + { + name: 'Multi-series multipliers', + nameZh: '多序列倍率对比', + note: 'Series dots identify each bar within a group; decimals align automatically.', + noteZh: '顶部圆点图例区分组内多条序列,小数位自动补齐对齐。', + state: { title: 'Bandwidth vs. price multiplier', sort: 'none', grouped: true }, + }, + ], + render: state => + state.grouped + ? h(BarList, { + class: 'w-full max-w-96', + title: String(state.title), + unit: '×', + sort: state.sort as never, + series: [ + { name: 'Bandwidth', tone: 'blue' }, + { name: 'Hourly cost', tone: 'amber' }, + ], + items: [ + { label: 'Baseline', values: [1, 1] }, + { label: 'Mid-range', values: [2.31, 1.28] }, + { label: 'Flagship', values: [5.56, 2.33] }, + ], + }) + : h(BarList, { + class: 'w-full max-w-96', + title: String(state.title), + unit: 'req/s', + sort: state.sort as never, + items: [ + { label: 'Edge cache', value: 1420, tone: state.tone as never }, + { label: 'Regional API', value: 860, tone: state.tone as never }, + { label: 'Cold origin', value: 95, tone: state.tone as never }, + ], + }), + usage: `Use BarList to compare ranked or grouped quantities across items. Unlike Progress, bars have no full-width gray track behind them so visual weight reflects magnitude rather than completion. + +- Reserve Progress for a single 0–100 completion or quota gauge. +- Set unit (such as "×", "%", "ms", "GB") when all items share one unit.`, + usageZh: `用 BarList 横向对比多条目的排行或分组数值。不同于 Progress,条形背后不铺满灰底轨道,使视觉长度直接表达量级而非完成度。 + +- 单一 0–100 完成度或配额进度请用 Progress。 +- 各条目共用同一单位时传入 unit(如 "×"、"%"、"ms"、"GB")。`, +} diff --git a/showcase/specs/index.ts b/showcase/specs/index.ts index c71b739..fbc38c6 100644 --- a/showcase/specs/index.ts +++ b/showcase/specs/index.ts @@ -2,6 +2,7 @@ import type { ComponentSpec } from '../lib/spec' import { accordionSpec } from './accordion' import { actionCardSpec } from './action-card' import { badgeSpec } from './badge' +import { barListSpec } from './bar-list' import { buttonSpec } from './button' import { cardSpec } from './card' import { checkboxSpec } from './checkbox' @@ -15,9 +16,12 @@ import { nativeSelectSpec } from './native-select' import { numberFieldSpec } from './number-field' import { popoverSpec } from './popover' import { segmentedSpec } from './segmented' +import { segmentedBarSpec } from './segmented-bar' import { selectSpec } from './select' import { skeletonSpec } from './skeleton' import { sonnerSpec } from './sonner' +import { statusListSpec } from './status-list' +import { stepsSpec } from './steps' import { switchSpec } from './switch' import { tabsSpec } from './tabs' import { textareaSpec } from './textarea' @@ -45,6 +49,10 @@ export const componentSpecs: ComponentSpec[] = [ actionCardSpec, badgeSpec, cardSpec, + barListSpec, + segmentedBarSpec, + statusListSpec, + stepsSpec, tabsSpec, accordionSpec, skeletonSpec, diff --git a/showcase/specs/segmented-bar.ts b/showcase/specs/segmented-bar.ts new file mode 100644 index 0000000..127e9d6 --- /dev/null +++ b/showcase/specs/segmented-bar.ts @@ -0,0 +1,47 @@ +import type { ComponentSpec } from '../lib/spec' +import { h } from 'vue' +import { SegmentedBar } from '#/components/segmented-bar' + +export const segmentedBarSpec: ComponentSpec = { + id: 'segmented-bar', + name: 'SegmentedBar', + description: + 'Part-to-whole composition strip paired with dot-swatch breakdown rows; hovering a segment or row dims sibling segments via @layer components.', + descriptionZh: + '部分占整体的多段构成条与圆点明细行:悬停任一分段或行时联动弱化其余项(交互样式归口于 @layer components)。', + controls: [ + { kind: 'string', key: 'title', label: 'Title', default: 'Memory footprint' }, + { kind: 'boolean', key: 'showPercent', label: 'Show percent', default: true }, + { kind: 'number', key: 'total', label: 'Total cap (0 = sum)', default: 0, min: 0, max: 64 }, + ], + examples: [ + { + name: 'With unallocated headroom', + nameZh: '带剩余容量上限', + note: 'Passing total larger than the item sum leaves neutral track space on the right.', + noteZh: '传入大于各段之和的 total 时,右侧自动留出未占用底槽。', + state: { title: '48 GiB card allocation', total: 48, showPercent: true }, + }, + ], + render: state => + h(SegmentedBar, { + class: 'w-full max-w-96', + title: String(state.title), + unit: 'GiB', + showPercent: Boolean(state.showPercent), + total: Number(state.total) > 0 ? Number(state.total) : undefined, + items: [ + { label: 'Model weights', value: 18, tone: 'blue' }, + { label: 'KV cache', value: 12, tone: 'teal' }, + { label: 'Runtime overhead', value: 4, tone: 'amber' }, + ], + }), + usage: `Use SegmentedBar when 2–6 parts add up to a meaningful whole (memory, storage, cost, or token share). + +- Keep segment count ≤ 6 so swatches remain distinguishable at a glance. +- Pass total when comparing used slices against a fixed capacity ceiling.`, + usageZh: `当 2–6 个部分合成为一个整体(显存、存储、费用或配额构成)时使用 SegmentedBar。 + +- 分段数控制在 6 段以内,保证色点与比例一眼可辨。 +- 需要对照固定容量上限展示剩余空间时传入 total。`, +} diff --git a/showcase/specs/status-list.ts b/showcase/specs/status-list.ts new file mode 100644 index 0000000..5716b8d --- /dev/null +++ b/showcase/specs/status-list.ts @@ -0,0 +1,34 @@ +import type { ComponentSpec } from '../lib/spec' +import { h } from 'vue' +import { StatusList, statusListStateKeys } from '#/components/status-list' + +export const statusListSpec: ComponentSpec = { + id: 'status-list', + name: 'StatusList', + description: + 'Compact check or compatibility rows with rationed signal icons, accessible status labels, optional secondary metadata, and tabular right-aligned results.', + descriptionZh: + '带语义状态图标、无障碍状态读音、可选辅助说明与右侧等宽结果的紧凑检查列表。', + controls: [ + { kind: 'string', key: 'title', label: 'Title', default: 'Node compatibility' }, + { kind: 'boolean', key: 'divided', label: 'Divided', default: true }, + { kind: 'enum', key: 'firstStatus', label: 'First row status', options: statusListStateKeys, default: 'error' }, + ], + render: state => + h(StatusList, { + class: 'w-full max-w-96', + title: String(state.title), + divided: Boolean(state.divided), + items: [ + { label: '24 GiB single card', sub: 'Entry workstation', meta: '$0.80/h', status: state.firstStatus as never, value: state.firstStatus === 'error' ? 'Insufficient' : 'Checked' }, + { label: '48 GiB single card', sub: 'Production baseline', meta: '$1.95/h', status: 'ok', value: 'Fits cleanly' }, + { label: '80 GiB high-bandwidth', meta: '$2.50/h', status: 'info', value: 'Headroom available' }, + ], + }), + usage: `Use StatusList for read-only pass/warn/error checks, preflight diagnostics, or compact key-value summaries. + +- Do not use StatusList for interactive settings rows with switches or inputs — use SettingsRow inside SettingsSection or SettingsList instead.`, + usageZh: `用 StatusList 展示只读的通过/告警/失败检查项、前置诊断或紧凑键值摘要。 + +- 右侧带开关、下拉或按钮的可交互设置行请使用 SettingsSection / SettingsList 配合 SettingsRow,不要混用。`, +} diff --git a/showcase/specs/steps.ts b/showcase/specs/steps.ts new file mode 100644 index 0000000..a294df0 --- /dev/null +++ b/showcase/specs/steps.ts @@ -0,0 +1,28 @@ +import type { ComponentSpec } from '../lib/spec' +import { h } from 'vue' +import { Steps, stepStatusKeys } from '#/components/steps' + +export const stepsSpec: ComponentSpec = { + id: 'steps', + name: 'Steps', + description: + 'Vertical numbered and status step rail for linear rollouts, migrations, and operating procedures.', + descriptionZh: + '用于线性发布流程、数据迁移与操作指引的纵向编号状态步骤流。', + controls: [ + { kind: 'string', key: 'title', label: 'Title', default: 'Rollout sequence' }, + { kind: 'enum', key: 'middleStatus', label: 'Step 2 status', options: stepStatusKeys, default: 'current', display: 'segmented' }, + ], + render: state => + h(Steps, { + class: 'w-full max-w-96', + title: String(state.title), + items: [ + { title: 'Dual-write shadow traffic', badge: '10 min', status: 'done', description: 'Mirror writes while keeping reads on the primary table.' }, + { title: 'Verify partition checksums', badge: '25 min', status: state.middleStatus as never, description: 'Confirm zero row drift across historical shards.' }, + { title: 'Switch read traffic', badge: '5 min', status: 'upcoming', description: 'Retain previous table read-only for 24h rollback.' }, + ], + }), + usage: `Use Steps to communicate ordered stages and their current state. Keep descriptions to one concise sentence per step.`, + usageZh: `用 Steps 呈现有先后顺序的阶段及其当前状态。每步说明保持在一句简短正文以内。`, +} diff --git a/src/components/bar-list/BarList.vue b/src/components/bar-list/BarList.vue index a79735a..10fd294 100644 --- a/src/components/bar-list/BarList.vue +++ b/src/components/bar-list/BarList.vue @@ -1,3 +1,8 @@ + + + +