Notification Stack
将紧凑通知堆叠展开为可以逐条阅读的条目。
适用场景
- 当界面需要以下行为时使用 Notification Stack:将紧凑通知堆叠展开为可以逐条阅读的条目。
安装
选择安装方式,用法示例将同步更新导入路径。
$ bunx --bun shadcn-vue@2.8.2 add https://orvui.efu.me/r/notification-stack.json
首次使用时,将安装的 src/components/orvui/styles.css 导入项目样式入口。
示例
预览
packages/vue/src/blocks/notification-stack/demo.vue
<script setup lang="ts">
import { h } from "vue";
import { RotateCw } from "lucide-vue-next";
import { NotificationStack, type NotificationStackItem } from "@/components/orvui/blocks/notification-stack";
const notices = [
[
"catalog-retry",
"Catalog refresh paused",
"42s · Gateway timeout in phase 2",
],
["queue-delay", "Queue delay", "2m 11s · Sample indexing"],
["media-restored", "Media preview recovered", "5m · Missing file in /media"],
] as const;
const items: NotificationStackItem[] = notices.map(
([id, title, description], index) => ({
id,
title,
description,
...(index === 0
? {
trailing: () =>
h(
"span",
{
class:
"inline-flex items-center gap-1 text-amber-500 dark:text-amber-400",
},
[h(RotateCw, { class: "h-3.5 w-3.5", "aria-hidden": true }), "2"],
),
}
: {}),
}),
);
</script>
<template>
<div class="flex w-full items-center justify-center pt-52 pb-6">
<NotificationStack :items="items" />
</div>
</template>
packages/vue/src/blocks/notification-stack/src/NotificationStack.vue
状态与事件
需要由表单、路由或父组件管理时,绑定下列状态并接收对应更新。v-model 是属性与 update 事件的简写;值的类型应与 API 一致。
| 组件 | Vue 绑定 | 更新事件 |
|---|---|---|
NotificationStack | v-model:expandedboolean | update:expanded |
可选受控属性未传入时,按组件文档的默认行为工作;不要用固定的 false 或空值代替未传入。异步请求和持久化在应用中处理,再把结果传回组件。
API 参考
itemsNotificationStackItem[]—expanded?booleanundefineddefaultExpanded?booleanfalsemaxVisible?number3collapsedLabel?string"Notifications"expandedLabel?string"View all"emptyLabel?string"All caught up"classNames?NotificationStackClassNames—事件
update:expanded[expanded: boolean]@update:expandedexpandedChange[expanded: boolean]@expandedChangeviewAll[]@viewAll无障碍
为交互控件提供明确的无障碍名称。保留文档中的键盘路径、可见焦点与减少动态效果状态;自定义插槽应继续保留所替代部件的语义。
常见问题
- 如何配置 Notification Stack?
- 通过 items、expanded、defaultExpanded、maxVisible、collapsedLabel、expandedLabel、emptyLabel、classNames 配置 Notification Stack;API 表列出其类型与默认值。
- 如何连接到应用状态?
- 监听 update:expanded、expandedChange、viewAll,将组件连接到应用状态。
- 可以在服务端渲染吗?
- 可以在 Vue SSR 应用中正常渲染。服务端与客户端的初始 props 应保持一致;浏览器测量与交互资源在挂载后启动。
请留意
部分组件参考了开源作品,相关署名与独立许可请参阅 NOTICE。
更新于
来源与许可 ↗MIT · 0.1.1