feat: add CloseButton Avatar and Skeleton components
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<script setup lang="ts">
|
||||
import { Avatar, AvatarImage, AvatarFallback } from "@heroui-vue/components";
|
||||
import { IconUser } from "@tabler/icons-vue";
|
||||
|
||||
const colors = ["accent", "default", "success", "warning", "danger"] as const;
|
||||
|
||||
const COLOR_LABELS: Record<(typeof colors)[number], string> = {
|
||||
accent: "强调",
|
||||
danger: "危险",
|
||||
default: "默认",
|
||||
success: "成功",
|
||||
warning: "警告",
|
||||
};
|
||||
|
||||
const variants = [
|
||||
{ content: "AG", label: "字母", type: "letter" },
|
||||
{ content: "AG", label: "柔和字母", type: "letter-soft" },
|
||||
{ content: "icon", label: "图标", type: "icon" },
|
||||
{ content: "icon", label: "柔和图标", type: "icon-soft" },
|
||||
{
|
||||
content: [
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=3",
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=4",
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=5",
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=8",
|
||||
"https://img.heroui.chat/image/avatar?w=400&h=400&u=16",
|
||||
],
|
||||
label: "图片",
|
||||
type: "img",
|
||||
},
|
||||
] as const;
|
||||
</script>
|
||||
<template>
|
||||
<div class="flex flex-col gap-4">
|
||||
<!-- 颜色列标题 -->
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-24 shrink-0" />
|
||||
<div
|
||||
v-for="color in colors"
|
||||
:key="color"
|
||||
class="flex w-20 shrink-0 items-center justify-center"
|
||||
>
|
||||
<span class="text-xs text-muted">{{ COLOR_LABELS[color] }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="h-px w-full bg-separator" />
|
||||
|
||||
<!-- 变体行 -->
|
||||
<div
|
||||
v-for="variant in variants"
|
||||
:key="variant.label"
|
||||
class="flex items-center gap-3"
|
||||
>
|
||||
<div class="w-24 shrink-0 text-sm text-muted">{{ variant.label }}</div>
|
||||
<div
|
||||
v-for="(color, colorIndex) in colors"
|
||||
:key="color"
|
||||
class="flex w-20 shrink-0 items-center justify-center"
|
||||
>
|
||||
<Avatar
|
||||
:color="color"
|
||||
:variant="variant.type.includes('soft') ? 'soft' : undefined"
|
||||
>
|
||||
<template v-if="variant.type === 'img'">
|
||||
<AvatarImage
|
||||
:alt="`${COLOR_LABELS[color]} 头像`"
|
||||
:src="
|
||||
Array.isArray(variant.content)
|
||||
? variant.content[colorIndex]
|
||||
: ''
|
||||
"
|
||||
/>
|
||||
<AvatarFallback>{{ COLOR_LABELS[color].charAt(0) }}</AvatarFallback>
|
||||
</template>
|
||||
<AvatarFallback v-else-if="variant.content === 'icon'">
|
||||
<IconUser aria-hidden="true" class="size-4 shrink-0" />
|
||||
</AvatarFallback>
|
||||
<AvatarFallback v-else>{{ variant.content }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user