From 9712ecf9746bbf86e790f738828a84856c5269b1 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Mon, 7 Dec 2020 17:47:08 +0100 Subject: [PATCH] don't show border radios on default avatar icon --- css/preview.css | 9 +++++++++ src/preview/PreviewView.js | 9 ++++++++- src/preview/PreviewViewModel.js | 8 +++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/css/preview.css b/css/preview.css index 1de5220..c72e96e 100644 --- a/css/preview.css +++ b/css/preview.css @@ -21,6 +21,15 @@ height: 64px; } +.PreviewView .defaultAvatar { + width: 64px; + height: 64px; + background-image: url('../images/chat-icon.svg'); + background-repeat: no-repeat; + background-position: center; + background-size: 85%; +} + .PreviewView .spinner { width: 32px; height: 32px; diff --git a/src/preview/PreviewView.js b/src/preview/PreviewView.js index 2cee062..4d16075 100644 --- a/src/preview/PreviewView.js +++ b/src/preview/PreviewView.js @@ -44,8 +44,15 @@ class LoadingPreviewView extends TemplateView { class LoadedPreviewView extends TemplateView { render(t, vm) { + const avatar = t.mapView(vm => vm.avatarUrl, avatarUrl => { + if (avatarUrl) { + return new TemplateView(avatarUrl, (t, src) => t.img({className: "avatar", src})); + } else { + return new TemplateView(null, t => t.div({className: "defaultAvatar"})); + } + }); return t.div([ - t.div({className: "avatarContainer"}, t.img({className: "avatar", src: vm => vm.avatarUrl})), + t.div({className: "avatarContainer"}, avatar), t.h1(vm => vm.name), t.p({className: {identifier: true, hidden: vm => !vm.identifier}}, vm => vm.identifier), t.div({className: {memberCount: true, hidden: vm => !vm.memberCount}}, t.p([vm => vm.memberCount, " members"])), diff --git a/src/preview/PreviewViewModel.js b/src/preview/PreviewViewModel.js index 5c340eb..50843e6 100644 --- a/src/preview/PreviewViewModel.js +++ b/src/preview/PreviewViewModel.js @@ -20,8 +20,6 @@ import {resolveServer} from "./HomeServer.js"; import {ClientListViewModel} from "../open/ClientListViewModel.js"; import {ClientViewModel} from "../open/ClientViewModel.js"; -const DEFAULT_AVATAR = "images/chat-icon.svg"; - export class PreviewViewModel extends ViewModel { constructor(options) { super(options); @@ -84,7 +82,7 @@ export class PreviewViewModel extends ViewModel { this.name = profile.displayname || userId; this.avatarUrl = profile.avatar_url ? homeserver.mxcUrlThumbnail(profile.avatar_url, 64, 64, "crop") : - DEFAULT_AVATAR; + null; this.identifier = userId; } @@ -101,7 +99,7 @@ export class PreviewViewModel extends ViewModel { this.name = publicRoom?.name || publicRoom?.canonical_alias || link.identifier; this.avatarUrl = publicRoom?.avatar_url ? homeserver.mxcUrlThumbnail(publicRoom.avatar_url, 64, 64, "crop") : - DEFAULT_AVATAR; + null; this.memberCount = publicRoom?.num_joined_members; this.topic = publicRoom?.topic; this.identifier = publicRoom?.canonical_alias || link.identifier; @@ -113,6 +111,6 @@ export class PreviewViewModel extends ViewModel { _setNoPreview(link) { this.name = link.identifier; this.identifier = null; - this.avatarUrl = DEFAULT_AVATAR; + this.avatarUrl = null; } }