116 lines
3.7 KiB
Vue
116 lines
3.7 KiB
Vue
<script setup lang="ts">
|
|
import type { Component } from "vue";
|
|
import {
|
|
Button,
|
|
Modal,
|
|
ModalBackdrop,
|
|
ModalBody,
|
|
ModalClose,
|
|
ModalCloseTrigger,
|
|
ModalContainer,
|
|
ModalDialog,
|
|
ModalFooter,
|
|
ModalHeader,
|
|
ModalHeading,
|
|
ModalIcon,
|
|
} from "@heroui-vue/components";
|
|
import {
|
|
IconSparkles as Sparkles,
|
|
IconArrowBarUp as ArrowUpFromLine,
|
|
} from "@tabler/icons-vue";
|
|
const iconMap: Record<string, Component> = {
|
|
"tabler:arrow-bar-up": ArrowUpFromLine,
|
|
"tabler:sparkles": Sparkles,
|
|
};
|
|
const animations = [
|
|
{
|
|
classNames: {
|
|
backdrop: [
|
|
"data-[entering]:duration-400",
|
|
"data-[entering]:ease-[cubic-bezier(0.16,1,0.3,1)]",
|
|
"data-[exiting]:duration-200",
|
|
"data-[exiting]:ease-[cubic-bezier(0.7,0,0.84,0)]",
|
|
].join(" "),
|
|
container: [
|
|
"data-[entering]:animate-in",
|
|
"data-[entering]:fade-in-0",
|
|
"data-[entering]:zoom-in-95",
|
|
"data-[entering]:duration-400",
|
|
"data-[entering]:ease-[cubic-bezier(0.16,1,0.3,1)]",
|
|
"data-[exiting]:animate-out",
|
|
"data-[exiting]:fade-out-0",
|
|
"data-[exiting]:zoom-out-95",
|
|
"data-[exiting]:duration-200",
|
|
"data-[exiting]:ease-[cubic-bezier(0.7,0,0.84,0)]",
|
|
].join(" "),
|
|
},
|
|
description:
|
|
"基于物理的弹性缩放,模拟高阻尼弹簧系统:快速瞬态响应与较长 settling 时间。适用于模态框与弹出层。",
|
|
icon: "tabler:sparkles",
|
|
name: "运动缩放",
|
|
},
|
|
{
|
|
classNames: {
|
|
backdrop: [
|
|
"data-[entering]:duration-500",
|
|
"data-[entering]:ease-[cubic-bezier(0.25,1,0.5,1)]",
|
|
"data-[exiting]:duration-200",
|
|
"data-[exiting]:ease-[cubic-bezier(0.5,0,0.75,0)]",
|
|
].join(" "),
|
|
container: [
|
|
"data-[entering]:animate-in",
|
|
"data-[entering]:fade-in-0",
|
|
"data-[entering]:slide-in-from-bottom-4",
|
|
"data-[entering]:duration-500",
|
|
"data-[entering]:ease-[cubic-bezier(0.25,1,0.5,1)]",
|
|
"data-[exiting]:animate-out",
|
|
"data-[exiting]:fade-out-0",
|
|
"data-[exiting]:slide-out-to-bottom-2",
|
|
"data-[exiting]:duration-200",
|
|
"data-[exiting]:ease-[cubic-bezier(0.5,0,0.75,0)]",
|
|
].join(" "),
|
|
},
|
|
description:
|
|
"模拟流体阻力中的运动,摆脱机械式线性动画,呈现更自然、沉稳的质感。适用于底部抽屉或 Toast。",
|
|
icon: "tabler:arrow-bar-up",
|
|
name: "流体滑入",
|
|
},
|
|
];
|
|
</script>
|
|
<template>
|
|
<div class="flex flex-wrap gap-4">
|
|
<template
|
|
v-for="{ classNames, description, icon, name } in animations"
|
|
:key="name"
|
|
>
|
|
<Modal>
|
|
<Button variant="secondary">{{ name }}</Button>
|
|
<ModalBackdrop :class="classNames.backdrop">
|
|
<ModalContainer :class="classNames.container">
|
|
<ModalDialog class="sm:max-w-[360px]">
|
|
<ModalCloseTrigger></ModalCloseTrigger>
|
|
<ModalHeader>
|
|
<ModalIcon class="bg-default text-foreground">
|
|
<template v-if="!!iconMap[icon]">
|
|
<component :is="iconMap[icon]" class="size-5"></component>
|
|
</template>
|
|
</ModalIcon>
|
|
<ModalHeading>{{ name }} 动画</ModalHeading>
|
|
</ModalHeader>
|
|
<ModalBody>
|
|
<p class="mt-1">{{ description }}</p>
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
<ModalClose as-child>
|
|
<Button variant="tertiary">关闭</Button>
|
|
</ModalClose>
|
|
<ModalClose as-child><Button>再试一次</Button></ModalClose>
|
|
</ModalFooter>
|
|
</ModalDialog>
|
|
</ModalContainer>
|
|
</ModalBackdrop>
|
|
</Modal>
|
|
</template>
|
|
</div>
|
|
</template>
|