Skip to content

Commit 1497204

Browse files
committed
MOBILE-4362 user: Fix user-initials size on toolbar
1 parent 68d9d6c commit 1497204

File tree

8 files changed

+46
-41
lines changed

8 files changed

+46
-41
lines changed

src/addons/messages/pages/discussion/discussion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ion-title>
77
<h1>
88
<img *ngIf="loaded && !otherMember && conversationImage" class="core-bar-button-image" [src]="conversationImage" alt=""
9-
onError="this.src='assets/img/group-avatar.svg'" core-external-content role="presentation" [siteId]="siteId || null">
9+
onError="this.src='assets/img/group-avatar.svg'" core-external-content role="presentation" [siteId]="siteId">
1010
<core-user-avatar *ngIf="loaded && otherMember" class="core-bar-button-image" [user]="otherMember" [linkProfile]="false"
1111
[checkOnline]="otherMember.showonlinestatus">
1212
</core-user-avatar>

src/addons/messages/pages/discussion/discussion.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
5858
@ViewChild(IonContent) content?: IonContent;
5959
@ViewChild(CoreInfiniteLoadingComponent) infinite?: CoreInfiniteLoadingComponent;
6060

61-
siteId: string;
6261
protected fetching = false;
6362
protected polling?: number;
6463
protected logger: CoreLogger;
@@ -79,6 +78,7 @@ export class AddonMessagesDiscussionPage implements OnInit, OnDestroy, AfterView
7978
conversation?: AddonMessagesConversationFormatted; // The conversation object (if it exists).
8079
userId?: number; // User ID you're talking to (only if group messaging not enabled or it's a new individual conversation).
8180
currentUserId: number;
81+
siteId: string;
8282
title?: string;
8383
showInfo = false;
8484
conversationImage?: string;

src/core/components/user-avatar/core-user-avatar.html

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<ng-container *ngIf="avatarUrl">
2-
<img *ngIf="linkProfile" [src]="avatarUrl" [alt]="'core.pictureof' | translate:{$a: fullname}" core-external-content
2+
<img class="userpicture" *ngIf="linkProfile" [src]="avatarUrl" [alt]="'core.pictureof' | translate:{$a: fullname}" core-external-content
33
(error)="loadImageError()" (ariaButtonClick)="gotoProfile($event)" [siteId]="siteId">
44

5-
<img *ngIf="!linkProfile" [src]="avatarUrl" [alt]="'core.pictureof' | translate:{$a: fullname}" core-external-content
6-
(error)="loadImageError()" aria-hidden="true" [siteId]="siteId">
5+
<img class="userpicture" *ngIf="!linkProfile" [src]="avatarUrl" [alt]="'core.pictureof' | translate:{$a: fullname}"
6+
core-external-content (error)="loadImageError()" aria-hidden="true" [siteId]="siteId">
77
</ng-container>
88
<ng-container *ngIf="!avatarUrl && initials">
99
<div class="userinitials" *ngIf="linkProfile" [attr.aria-label]="'core.pictureof' | translate:{$a: fullname}"
@@ -16,10 +16,11 @@
1616
</div>
1717
</ng-container>
1818
<ng-container *ngIf="!avatarUrl && !initials">
19-
<img *ngIf="linkProfile" src="assets/img/user-avatar.png" [alt]="'core.pictureof' | translate:{$a: fullname}"
19+
<img class="userpicture" *ngIf="linkProfile" src="assets/img/user-avatar.png" [alt]="'core.pictureof' | translate:{$a: fullname}"
2020
(ariaButtonClick)="gotoProfile($event)">
2121

22-
<img *ngIf="!linkProfile" src="assets/img/user-avatar.png" [alt]="'core.pictureof' | translate:{$a: fullname}" aria-hidden="true">
22+
<img class="userpicture" *ngIf="!linkProfile" src="assets/img/user-avatar.png" [alt]="'core.pictureof' | translate:{$a: fullname}"
23+
aria-hidden="true">
2324
</ng-container>
2425

2526
<span *ngIf="checkOnline && isOnline()" class="contact-status online" role="status" [attr.aria-label]="'core.online' | translate">

src/core/components/user-avatar/user-avatar.scss

Lines changed: 33 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,47 @@
44
position: relative;
55
width: var(--core-avatar-size);
66
height: var(--core-avatar-size);
7+
padding: 0px;
78
--contact-status-size: 14px;
89
--margin-end-on-item: 8px;
910
--margin-vertical-on-item: 8px;
11+
--userpicture-padding: 0px;
1012

11-
img {
13+
img.userpicture {
1214
border-radius: var(--core-avatar-radius);
1315
width: var(--core-avatar-size);
1416
height: var(--core-avatar-size);
1517
max-width: var(--core-avatar-size);
1618
max-height: var(--core-avatar-size);
17-
}
18-
img[alt] {
19-
text-indent: -999999px;
20-
white-space: nowrap;
21-
overflow: hidden;
22-
}
23-
img[core-external-content]:not([src]),
24-
img[core-external-content][src=""] {
25-
visibility: visible;
26-
display: inline-block;
27-
position: relative;
28-
&:after {
29-
border-radius: var(--core-avatar-radius);
30-
display: block;
31-
position: absolute;
32-
top: 0;
33-
left: 0;
34-
width: 100%;
35-
height: 100%;
36-
background: url('/assets/img/user-avatar.png');
37-
background-size: contain;
38-
content: "";
19+
padding: var(--userpicture-padding);
20+
&[alt] {
21+
text-indent: -999999px;
22+
white-space: nowrap;
23+
overflow: hidden;
24+
}
25+
&:not([src]),
26+
&[src=""] {
27+
visibility: visible;
28+
display: inline-block;
29+
position: relative;
30+
margin: var(--userpicture-padding);
31+
width: calc(var(--core-avatar-size) - var(--userpicture-padding) - var(--userpicture-padding));
32+
height: calc(var(--core-avatar-size) - var(--userpicture-padding) - var(--userpicture-padding));
33+
&:after {
34+
border-radius: var(--core-avatar-radius);
35+
display: block;
36+
position: absolute;
37+
top: 0;
38+
left: 0;
39+
right: 0;
40+
bottom: 0;
41+
background: url('/assets/img/user-avatar.png');
42+
background-size: contain;
43+
content: "";
44+
}
3945
}
4046
}
47+
4148
&.core-bar-button-image {
4249
padding: 0;
4350
width: var(--core-header-toolbar-button-image-size);
@@ -74,9 +81,10 @@
7481
border-radius: var(--core-avatar-radius);
7582
color: var(--gray-800);
7683
font-weight: normal;
77-
width: var(--core-avatar-size);
78-
height: var(--core-avatar-size);
84+
width: calc(var(--core-avatar-size) - var(--userpicture-padding) - var(--userpicture-padding));
85+
height: calc(var(--core-avatar-size) - var(--userpicture-padding) - var(--userpicture-padding));
7986
font-size: calc(var(--core-avatar-size)*0.3);
87+
margin: var(--userpicture-padding);
8088
}
8189

8290
&.large-avatar .userinitials {

src/core/components/user-avatar/user-avatar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy {
7878
}
7979

8080
/**
81-
* Listen to changes.
81+
* @inheritdoc
8282
*/
8383
ngOnChanges(changes: { [name: string]: SimpleChange }): void {
8484
// If something change, update the fields.
@@ -166,7 +166,7 @@ export class CoreUserAvatarComponent implements OnInit, OnChanges, OnDestroy {
166166
}
167167

168168
/**
169-
* Component destroyed.
169+
* @inheritdoc
170170
*/
171171
ngOnDestroy(): void {
172172
this.pictureObserver.off();
Loading
Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
core-user-avatar {
2-
padding: 0;
3-
}
4-
51
:host-context(ion-tabs.placement-side ion-toolbar) {
62
display: none;
73
}
84

9-
:host-context(ion-toolbar) core-user-avatar ::ng-deep img,
10-
:host-context(ion-tab-bar) core-user-avatar ::ng-deep img {
11-
padding: 6px !important;
5+
:host core-user-avatar {
6+
--userpicture-padding: 6px !important;
127
}

src/theme/theme.base.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -980,6 +980,7 @@ ion-content.limited-width > :not([slot]) {
980980
ion-toolbar h1 img.core-bar-button-image,
981981
ion-toolbar h1 .core-bar-button-image img {
982982
padding: 4px;
983+
--userpicture-padding: 4px;
983984
width: var(--core-header-toolbar-button-image-size);
984985
height: var(--core-header-toolbar-button-image-size);
985986
max-width: var(--core-header-toolbar-button-image-size);

0 commit comments

Comments
 (0)