feat: migrate Modal Popover and Tooltip with shared overlay foundation

This commit is contained in:
maoyingjie
2026-10-22 23:39:51 +08:00
parent b086d7f30d
commit 2b4ac04df1
108 changed files with 6888 additions and 100 deletions
+66
View File
@@ -0,0 +1,66 @@
<script setup lang="ts">
import { ref } from "vue";
import {
Button,
Modal,
ModalBackdrop,
ModalContainer,
ModalDialog,
ModalCloseTrigger,
ModalHeader,
ModalHeading,
ModalBody,
ModalFooter,
ModalClose,
} from "@heroui-vue/components";
const portalContainer = ref<HTMLElement>();
</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="portalContainer"
class="relative flex h-[380px] items-center justify-center overflow-hidden rounded bg-muted/20"
style="transform: translate(0)"
>
<Modal v-if="portalContainer">
<Button>打开模态框</Button>
<ModalBackdrop :to="portalContainer" class="h-full">
<ModalContainer class="h-full max-h-full">
<ModalDialog class="h-full max-h-full sm:max-w-md">
<ModalCloseTrigger />
<ModalHeader>
<ModalHeading>自定义 Portal</ModalHeading>
</ModalHeader>
<ModalBody>
<p v-for="i in 3" :key="i" class="text-sm text-muted">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Ut enim ad minim veniam, quis nostrud exercitation ullamco
laboris nisi ut aliquip ex ea commodo consequat.
</p>
</ModalBody>
<ModalFooter>
<ModalClose as-child>
<Button variant="secondary">关闭</Button>
</ModalClose>
</ModalFooter>
</ModalDialog>
</ModalContainer>
</ModalBackdrop>
</Modal>
</div>
</div>
</template>