feat: migrate AlertDialog and Drawer with reviewed overlay lifecycles
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from "vue";
|
||||
import {
|
||||
AlertDialog,
|
||||
AlertDialogBackdrop,
|
||||
AlertDialogBody,
|
||||
AlertDialogClose,
|
||||
AlertDialogCloseTrigger,
|
||||
AlertDialogContainer,
|
||||
AlertDialogDialog,
|
||||
AlertDialogFooter,
|
||||
AlertDialogHeader,
|
||||
AlertDialogHeading,
|
||||
AlertDialogIcon,
|
||||
Button,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const portalEl = ref<HTMLElement | null>(null);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div>
|
||||
<p class="text-sm">
|
||||
将警告对话框渲染到自定义容器,而不是
|
||||
<code>document.body</code>
|
||||
</p>
|
||||
<p class="text-sm text-muted">
|
||||
为容器应用
|
||||
<code class="rounded px-1 py-0.5 text-xs">
|
||||
transform: translateZ(0)
|
||||
</code>
|
||||
可创建新的层叠上下文。
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
ref="portalEl"
|
||||
class="relative flex h-[380px] items-center justify-center overflow-hidden rounded bg-muted/20"
|
||||
style="transform: translate(0)"
|
||||
>
|
||||
<AlertDialog v-if="portalEl">
|
||||
<Button>打开警告对话框</Button>
|
||||
<AlertDialogBackdrop class="h-full" :to="portalEl">
|
||||
<AlertDialogContainer class="h-full max-h-full">
|
||||
<AlertDialogDialog class="h-full max-h-full sm:max-w-md">
|
||||
<AlertDialogCloseTrigger />
|
||||
<AlertDialogHeader>
|
||||
<AlertDialogIcon status="accent" />
|
||||
<AlertDialogHeading>自定义传送门</AlertDialogHeading>
|
||||
</AlertDialogHeader>
|
||||
<AlertDialogBody>
|
||||
<p class="text-sm text-muted">
|
||||
此段为示例占位文案,用于演示在自定义容器内渲染对话框时的滚动与排版效果。
|
||||
</p>
|
||||
<p class="text-sm text-muted">
|
||||
通过将浮层挂载到局部容器,可以配合裁剪、缩放或卡片布局,避免遮挡整个页面。
|
||||
</p>
|
||||
</AlertDialogBody>
|
||||
<AlertDialogFooter>
|
||||
<AlertDialogClose as-child>
|
||||
<Button variant="tertiary">取消</Button>
|
||||
</AlertDialogClose>
|
||||
<AlertDialogClose as-child>
|
||||
<Button>确认</Button>
|
||||
</AlertDialogClose>
|
||||
</AlertDialogFooter>
|
||||
</AlertDialogDialog>
|
||||
</AlertDialogContainer>
|
||||
</AlertDialogBackdrop>
|
||||
</AlertDialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user