Merge pull request #2183 from ianmacd/pr5

Use up to two scaled placeholder characters for users with no avatar.
pull/2193/head
Audric Ackermann 4 years ago committed by GitHub
commit 8a13a9e6e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -97,8 +97,12 @@ export const AvatarPlaceHolder = (props: Props) => {
); );
} }
const initial = getInitials(name)?.toLocaleUpperCase() || '0'; let initials = getInitials(name)?.toLocaleUpperCase() || '0';
const fontSize = diameter * 0.5; if (name.indexOf(' ') === -1) {
initials = name.substr(0, 2);
}
const fontSize = diameter * (1 / (initials.length + 1));
const bgColorIndex = hash % avatarPlaceholderColors.length; const bgColorIndex = hash % avatarPlaceholderColors.length;
@ -126,7 +130,7 @@ export const AvatarPlaceHolder = (props: Props) => {
strokeWidth={1} strokeWidth={1}
alignmentBaseline="central" alignmentBaseline="central"
> >
{initial} {initials}
</text> </text>
</g> </g>
</svg> </svg>

@ -7,5 +7,9 @@ export function getInitials(name?: string): string | undefined {
return name[2]; return name[2];
} }
return name[0]; const initials = name.split(' ').slice(0, 2).map(n => {
return n[0];
})
return initials.join('');
} }

Loading…
Cancel
Save