@@ -9,7 +9,7 @@ Please see LICENSE files in the repository root for full details.
99import classNames from "classnames" ;
1010import { EventType } from "matrix-js-sdk/src/matrix" ;
1111import 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
1414import MatrixClientContext from "../../../contexts/MatrixClientContext" ;
1515import { chromeFileInputFix } from "../../../utils/BrowserWorkarounds" ;
@@ -19,6 +19,7 @@ import { getFileChanged } from "../settings/AvatarSetting.tsx";
1919import { useScopedRoomContext } from "../../../contexts/ScopedRoomContext.tsx" ;
2020
2121export const AVATAR_SIZE = "52px" ;
22+ export const AVATAR_LARGE_SIZE = "88px" ;
2223
2324interface 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
3339const 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