feat: add CloseButton Avatar and Skeleton components

This commit is contained in:
maoyingjie
2026-10-21 17:06:53 +08:00
parent 56b1ef11d8
commit 3d05fea7bd
60 changed files with 3906 additions and 57 deletions
@@ -0,0 +1,46 @@
<script setup lang="ts">
import { inject, useAttrs } from "vue";
import { AvatarFallback } from "reka-ui";
import { avatarVariants, type AvatarVariants } from "@heroui-vue/styles";
import { avatarContextKey } from "./context";
defineOptions({ inheritAttrs: false });
const props = defineProps<{
delayMs?: number;
color?: AvatarVariants["color"];
}>();
const attrs = useAttrs();
const ctx = inject(avatarContextKey, undefined);
// 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;
}
// Single tv slot call so a local `color` replaces the inherited variant
// instead of concatenating a second `--color` class (upstream composeSlotClassName).
function fallbackClass() {
const slotArgs: Record<string, unknown> = { class: attrs.class };
if (props.color !== undefined) slotArgs.color = props.color;
const slot = ctx?.slots.value.fallback ?? avatarVariants().fallback;
return slot(slotArgs);
}
</script>
<template>
<AvatarFallback
v-bind="restAttrs()"
:delay-ms="delayMs"
:class="fallbackClass()"
data-slot="avatar-fallback"
>
<slot />
</AvatarFallback>
</template>