Status Bar
在按比例分段的条形图中汇总各命名状态的数量。
适用场景
- 当界面需要以下行为时使用 Status Bar:在按比例分段的条形图中汇总各命名状态的数量。
安装
选择安装方式,用法示例将同步更新导入路径。
$ bunx --bun shadcn-vue@2.8.2 add https://orvui.efu.me/r/status-bar.json https://orvui.efu.me/r/button.json
首次使用时,将安装的 src/components/orvui/styles.css 导入项目样式入口。
示例
预览
48 days of status
APIOperational
Aug 21Oct 7
| Period | Status | Description |
|---|---|---|
| Aug 21 | Operational | All checks passed. |
| Aug 22 | Operational | All checks passed. |
| Aug 23 | Operational | All checks passed. |
| Aug 24 | Operational | All checks passed. |
| Aug 25 | Operational | All checks passed. |
| Aug 26 | Operational | All checks passed. |
| Aug 27 | Operational | All checks passed. |
| Aug 28 | Operational | All checks passed. |
| Aug 29 | Degraded | Elevated response times for 12 minutes. |
| Aug 30 | Operational | All checks passed. |
| Aug 31 | Operational | All checks passed. |
| Sep 1 | Operational | All checks passed. |
| Sep 2 | Operational | All checks passed. |
| Sep 3 | Operational | All checks passed. |
| Sep 4 | Operational | All checks passed. |
| Sep 5 | Operational | All checks passed. |
| Sep 6 | Operational | All checks passed. |
| Sep 7 | Operational | All checks passed. |
| Sep 8 | Operational | All checks passed. |
| Sep 9 | Operational | All checks passed. |
| Sep 10 | Operational | All checks passed. |
| Sep 11 | Operational | All checks passed. |
| Sep 12 | Operational | All checks passed. |
| Sep 13 | Operational | All checks passed. |
| Sep 14 | Operational | All checks passed. |
| Sep 15 | Operational | All checks passed. |
| Sep 16 | Operational | All checks passed. |
| Sep 17 | Operational | All checks passed. |
| Sep 18 | Operational | All checks passed. |
| Sep 19 | Operational | All checks passed. |
| Sep 20 | Operational | All checks passed. |
| Sep 21 | Operational | All checks passed. |
| Sep 22 | Operational | All checks passed. |
| Sep 23 | Operational | All checks passed. |
| Sep 24 | Operational | All checks passed. |
| Sep 25 | Operational | All checks passed. |
| Sep 26 | Operational | All checks passed. |
| Sep 27 | Operational | All checks passed. |
| Sep 28 | Operational | All checks passed. |
| Sep 29 | Operational | All checks passed. |
| Sep 30 | Operational | All checks passed. |
| Oct 1 | Operational | All checks passed. |
| Oct 2 | Operational | All checks passed. |
| Oct 3 | Operational | All checks passed. |
| Oct 4 | Operational | All checks passed. |
| Oct 5 | Operational | All checks passed. |
| Oct 6 | Operational | All checks passed. |
| Oct 7 | Operational | All checks passed. |
WebsiteOperational
Aug 21Oct 7
- Operational
- Degraded
- Outage
| Period | Status | Description |
|---|---|---|
| Aug 21 | Operational | All checks passed. |
| Aug 22 | Operational | All checks passed. |
| Aug 23 | Operational | All checks passed. |
| Aug 24 | Operational | All checks passed. |
| Aug 25 | Operational | All checks passed. |
| Aug 26 | Operational | All checks passed. |
| Aug 27 | Operational | All checks passed. |
| Aug 28 | Operational | All checks passed. |
| Aug 29 | Operational | All checks passed. |
| Aug 30 | Operational | All checks passed. |
| Aug 31 | Operational | All checks passed. |
| Sep 1 | Operational | All checks passed. |
| Sep 2 | Operational | All checks passed. |
| Sep 3 | Operational | All checks passed. |
| Sep 4 | Operational | All checks passed. |
| Sep 5 | Operational | All checks passed. |
| Sep 6 | Operational | All checks passed. |
| Sep 7 | Operational | All checks passed. |
| Sep 8 | Operational | All checks passed. |
| Sep 9 | Operational | All checks passed. |
| Sep 10 | Operational | All checks passed. |
| Sep 11 | Operational | All checks passed. |
| Sep 12 | Operational | All checks passed. |
| Sep 13 | Operational | All checks passed. |
| Sep 14 | Operational | All checks passed. |
| Sep 15 | Operational | All checks passed. |
| Sep 16 | Operational | All checks passed. |
| Sep 17 | Operational | All checks passed. |
| Sep 18 | Operational | All checks passed. |
| Sep 19 | Operational | All checks passed. |
| Sep 20 | Operational | All checks passed. |
| Sep 21 | Operational | All checks passed. |
| Sep 22 | Operational | All checks passed. |
| Sep 23 | Operational | All checks passed. |
| Sep 24 | Operational | All checks passed. |
| Sep 25 | Operational | All checks passed. |
| Sep 26 | Operational | All checks passed. |
| Sep 27 | Operational | All checks passed. |
| Sep 28 | Operational | All checks passed. |
| Sep 29 | Operational | All checks passed. |
| Sep 30 | Operational | All checks passed. |
| Oct 1 | Operational | All checks passed. |
| Oct 2 | Operational | All checks passed. |
| Oct 3 | Operational | All checks passed. |
| Oct 4 | Operational | All checks passed. |
| Oct 5 | Operational | All checks passed. |
| Oct 6 | Operational | All checks passed. |
| Oct 7 | Operational | All checks passed. |
packages/vue/src/charts/status-bar/demo.vue
<script setup lang="ts">
import { computed, ref } from "vue";
import {
StatusBar,
StatusBarPlot,
StatusBarTooltip,
StatusBarLegend,
STATUS_BAR_STATUSES,
type StatusBarDatum,
} from "@/components/orvui/charts/status-bar";
import { Button } from "@/components/orvui/motion/button";
const dateLabel = new Intl.DateTimeFormat("en", {
month: "short",
day: "numeric",
timeZone: "UTC",
});
const history: readonly StatusBarDatum[] = Array.from(
{ length: 48 },
(_, index) => {
const date = new Date(Date.UTC(2026, 7, 21 + index));
const degraded = index === 8;
return {
id: date.toISOString().slice(0, 10),
label: dateLabel.format(date),
status: degraded ? "degraded" : "operational",
description: degraded
? "Elevated response times for 12 minutes."
: "All checks passed.",
};
},
);
const website = history.map((period) => ({
...period,
status: "operational",
description: "All checks passed.",
}));
const statuses = STATUS_BAR_STATUSES.slice(0, 3);
const incident = ref(false);
const replay = ref(0);
const api = computed(() =>
history.map((period, index) => {
if (!incident.value || index < 45) return period;
return {
...period,
status: index === 46 ? "outage" : "degraded",
description:
index === 46
? "Requests failed for 4 minutes."
: "Elevated response times.",
};
}),
);
</script>
<template>
<div class="w-full max-w-2xl space-y-6">
<div class="flex flex-wrap items-center justify-between gap-3">
<span class="text-sm text-muted-foreground">48 days of status</span>
<div class="flex gap-1">
<Button variant="ghost" size="sm" tabindex="0" @click="replay++"
>Replay</Button
><Button
variant="ghost"
size="sm"
tabindex="0"
@click="incident = !incident"
>{{ incident ? "Resolve incident" : "Simulate incident" }}</Button
>
</div>
</div>
<StatusBar
:key="'api-' + replay"
:data="api"
:statuses="statuses"
label="API status"
>
<div class="flex items-center justify-between text-sm">
<span class="font-medium">API</span
><span class="text-muted-foreground">{{
incident ? "Degraded" : "Operational"
}}</span>
</div>
<StatusBarPlot /><StatusBarTooltip />
</StatusBar>
<StatusBar
:key="'website-' + replay"
class="border-t border-border pt-6"
:data="website"
:statuses="statuses"
label="Website status"
>
<div class="flex items-center justify-between text-sm">
<span class="font-medium">Website</span
><span class="text-muted-foreground">Operational</span>
</div>
<StatusBarPlot /><StatusBarLegend class="pt-2" /><StatusBarTooltip />
</StatusBar>
</div>
</template>
packages/vue/src/charts/status-bar/src/StatusBar.vue
状态与事件
需要由表单、路由或父组件管理时,绑定下列状态并接收对应更新。v-model 是属性与 update 事件的简写;值的类型应与 API 一致。
| 组件 | Vue 绑定 | 更新事件 |
|---|---|---|
StatusBar | v-model:activeIdnull | string | update:activeId |
可选受控属性未传入时,按组件文档的默认行为工作;不要用固定的 false 或空值代替未传入。异步请求和持久化在应用中处理,再把结果传回组件。
API 参考
StatusBar
datareadonly StatusBarDatum[]—statuses?readonly StatusBarStatus[]STATUS_BAR_STATUSESlabel?string"Status history"activeId?null | string—defaultActiveId?null | stringnullclassName?string—事件
update:activeId—@update:activeIdactiveChange—@activeChange插槽
default() => VNodeChild#defaultStatusBarPlot
barClassName?string—showLabels?booleantrue插槽
default() => VNodeChild#defaultStatusBarTooltip
side?"top" | "bottom" | "left" | "right""top"插槽
default—作用域参数: datum, status
#defaultStatusBarLegend
showCounts?booleanfalse插槽
default() => VNodeChild#default无障碍
为交互控件提供明确的无障碍名称。保留文档中的键盘路径、可见焦点与减少动态效果状态;自定义插槽应继续保留所替代部件的语义。
常见问题
- 如何配置 Status Bar?
- 通过 data、statuses、label、activeId、defaultActiveId、className 配置 Status Bar;API 表列出其类型与默认值。
- 如何连接到应用状态?
- 监听 update:activeId、activeChange,将组件连接到应用状态。
- 可以在服务端渲染吗?
- 可以在 Vue SSR 应用中正常渲染。服务端与客户端的初始 props 应保持一致;浏览器测量与交互资源在挂载后启动。
更新于
来源与许可 ↗MIT · 0.1.1