feat(KAN-18): redesign foundational UI components
This commit is contained in:
@@ -1,41 +1,39 @@
|
||||
<script setup lang="ts">
|
||||
import { getInitials } from "@/composables/useInitials";
|
||||
import {
|
||||
Avatar,
|
||||
AvatarFallback,
|
||||
AvatarImage,
|
||||
} from "@/components/ui/avatar/index";
|
||||
import type { AvatarVariants } from "@/components/ui/avatar";
|
||||
import type { UserModel } from "@/types/models/user-model";
|
||||
import { usePage } from "@inertiajs/vue3";
|
||||
import { computed, PropType } from "vue";
|
||||
import { UserModel } from "@/types/models/user-model";
|
||||
import { computed } from "vue";
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
|
||||
import { getInitials } from "@/composables/useInitials";
|
||||
|
||||
const props = defineProps({
|
||||
user: {
|
||||
type: Object as PropType<UserModel>,
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
user?: UserModel;
|
||||
rounded?: boolean;
|
||||
size?: AvatarVariants["size"];
|
||||
label?: string;
|
||||
}>(),
|
||||
{
|
||||
rounded: true,
|
||||
size: "default",
|
||||
},
|
||||
rounded: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
})
|
||||
);
|
||||
|
||||
const page = usePage();
|
||||
const auth = computed(() => page.props.auth);
|
||||
|
||||
const user = computed(() => props.user ?? auth.value.user)
|
||||
const user = computed(() => props.user ?? page.props.auth.user);
|
||||
const accessibleLabel = computed(() => props.label ?? user.value.name);
|
||||
const initials = computed(() => getInitials(user.value.name));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Avatar class="size-8 overflow-hidden" :class="rounded ? 'rounded-full' : 'rounded-lg'">
|
||||
<Avatar :size="size" :shape="rounded ? 'circle' : 'rounded'">
|
||||
<AvatarImage
|
||||
v-if="user.avatar"
|
||||
:src="user.avatar"
|
||||
:alt="user.name"
|
||||
:alt="accessibleLabel"
|
||||
/>
|
||||
<AvatarFallback
|
||||
class="rounded-lg bg-neutral-200 font-semibold text-black dark:bg-neutral-700 dark:text-white"
|
||||
>
|
||||
{{ getInitials(auth.user?.name) }}
|
||||
<AvatarFallback :aria-label="accessibleLabel">
|
||||
{{ initials }}
|
||||
</AvatarFallback>
|
||||
</Avatar>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user