mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-25 09:20:36 +01:00
chore: use InjectionKey to type and define injected properties (#90)
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import { inject, provide, computed, type ComputedRef } from 'vue'
|
||||
import { inject, provide, computed, type ComputedRef, type InjectionKey } from 'vue'
|
||||
import type { AvatarGroupProps } from '#ui/types'
|
||||
|
||||
export const avatarGroupInjectionKey: InjectionKey<ComputedRef<{ size: AvatarGroupProps['size'] }>> = Symbol('nuxt-ui.avatar-group')
|
||||
|
||||
export function useAvatarGroup(props: { size: AvatarGroupProps['size'] }) {
|
||||
const injectedSize = inject<ComputedRef<AvatarGroupProps['size']> | undefined>('avatar-size', undefined)
|
||||
const size = computed(() => props.size ?? injectedSize?.value)
|
||||
const injectedSize = inject(avatarGroupInjectionKey, undefined)
|
||||
|
||||
const size = computed(() => props.size ?? injectedSize?.value.size)
|
||||
provide('avatar-size', size)
|
||||
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user