support extra classes in static avatar

This commit is contained in:
Bruno Windels 2021-04-27 15:04:01 +02:00
parent 441bb4d5d7
commit fbe255f837

View File

@ -103,12 +103,15 @@ export class AvatarView extends BaseUpdateView {
* @param {Number} size * @param {Number} size
* @return {Element} * @return {Element}
*/ */
export function renderStaticAvatar(vm, size) { export function renderStaticAvatar(vm, size, extraClasses = undefined) {
const hasAvatar = !!vm.avatarUrl; const hasAvatar = !!vm.avatarUrl;
const avatarClasses = classNames({ let avatarClasses = classNames({
avatar: true, avatar: true,
[`usercolor${vm.avatarColorNumber}`]: !hasAvatar, [`usercolor${vm.avatarColorNumber}`]: !hasAvatar,
}); });
if (extraClasses) {
avatarClasses += ` ${extraClasses}`;
}
const avatarContent = hasAvatar ? renderImg(vm, size) : text(vm.avatarLetter); const avatarContent = hasAvatar ? renderImg(vm, size) : text(vm.avatarLetter);
return tag.div({className: avatarClasses}, [avatarContent]); return tag.div({className: avatarClasses}, [avatarContent]);
} }