Files
vue-chat-layer/app/components/Chat/Avatar.vue
Jakub Zych 5d581539b3 feat: port the chat store, realtime client and components
- realtime.ts: the page's one Centrifuge client, setRealtimeAuth, onUserEvent for user:{me} events the chat does not handle
- chatEvents, chatFormat, chatText, chatUnread, format, media, tabs ported; copy passed in localized
- useChat over useState: channels with join and leave, DMs, member list, unread and mention counts, read marks, typing, presence, polling fallback
- ChatPanel, ChatHeader, ChatMessage, ChatDmList, ChatMemberPicker, ChatMentionPopup, ChatAvatar, ChatIcon, ChatNotices
- EN and PL strings
2026-10-31 13:52:56 +01:00

21 lines
842 B
Vue

<script setup lang="ts">
// Initials on a palette colour derived from the user id. Never an image:
// sender_avatar from the chat API may point at an external host.
import type { ChatMember } from '../../lib/types'
import { avatarIndex, initials } from '../../lib/chatFormat'
const props = withDefaults(defineProps<{ userId: number; member?: ChatMember | null; fallback?: string; size?: 24 | 32 | 44; me?: boolean }>(), {
member: null,
fallback: '',
size: 32,
me: false,
})
const text = computed(() => initials(props.member, props.fallback))
const fill = computed(() => (props.me ? undefined : { background: `var(--chat-av-${avatarIndex(props.userId)})` }))
</script>
<template>
<span class="chat-avatar" :class="[`chat-avatar--${size}`, { 'chat-avatar--me': me }]" :style="fill" aria-hidden="true">{{ text }}</span>
</template>