🚸(frontend) show two initials in the Avatar when possible

Display two initials in the Avatar whenever the participant's name
allows it, instead of a single letter.

A single initial makes it too hard to distinguish participants when
their cameras are off, especially in larger
This commit is contained in:
lebaudantoine
2026-07-28 23:07:27 +02:00
parent 0ec8ac806f
commit e3b954ff97
2 changed files with 13 additions and 3 deletions
+1
View File
@@ -35,6 +35,7 @@ and this project adheres to
- 🐛(backend) preserve recording metadata when updating room access - 🐛(backend) preserve recording metadata when updating room access
- 🐛(backend) allow any string as sub in the API serializer - 🐛(backend) allow any string as sub in the API serializer
- 🐛(frontend) fall back to user.full_name on request-entry - 🐛(frontend) fall back to user.full_name on request-entry
- 🚸(frontend) show two initials in the Avatar when possible
## [1.24.0] - 2026-07-21 ## [1.24.0] - 2026-07-21
+12 -3
View File
@@ -28,6 +28,15 @@ const avatar = cva({
}, },
}) })
const getInitials = (name?: string): string => {
if (!name) return ''
const words = name.trim().split(/\s+/).filter(Boolean)
if (words.length === 0) return ''
const first = words[0].charAt(0)
const second = words.length > 1 ? words[1].charAt(0) : ''
return (first + second).toUpperCase()
}
export type AvatarProps = React.HTMLAttributes<HTMLDivElement> & { export type AvatarProps = React.HTMLAttributes<HTMLDivElement> & {
name?: string name?: string
bgColor?: string bgColor?: string
@@ -35,7 +44,7 @@ export type AvatarProps = React.HTMLAttributes<HTMLDivElement> & {
export const Avatar = React.memo( export const Avatar = React.memo(
({ name, bgColor, context, notification, style, ...props }: AvatarProps) => { ({ name, bgColor, context, notification, style, ...props }: AvatarProps) => {
const initial = name?.trim()?.charAt(0) ?? '' const initials = getInitials(name)
return ( return (
<div <div
style={{ backgroundColor: bgColor, ...style }} style={{ backgroundColor: bgColor, ...style }}
@@ -52,11 +61,11 @@ export const Avatar = React.memo(
y="50" y="50"
textAnchor="middle" textAnchor="middle"
dominantBaseline="central" dominantBaseline="central"
fontSize="52" fontSize={initials.length > 1 ? 48 : 52}
fontWeight="500" fontWeight="500"
fill="currentColor" fill="currentColor"
> >
{initial.toUpperCase()} {initials.toUpperCase()}
</text> </text>
</svg> </svg>
</div> </div>