mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-17 13:38:07 +01:00
16 lines
582 B
TypeScript
16 lines
582 B
TypeScript
import { inject, provide, computed, type ComputedRef, type InjectionKey } from 'vue'
|
|
import type { AvatarGroupProps } from '../types'
|
|
|
|
export const avatarGroupInjectionKey: InjectionKey<ComputedRef<{ size: AvatarGroupProps['size'] }>> = Symbol('nuxt-ui.avatar-group')
|
|
|
|
export function useAvatarGroup(props: { size: AvatarGroupProps['size'] }) {
|
|
const avatarGroup = inject(avatarGroupInjectionKey, undefined)
|
|
|
|
const size = computed(() => props.size ?? avatarGroup?.value.size)
|
|
provide(avatarGroupInjectionKey, computed(() => ({ size: size.value })))
|
|
|
|
return {
|
|
size
|
|
}
|
|
}
|