diff --git a/docs/components/avatar/avatar.md b/docs/components/avatar/avatar.md index 1294e57..a1b8a7f 100644 --- a/docs/components/avatar/avatar.md +++ b/docs/components/avatar/avatar.md @@ -6,6 +6,8 @@ import AvatarSizeExample from './examples/AvatarSizeExample.vue' import AvatarDotIndicatorPositionExample from './examples/AvatarDotIndicatorPositionExample.vue' import AvatarAlternativeTextExample from './examples/AvatarAlternativeTextExample.vue' import StackedAvatarsExample from './examples/StackedAvatarsExample.vue' +import AvatarPlaceholderExample from './examples/AvatarPlaceholderExample.vue' +import AvatarPlaceholderInitialsExample from './examples/AvatarPlaceholderInitialsExample.vue' # Avatar @@ -46,6 +48,7 @@ import { Avatar } from 'flowbite-vue' ``` ## Dot indicator +Use a dot element relative to the avatar component as an indicator for the user (eg. online or offline status). @@ -63,27 +66,9 @@ import { Avatar } from 'flowbite-vue' ``` -## Sizes - - - -```vue - - -``` - ## Dot indicator position + ```vue @@ -103,11 +88,44 @@ import { Avatar } from 'flowbite-vue' ``` + +## Sizes + +Choose from multiple sizing options for the avatar component from this example. + + + +```vue + + +``` + ## Alternative text +```vue + + + +``` + ## Stacked avatars +Use this example if you want to stack a group of users by overlapping the avatar components. @@ -133,3 +151,37 @@ import { StackedAvatars, Avatar, StackedAvatarsCounter } from 'flowbite-vue' ``` + +## Placeholder icon + + + +```vue + + + +``` + +## Placeholder initials + + + +```vue + + + +``` diff --git a/docs/components/avatar/examples/AvatarPlaceholderExample.vue b/docs/components/avatar/examples/AvatarPlaceholderExample.vue new file mode 100644 index 0000000..e22a835 --- /dev/null +++ b/docs/components/avatar/examples/AvatarPlaceholderExample.vue @@ -0,0 +1,9 @@ + + diff --git a/docs/components/avatar/examples/AvatarPlaceholderInitialsExample.vue b/docs/components/avatar/examples/AvatarPlaceholderInitialsExample.vue new file mode 100644 index 0000000..a53b0f4 --- /dev/null +++ b/docs/components/avatar/examples/AvatarPlaceholderInitialsExample.vue @@ -0,0 +1,9 @@ + + diff --git a/src/components/Avatar/Avatar.vue b/src/components/Avatar/Avatar.vue index 3826820..1d674fe 100644 --- a/src/components/Avatar/Avatar.vue +++ b/src/components/Avatar/Avatar.vue @@ -1,6 +1,12 @@ @@ -43,8 +49,12 @@ const props = defineProps({ type: String as PropType, default: 'top-right', }, + initials: { + type: String, + default: null, + }, }) -const { avatarClasses, avatarDotClasses } = useAvatarClasses(toRefs(props)) +const { avatarClasses, avatarDotClasses, avatarPlaceholderClasses, avatarPlaceholderWrapperClasses, avatarPlaceholderInitialsClasses } = useAvatarClasses(toRefs(props)) diff --git a/src/components/Avatar/composables/useAvatarClasses.ts b/src/components/Avatar/composables/useAvatarClasses.ts index c172c37..bfb5619 100644 --- a/src/components/Avatar/composables/useAvatarClasses.ts +++ b/src/components/Avatar/composables/useAvatarClasses.ts @@ -34,6 +34,17 @@ const avatarStatusDotPositionClasses: Record bordered: Ref @@ -48,6 +59,9 @@ export type UseAvatarClassesProps = { export function useAvatarClasses(props: UseAvatarClassesProps): { avatarClasses: Ref avatarDotClasses: Ref + avatarPlaceholderClasses: Ref + avatarPlaceholderWrapperClasses: Ref + avatarPlaceholderInitialsClasses: Ref } { const avatarClasses = computed(() => { @@ -67,12 +81,32 @@ export function useAvatarClasses(props: UseAvatarClassesProps): { avatarStatusDotPositionClasses[avatarType as avatarDotIndicatorPositionClasses], ) }) - // TODO: Placeholder + const avatarPlaceholderClasses = computed(() => { + return classNames( + avatarPlaceholderDefaultClasses, + avatarPlaceholderSizes[props.size.value], + ) + }) + const avatarPlaceholderWrapperClasses = computed(() => { + return classNames( + avatarPlaceholderWrapperDefaultClasses, + avatarSizeClasses[props.size.value], + avatarTypeClasses[props.rounded.value ? 'rounded' : 'default'], + ) + }) + const avatarPlaceholderInitialsClasses = computed(() => { + return classNames( + avatarPlaceholderInitialsDefaultClasses, + ) + }) // TODO: Avatar Initials return { avatarClasses, avatarDotClasses, + avatarPlaceholderClasses, + avatarPlaceholderWrapperClasses, + avatarPlaceholderInitialsClasses, } }