Use PrimeVue Avatar component (#3615)

This commit is contained in:
Chenlei Hu
2025-04-24 21:49:03 -04:00
committed by GitHub
parent b05407ffdd
commit b79cbf69af
2 changed files with 20 additions and 24 deletions

View File

@@ -5,14 +5,13 @@
<Divider class="mb-3" />
<div v-if="user" class="flex flex-col gap-2">
<!-- User Avatar if available -->
<div v-if="user.photoURL" class="flex items-center gap-2">
<img
:src="user.photoURL"
:alt="user.displayName || ''"
class="w-8 h-8 rounded-full"
/>
</div>
<Avatar
v-if="user.photoURL"
:image="user.photoURL"
shape="circle"
size="large"
aria-label="User Avatar"
/>
<div class="flex flex-col gap-0.5">
<h3 class="font-medium">
@@ -77,6 +76,7 @@
</template>
<script setup lang="ts">
import Avatar from 'primevue/avatar'
import Button from 'primevue/button'
import Divider from 'primevue/divider'
import ProgressSpinner from 'primevue/progressspinner'

View File

@@ -10,28 +10,22 @@
@click="openUserSettings"
>
<div
class="flex items-center gap-2 pr-2 rounded-full bg-[var(--p-content-background)]"
class="flex items-center rounded-full bg-[var(--p-content-background)]"
>
<!-- User Avatar if available -->
<div v-if="user?.photoURL" class="flex items-center gap-1">
<img
:src="user.photoURL"
:alt="user.displayName || ''"
class="w-8 h-8 rounded-full"
/>
</div>
<Avatar
:image="photoURL"
:icon="photoURL ? undefined : 'pi pi-user'"
shape="circle"
aria-label="User Avatar"
/>
<!-- User Icon if no avatar -->
<div v-else class="w-8 h-8 rounded-full flex items-center justify-center">
<i class="pi pi-user text-sm" />
</div>
<i class="pi pi-chevron-down" :style="{ fontSize: '0.5rem' }" />
<i class="pi pi-chevron-down px-1" :style="{ fontSize: '0.5rem' }" />
</div>
</Button>
</template>
<script setup lang="ts">
import Avatar from 'primevue/avatar'
import Button from 'primevue/button'
import { computed } from 'vue'
@@ -41,7 +35,9 @@ import { useFirebaseAuthStore } from '@/stores/firebaseAuthStore'
const authStore = useFirebaseAuthStore()
const dialogService = useDialogService()
const isAuthenticated = computed(() => authStore.isAuthenticated)
const user = computed(() => authStore.currentUser)
const photoURL = computed<string | undefined>(
() => authStore.currentUser?.photoURL ?? undefined
)
const openUserSettings = () => {
dialogService.showSettingsDialog('user')