feat: add CloseButton Avatar and Skeleton components
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
<script setup lang="ts">
|
||||
import {
|
||||
Avatar,
|
||||
AvatarGroup,
|
||||
AvatarImage,
|
||||
AvatarFallback,
|
||||
} from "@heroui-vue/components";
|
||||
|
||||
const users = [
|
||||
{
|
||||
id: 1,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/blue.jpg",
|
||||
name: "张明",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/green.jpg",
|
||||
name: "李华",
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/purple.jpg",
|
||||
name: "王芳",
|
||||
},
|
||||
{
|
||||
id: 4,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/orange.jpg",
|
||||
name: "刘洋",
|
||||
},
|
||||
{
|
||||
id: 5,
|
||||
image:
|
||||
"https://heroui-assets.nyc3.cdn.digitaloceanspaces.com/avatars/red.jpg",
|
||||
name: "陈静",
|
||||
},
|
||||
];
|
||||
|
||||
function initialsFromName(name: string) {
|
||||
const parts = name.split(/\s+/).filter(Boolean);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
return parts.map((n) => n[0]).join("");
|
||||
}
|
||||
|
||||
return name.slice(0, 2);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<AvatarGroup>
|
||||
<Avatar v-for="user in users.slice(0, 4)" :key="user.id">
|
||||
<AvatarImage :alt="`${user.name} 的头像`" :src="user.image" />
|
||||
<AvatarFallback>{{ initialsFromName(user.name) }}</AvatarFallback>
|
||||
</Avatar>
|
||||
</AvatarGroup>
|
||||
</template>
|
||||
Reference in New Issue
Block a user