Files
heroui-vue/apps/docs/demos/popover-interactive.vue

82 lines
2.6 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 { ref } from "vue";
import {
Avatar,
AvatarFallback,
AvatarImage,
Button,
Popover,
PopoverContent,
PopoverDialog,
PopoverHeading,
PopoverTrigger,
} from "@heroui-vue/components";
const isFollowing = ref(false);
function setIsFollowing(value: boolean) {
isFollowing.value = value;
}
</script>
<template>
<div class="flex items-center gap-6">
<Popover>
<PopoverTrigger aria-label="用户资料">
<div class="flex items-center gap-2">
<Avatar size="sm">
<AvatarImage
alt="Sarah Johnson"
src="https://img.heroui.chat/image/avatar?w=400&amp;h=400&amp;u=1"
></AvatarImage>
<AvatarFallback>SJ</AvatarFallback>
</Avatar>
<div class="flex flex-col">
<p class="text-sm font-medium">Sarah Johnson</p>
<p class="text-xs text-muted">@sarahj</p>
</div>
</div>
</PopoverTrigger>
<PopoverContent class="w-[320px]">
<PopoverDialog>
<PopoverHeading>
<div class="flex items-center justify-between">
<div class="flex items-center gap-3">
<Avatar size="md">
<AvatarImage
alt="Sarah Johnson"
src="https://img.heroui.chat/image/avatar?w=400&amp;h=400&amp;u=1"
></AvatarImage>
<AvatarFallback>SJ</AvatarFallback>
</Avatar>
<div>
<p class="font-semibold">Sarah Johnson</p>
<p class="text-sm text-muted">@sarahj</p>
</div>
</div>
<Button
class="rounded-full"
size="sm"
:variant="isFollowing ? 'tertiary' : 'primary'"
@click="setIsFollowing(!isFollowing)"
>
{{ isFollowing ? "已关注" : "关注" }}
</Button>
</div>
</PopoverHeading>
<p class="mt-3 text-sm text-muted">
产品设计师兼创意总监,打造有意义的美好体验。
</p>
<div class="mt-3 flex gap-4">
<div>
<span class="font-semibold">892</span>
<span class="ms-1 text-sm text-muted">关注中</span>
</div>
<div>
<span class="font-semibold">12.5K</span>
<span class="ms-1 text-sm text-muted">粉丝</span>
</div>
</div>
</PopoverDialog>
</PopoverContent>
</Popover>
</div>
</template>