Files

77 lines
2.7 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<script setup lang="ts">
import {
Button,
Modal,
ModalBackdrop,
ModalBody,
ModalClose,
ModalCloseTrigger,
ModalContainer,
ModalDialog,
ModalFooter,
ModalHeader,
ModalHeading,
ModalIcon,
} from "@heroui-vue/components";
import { IconRocket as Rocket } from "@tabler/icons-vue";
const SIZE_LABELS = {
cover: "通栏",
full: "全屏",
lg: "大",
md: "中",
sm: "小",
xs: "超小",
} as const;
const sizes = ["xs", "sm", "md", "lg", "cover", "full"] as const;
</script>
<template>
<div class="flex flex-wrap gap-4">
<template v-for="size in sizes" :key="size">
<Modal>
<Button variant="secondary">{{ SIZE_LABELS[size] }}</Button>
<ModalBackdrop>
<ModalContainer :size="size">
<ModalDialog>
<ModalCloseTrigger></ModalCloseTrigger>
<ModalHeader>
<ModalIcon class="bg-default text-foreground">
<Rocket aria-hidden="true" class="size-5"></Rocket>
</ModalIcon>
<ModalHeading>尺寸:{{ SIZE_LABELS[size] }}</ModalHeading>
</ModalHeader>
<ModalBody>
<p>
<template v-if="size === 'cover'">
此模态框使用
<code>cover</code>
尺寸:在移动端与桌面端保留边距(移动端约 16px、桌面端约
40px)铺满可视区域,仍保持圆角与标准内边距,适合需要最大宽度又保留模态框气质的内容展示。
</template>
<template v-else>
<template v-if="size === 'full'">
此模态框使用
<code>full</code>
尺寸,占满整个视口,无边距、圆角或阴影,提供真正的全屏体验,适合沉浸式内容或全页交互。
</template>
<template v-else>
此模态框使用
<code>{{ size }}</code>
尺寸。在移动端各尺寸都会接近全宽以便阅读;在桌面端则对应不同的最大宽度,以适配不同信息量。
</template>
</template>
</p>
</ModalBody>
<ModalFooter>
<ModalClose as-child>
<Button variant="secondary">取消</Button>
</ModalClose>
<ModalClose as-child><Button>确认</Button></ModalClose>
</ModalFooter>
</ModalDialog>
</ModalContainer>
</ModalBackdrop>
</Modal>
</template>
</div>
</template>