From 440527c0785224bbbdff3e8845d92067600e23b4 Mon Sep 17 00:00:00 2001 From: ArneBo Date: Fri, 17 Jan 2025 18:53:43 +0100 Subject: [PATCH] feat(front): username initials as fallback for profile image and usermenu icon --- front/src/components/common/ActorAvatar.vue | 3 +-- front/src/style/components/_avatar.scss | 2 +- front/src/ui/components/UserMenu.vue | 11 ++++++++++ front/src/views/auth/ProfileBase.vue | 24 ++++++++++++--------- 4 files changed, 27 insertions(+), 13 deletions(-) diff --git a/front/src/components/common/ActorAvatar.vue b/front/src/components/common/ActorAvatar.vue index 815a6f348..f6222afa1 100644 --- a/front/src/components/common/ActorAvatar.vue +++ b/front/src/components/common/ActorAvatar.vue @@ -31,7 +31,6 @@ const defaultAvatarStyle = computed(() => ({ backgroundColor: `#${actorColor.val \ No newline at end of file + diff --git a/front/src/style/components/_avatar.scss b/front/src/style/components/_avatar.scss index f7c3506ef..350937ce9 100644 --- a/front/src/style/components/_avatar.scss +++ b/front/src/style/components/_avatar.scss @@ -5,7 +5,7 @@ width: 3em; } -.ui.circular.avatar { +.ui.tiny.avatar { width: 28px; height: 28px; font-size: 1em !important; diff --git a/front/src/ui/components/UserMenu.vue b/front/src/ui/components/UserMenu.vue index 87e46931b..611e33584 100644 --- a/front/src/ui/components/UserMenu.vue +++ b/front/src/ui/components/UserMenu.vue @@ -3,6 +3,7 @@ import { useI18n } from 'vue-i18n' import { computed, ref} from 'vue' import { useStore } from '~/store' import { useRoute } from 'vue-router' +import { hashCode, intToRGB } from '~/utils/color' import useThemeList from '~/composables/useThemeList' import useTheme from '~/composables/useTheme' @@ -23,6 +24,9 @@ const { theme } = useTheme() const isOpen = ref(false) +const actorColor = computed(() => intToRGB(hashCode(store.state.auth.profile.full_username))) +const defaultAvatarStyle = computed(() => ({ backgroundColor: `#${actorColor.value}` })) + const labels = computed(() => ({ profile: t('components.common.UserMenu.link.profile'), settings: t('components.common.UserMenu.link.settings'), @@ -57,6 +61,13 @@ const labels = computed(() => ({ :src="store.getters['instance/absoluteUrl'](store.state.auth.profile?.avatar.urls.medium_square_crop)" class="avatar" > + + {{ store.state.auth.profile?.full_username?.[0] || "" }} +