feat: add CloseButton Avatar and Skeleton components
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, useAttrs } from "vue";
|
||||
import { avatarGroupVariants, type AvatarVariants } from "@heroui-vue/styles";
|
||||
import Avatar from "./Avatar.vue";
|
||||
import AvatarFallback from "./AvatarFallback.vue";
|
||||
import { avatarGroupContextKey } from "./context";
|
||||
|
||||
defineOptions({
|
||||
inheritAttrs: false,
|
||||
name: "AvatarGroupCount",
|
||||
});
|
||||
|
||||
const props = defineProps<{
|
||||
color?: AvatarVariants["color"];
|
||||
size?: AvatarVariants["size"];
|
||||
variant?: AvatarVariants["variant"];
|
||||
}>();
|
||||
|
||||
const attrs = useAttrs();
|
||||
const group = inject(avatarGroupContextKey, undefined);
|
||||
|
||||
const finalSize = computed(() => props.size ?? group?.value.size);
|
||||
const finalColor = computed(() => props.color ?? group?.value.color);
|
||||
const finalVariant = computed(() => props.variant ?? group?.value.variant);
|
||||
|
||||
// Built during render (not cached): key additions/removals on $attrs must not
|
||||
// depend on computed invalidation of an initially empty key set.
|
||||
function restAttrs() {
|
||||
const rest: Record<string, unknown> = {};
|
||||
for (const key of Object.keys(attrs)) {
|
||||
if (key !== "class") rest[key] = attrs[key];
|
||||
}
|
||||
return rest;
|
||||
}
|
||||
|
||||
function countClass() {
|
||||
const base = group?.value.countClass ?? avatarGroupVariants().count();
|
||||
return [base, attrs.class];
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Avatar
|
||||
v-bind="restAttrs()"
|
||||
:color="finalColor"
|
||||
:size="finalSize"
|
||||
:variant="finalVariant"
|
||||
:__avatar_group_child="true"
|
||||
:class="countClass()"
|
||||
data-slot="avatar-group-count"
|
||||
>
|
||||
<AvatarFallback>
|
||||
<slot />
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
</template>
|
||||
Reference in New Issue
Block a user