Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit a07f503

Browse files
committed
Revert "Fix layout and visual regressions around default avatars (#10031)"
This reverts commit 0d1fce3.
1 parent 4ecfb93 commit a07f503

File tree

5 files changed

+28
-21
lines changed

5 files changed

+28
-21
lines changed

cypress/e2e/spaces/spaces.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ describe("Spaces", () => {
153153

154154
openSpaceCreateMenu().within(() => {
155155
cy.get(".mx_SpaceCreateMenuType_private").click();
156-
// We don't set an avatar here to get a Percy snapshot of the default avatar style for spaces
156+
cy.get('.mx_SpaceBasicSettings_avatarContainer input[type="file"]').selectFile(
157+
"cypress/fixtures/riot.png",
158+
{ force: true },
159+
);
157160
cy.get('input[label="Address"]').should("not.exist");
158161
cy.get('textarea[label="Description"]').type("This is a personal space to mourn Riot.im...");
159162
cy.get('input[label="Name"]').type("This is my Riot{enter}");
@@ -166,7 +169,6 @@ describe("Spaces", () => {
166169

167170
cy.contains(".mx_RoomList .mx_RoomTile", "Sample Room").should("exist");
168171
cy.contains(".mx_SpaceHierarchy_list .mx_SpaceHierarchy_roomTile", "Sample Room").should("exist");
169-
cy.get(".mx_LeftPanel_outerWrapper").percySnapshotElement("Left panel with default avatar space");
170172
});
171173

172174
it("should allow user to invite another to a space", () => {

res/css/structures/_SpacePanel.pcss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,11 +277,14 @@ $activeBorderColor: $primary-content;
277277
.mx_BaseAvatar:not(.mx_UserMenu_userAvatar_BaseAvatar) .mx_BaseAvatar_initial {
278278
color: $secondary-content;
279279
border-radius: 8px;
280+
background-color: $panel-actions;
281+
font-size: $font-15px !important; /* override inline style */
280282
font-weight: $font-semi-bold;
281283
line-height: $font-18px;
282-
/* override inline styles which are part of the default avatar style as these uses a monochrome style */
283-
background-color: $panel-actions !important;
284-
font-size: $font-15px !important;
284+
285+
& + .mx_BaseAvatar_image {
286+
visibility: hidden;
287+
}
285288
}
286289

287290
.mx_SpaceTreeLevel {

res/css/structures/_UserMenu.pcss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ limitations under the License.
2525

2626
.mx_UserMenu_userAvatar {
2727
position: relative;
28-
/* without this a default avatar will cause this to be 4px oversized and out of alignment */
29-
display: inherit;
3028

3129
.mx_BaseAvatar {
3230
pointer-events: none; /* makes the avatar non-draggable */

src/components/views/avatars/BaseAvatar.tsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
import React, { CSSProperties, useCallback, useContext, useEffect, useState } from "react";
18+
import React, { useCallback, useContext, useEffect, useState } from "react";
1919
import classNames from "classnames";
2020
import { ResizeMethod } from "matrix-js-sdk/src/@types/partials";
2121
import { ClientEvent } from "matrix-js-sdk/src/client";
@@ -51,7 +51,6 @@ interface IProps {
5151
inputRef?: React.RefObject<HTMLImageElement & HTMLSpanElement>;
5252
className?: string;
5353
tabIndex?: number;
54-
style?: CSSProperties;
5554
}
5655

5756
const calculateUrls = (url: string | undefined, urls: string[] | undefined, lowBandwidth: boolean): string[] => {
@@ -133,17 +132,10 @@ const BaseAvatar: React.FC<IProps> = (props) => {
133132
onClick,
134133
inputRef,
135134
className,
136-
style: parentStyle,
137135
resizeMethod: _unused, // to keep it from being in `otherProps`
138136
...otherProps
139137
} = props;
140138

141-
const style = {
142-
...parentStyle,
143-
width: toPx(width),
144-
height: toPx(height),
145-
};
146-
147139
const [imageUrl, onError] = useImageUrl({ url, urls });
148140

149141
if (!imageUrl && defaultToInitialLetter && name) {
@@ -159,7 +151,10 @@ const BaseAvatar: React.FC<IProps> = (props) => {
159151
className={classNames("mx_BaseAvatar", className)}
160152
onClick={onClick}
161153
inputRef={inputRef}
162-
style={style}
154+
style={{
155+
width: toPx(width),
156+
height: toPx(height),
157+
}}
163158
>
164159
{avatar}
165160
</AccessibleButton>
@@ -170,7 +165,10 @@ const BaseAvatar: React.FC<IProps> = (props) => {
170165
className={classNames("mx_BaseAvatar", className)}
171166
ref={inputRef}
172167
{...otherProps}
173-
style={style}
168+
style={{
169+
width: toPx(width),
170+
height: toPx(height),
171+
}}
174172
role="presentation"
175173
>
176174
{avatar}
@@ -187,7 +185,10 @@ const BaseAvatar: React.FC<IProps> = (props) => {
187185
src={imageUrl}
188186
onClick={onClick}
189187
onError={onError}
190-
style={style}
188+
style={{
189+
width: toPx(width),
190+
height: toPx(height),
191+
}}
191192
title={title}
192193
alt={_t("Avatar")}
193194
inputRef={inputRef}
@@ -201,7 +202,10 @@ const BaseAvatar: React.FC<IProps> = (props) => {
201202
className={classNames("mx_BaseAvatar mx_BaseAvatar_image", className)}
202203
src={imageUrl}
203204
onError={onError}
204-
style={style}
205+
style={{
206+
width: toPx(width),
207+
height: toPx(height),
208+
}}
205209
title={title}
206210
alt=""
207211
ref={inputRef}

test/components/views/avatars/__snapshots__/MemberAvatar-test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ exports[`MemberAvatar matches the snapshot 1`] = `
77
class="mx_BaseAvatar mx_BaseAvatar_image"
88
data-testid="avatar-img"
99
src="http://this.is.a.url//placekitten.com/400/400"
10-
style="color: pink; width: 35px; height: 35px;"
10+
style="color: pink;"
1111
title="Hover title"
1212
/>
1313
</div>

0 commit comments

Comments
 (0)