forked from mystiq/hydrogen-web
support extra classes in static avatar
This commit is contained in:
parent
441bb4d5d7
commit
fbe255f837
1 changed files with 5 additions and 2 deletions
|
@ -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]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue