Skip to content

Commit 1b085aa

Browse files
committed
feat: increase size and change icon of MiniAvatarUploader
1 parent 47250b5 commit 1b085aa

2 files changed

Lines changed: 33 additions & 4 deletions

File tree

apps/web/res/css/views/elements/_MiniAvatarUploader.pcss

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,20 @@ Please see LICENSE files in the repository root for full details.
2525

2626
line-height: 0;
2727

28-
.mx_MiniAvatarUploader_cameraIcon {
28+
.mx_MiniAvatarUploader_icon {
2929
height: inherit;
3030
width: inherit;
3131
color: $secondary-content;
3232
}
3333
}
34+
35+
.mx_MiniAvatarUploader_indicatorLarge {
36+
height: 20px;
37+
width: 20px;
38+
39+
right: 4px;
40+
bottom: 4px;
41+
}
3442
}
3543

3644
.mx_MiniAvatarUploader_input {

apps/web/src/components/views/elements/MiniAvatarUploader.tsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details.
99
import classNames from "classnames";
1010
import { EventType } from "matrix-js-sdk/src/matrix";
1111
import React, { useContext, useRef, useState, type MouseEvent, type ReactNode } from "react";
12-
import { TakePhotoSolidIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
12+
import { EditIcon, TakePhotoSolidIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
1313

1414
import MatrixClientContext from "../../../contexts/MatrixClientContext";
1515
import { chromeFileInputFix } from "../../../utils/BrowserWorkarounds";
@@ -19,6 +19,7 @@ import { getFileChanged } from "../settings/AvatarSetting.tsx";
1919
import { useScopedRoomContext } from "../../../contexts/ScopedRoomContext.tsx";
2020

2121
export const AVATAR_SIZE = "52px";
22+
export const AVATAR_LARGE_SIZE = "88px";
2223

2324
interface IProps {
2425
hasAvatar: boolean;
@@ -28,6 +29,11 @@ interface IProps {
2829
isUserAvatar?: boolean;
2930
onClick?(this: void, ev: MouseEvent<HTMLInputElement>): void;
3031
children?: ReactNode;
32+
/**
33+
* The size of the avatar, either {@link AVATAR_SIZE} or {@link AVATAR_LARGE_SIZE}.
34+
* @default AVATAR_SIZE
35+
*/
36+
size?: typeof AVATAR_SIZE | typeof AVATAR_LARGE_SIZE;
3137
}
3238

3339
const MiniAvatarUploader: React.FC<IProps> = ({
@@ -38,6 +44,7 @@ const MiniAvatarUploader: React.FC<IProps> = ({
3844
isUserAvatar,
3945
children,
4046
onClick,
47+
size = AVATAR_SIZE,
4148
}) => {
4249
const cli = useContext(MatrixClientContext);
4350
const [busy, setBusy] = useState(false);
@@ -51,6 +58,13 @@ const MiniAvatarUploader: React.FC<IProps> = ({
5158
isUserAvatar || room?.currentState?.maySendStateEvent(EventType.RoomAvatar, cli.getSafeUserId());
5259
if (!canSetAvatar) return <React.Fragment>{children}</React.Fragment>;
5360

61+
const spinnerSize = size === AVATAR_LARGE_SIZE ? 24 : 20;
62+
const icon = AVATAR_LARGE_SIZE ? (
63+
<EditIcon className="mx_MiniAvatarUploader_icon" />
64+
) : (
65+
<TakePhotoSolidIcon className="mx_MiniAvatarUploader_icon" />
66+
);
67+
5468
return (
5569
<React.Fragment>
5670
<input
@@ -86,8 +100,15 @@ const MiniAvatarUploader: React.FC<IProps> = ({
86100
>
87101
{children}
88102

89-
<div className="mx_MiniAvatarUploader_indicator">
90-
{busy ? <Spinner size={20} /> : <TakePhotoSolidIcon className="mx_MiniAvatarUploader_cameraIcon" />}
103+
<div
104+
className={classNames(
105+
{
106+
mx_MiniAvatarUploader_indicatorLarge: size === AVATAR_LARGE_SIZE,
107+
},
108+
"mx_MiniAvatarUploader_indicator",
109+
)}
110+
>
111+
{busy ? <Spinner size={spinnerSize} /> : icon}
91112
</div>
92113
</AccessibleButton>
93114
</React.Fragment>

0 commit comments

Comments
 (0)