-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathAvatarImage.vue
32 lines (27 loc) · 934 Bytes
/
AvatarImage.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<script setup lang="ts">
import type { EmitsToHookProps } from '../shared/index.ts'
import type { AvatarImageEmits, AvatarImageProps } from './AvatarImage.ts'
import { Primitive } from '../primitive/index.ts'
import { convertPropsToHookProps, normalizeAttrs } from '../shared/index.ts'
import { DEFAULT_AVATAR_IMAGE_PROPS, useAvatarImage } from './AvatarImage.ts'
defineOptions({
name: 'AvatarImage',
inheritAttrs: false,
})
const props = withDefaults(defineProps<AvatarImageProps>(), DEFAULT_AVATAR_IMAGE_PROPS)
const emit = defineEmits<AvatarImageEmits>()
const avatarImage = useAvatarImage(convertPropsToHookProps(
props,
['src'],
(): Required<EmitsToHookProps<AvatarImageEmits>> => ({
onLoadingStatusChange(status) {
emit('loadingStatusChange', status)
},
}),
))
</script>
<template>
<Primitive v-bind="normalizeAttrs(avatarImage.attrs([$attrs, { as }]))">
<slot />
</Primitive>
</template>