diff --git a/res/css/views/settings/_AvatarSetting.pcss b/res/css/views/settings/_AvatarSetting.pcss index 93fce06b13..7f63c3a564 100644 --- a/res/css/views/settings/_AvatarSetting.pcss +++ b/res/css/views/settings/_AvatarSetting.pcss @@ -51,7 +51,7 @@ limitations under the License. height: 28px; border-radius: 32px; border: 1px solid var(--cpd-color-bg-canvas-default); - background-color: var(--cpd-color-bg-subtle-primary); + background-color: var(--cpd-color-bg-canvas-default); position: absolute; bottom: 0; @@ -64,6 +64,11 @@ limitations under the License. top: 3px; } } + + .mx_AvatarSetting_uploadButton:hover, + .mx_AvatarSetting_uploadButton_active { + background-color: var(--cpd-color-bg-subtle-primary); + } } .mx_AvatarSetting_removeMenuItem svg, diff --git a/src/components/views/settings/AvatarSetting.tsx b/src/components/views/settings/AvatarSetting.tsx index a3c0cf850b..81f1cd5201 100644 --- a/src/components/views/settings/AvatarSetting.tsx +++ b/src/components/views/settings/AvatarSetting.tsx @@ -19,6 +19,7 @@ import { Icon as EditIcon } from "@vector-im/compound-design-tokens/icons/edit.s import { Icon as UploadIcon } from "@vector-im/compound-design-tokens/icons/share.svg"; import { Icon as DeleteIcon } from "@vector-im/compound-design-tokens/icons/delete.svg"; import { Menu, MenuItem } from "@vector-im/compound-web"; +import classNames from "classnames"; import { _t } from "../../../languageHandler"; import { mediaFromMxc } from "../../../customisations/Media"; @@ -31,15 +32,17 @@ interface MenuProps { trigger: ReactNode; onUploadSelect: () => void; onRemoveSelect?: () => void; + menuOpen: boolean; + onOpenChange: (newOpen: boolean) => void; } -const AvatarSettingContextMenu: React.FC = ({ trigger, onUploadSelect, onRemoveSelect }) => { - const [menuOpen, setMenuOpen] = useState(false); - - const onOpenChange = useCallback((newOpen: boolean) => { - setMenuOpen(newOpen); - }, []); - +const AvatarSettingContextMenu: React.FC = ({ + trigger, + onUploadSelect, + onRemoveSelect, + menuOpen, + onOpenChange, +}) => { return ( = ({ fileInputRef.current?.click(); }, [fileInputRef]); + const [menuOpen, setMenuOpen] = useState(false); + + const onOpenChange = useCallback((newOpen: boolean) => { + setMenuOpen(newOpen); + }, []); + let avatarElement = ( = ({ let uploadAvatarBtn: JSX.Element | undefined; if (!disabled) { + const uploadButtonClasses = classNames("mx_AvatarSetting_uploadButton", { + mx_AvatarSetting_uploadButton_active: menuOpen, + }); uploadAvatarBtn = ( -
+
); @@ -201,7 +213,13 @@ const AvatarSetting: React.FC = ({ return ( <> - +