feat: migrate Toast and Table with reviewed state focus and SSR contracts
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<script setup lang="ts">
|
||||
import { onBeforeUnmount } from "vue";
|
||||
import { Button, ToastProvider, ToastQueue } from "@heroui-vue/components";
|
||||
const notificationQueue = new ToastQueue({ maxVisibleToasts: 2 });
|
||||
const errorQueue = new ToastQueue({ maxVisibleToasts: 3 });
|
||||
const successQueue = new ToastQueue({ maxVisibleToasts: 1 });
|
||||
onBeforeUnmount(() =>
|
||||
[notificationQueue, errorQueue, successQueue].forEach((queue) =>
|
||||
queue.destroy(),
|
||||
),
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<div
|
||||
class="flex h-full max-w-4xl flex-wrap items-center justify-center gap-4"
|
||||
>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
@click="
|
||||
notificationQueue.add({
|
||||
title: '新通知',
|
||||
description: '您有一条新消息',
|
||||
variant: 'default',
|
||||
})
|
||||
"
|
||||
>
|
||||
添加通知(最多 2 条)
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="danger-soft"
|
||||
@click="
|
||||
errorQueue.add({
|
||||
title: '发生错误',
|
||||
description: '保存更改失败',
|
||||
variant: 'danger',
|
||||
})
|
||||
"
|
||||
>
|
||||
添加错误(最多 3 条)
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
class="text-success"
|
||||
@click="
|
||||
successQueue.add({
|
||||
title: '成功!',
|
||||
description: `操作 ${Date.now()}`,
|
||||
variant: 'success',
|
||||
})
|
||||
"
|
||||
>
|
||||
添加成功(最多 1 条)
|
||||
</Button>
|
||||
<ToastProvider :queue="notificationQueue" to="body" placement="bottom" />
|
||||
<ToastProvider :queue="errorQueue" to="body" placement="bottom start" />
|
||||
<ToastProvider :queue="successQueue" to="body" placement="bottom end" />
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user