From 22d015615d4b9e9f4cb5d535f027760cc0b01160 Mon Sep 17 00:00:00 2001 From: proddy Date: Mon, 10 Nov 2025 21:20:10 +0100 Subject: [PATCH] fixed jumpy buttons, moved user profile to its own component --- interface/src/app/main/UserProfile.tsx | 55 +++++++++++ .../src/components/layout/LayoutMenu.tsx | 95 +------------------ .../src/components/layout/LayoutMenuItem.tsx | 4 +- 3 files changed, 61 insertions(+), 93 deletions(-) create mode 100644 interface/src/app/main/UserProfile.tsx diff --git a/interface/src/app/main/UserProfile.tsx b/interface/src/app/main/UserProfile.tsx new file mode 100644 index 000000000..73338975d --- /dev/null +++ b/interface/src/app/main/UserProfile.tsx @@ -0,0 +1,55 @@ +import { memo, useCallback, useContext } from 'react'; + +import PersonIcon from '@mui/icons-material/Person'; +import { Avatar, Box, Button, List, ListItem, ListItemText } from '@mui/material'; + +import { AuthenticatedContext } from '@/contexts/authentication'; +import { SectionContent, useLayoutTitle } from 'components'; +import { LanguageSelector } from 'components/inputs'; +import { useI18nContext } from 'i18n/i18n-react'; + +const UserProfileComponent = () => { + const { LL } = useI18nContext(); + const { me, signOut } = useContext(AuthenticatedContext); + + useLayoutTitle(LL.USER(1)); + + const handleSignOut = useCallback(() => { + signOut(true); + }, [signOut]); + + return ( + + + + + + + + + + + + + + + + + ); +}; + +const UserProfile = memo(UserProfileComponent); + +export default UserProfile; diff --git a/interface/src/components/layout/LayoutMenu.tsx b/interface/src/components/layout/LayoutMenu.tsx index 29746ff27..d37c96b5c 100644 --- a/interface/src/components/layout/LayoutMenu.tsx +++ b/interface/src/components/layout/LayoutMenu.tsx @@ -1,4 +1,4 @@ -import { memo, useCallback, useContext, useMemo, useState } from 'react'; +import { memo, useCallback, useContext, useState } from 'react'; import AccountCircleIcon from '@mui/icons-material/AccountCircle'; import AssessmentIcon from '@mui/icons-material/Assessment'; @@ -7,51 +7,21 @@ import ConstructionIcon from '@mui/icons-material/Construction'; import KeyboardArrowDown from '@mui/icons-material/KeyboardArrowDown'; import LiveHelpIcon from '@mui/icons-material/LiveHelp'; import MoreTimeIcon from '@mui/icons-material/MoreTime'; -import PersonIcon from '@mui/icons-material/Person'; import PlaylistAddIcon from '@mui/icons-material/PlaylistAdd'; import SensorsIcon from '@mui/icons-material/Sensors'; import SettingsIcon from '@mui/icons-material/Settings'; import StarIcon from '@mui/icons-material/Star'; -import { - Avatar, - Box, - Button, - Divider, - List, - ListItem, - ListItemButton, - ListItemIcon, - ListItemText, - Popover -} from '@mui/material'; +import { Box, Divider, List, ListItemButton, ListItemText } from '@mui/material'; -import { LanguageSelector } from 'components/inputs'; import LayoutMenuItem from 'components/layout/LayoutMenuItem'; import { AuthenticatedContext } from 'contexts/authentication'; import { useI18nContext } from 'i18n/i18n-react'; const LayoutMenuComponent = () => { - const { me, signOut } = useContext(AuthenticatedContext); + const { me } = useContext(AuthenticatedContext); const { LL } = useI18nContext(); - - const [anchorEl, setAnchorEl] = useState(null); const [menuOpen, setMenuOpen] = useState(true); - const open = useMemo(() => Boolean(anchorEl), [anchorEl]); - const id = useMemo(() => (anchorEl ? 'app-menu-popover' : undefined), [anchorEl]); - - const handleClick = useCallback((event: React.MouseEvent) => { - setAnchorEl(event.currentTarget); - }, []); - - const handleClose = useCallback(() => { - setAnchorEl(null); - }, []); - - const handleSignOut = useCallback(() => { - signOut(true); - }, [signOut]); - const handleMenuToggle = useCallback(() => { setMenuOpen((prev) => !prev); }, []); @@ -139,64 +109,9 @@ const LayoutMenuComponent = () => { to="/settings" /> + + - - - - - - - - {me.username} - - - - - - - - - - - - - - - - - ); }; diff --git a/interface/src/components/layout/LayoutMenuItem.tsx b/interface/src/components/layout/LayoutMenuItem.tsx index a226138b4..b19652cca 100644 --- a/interface/src/components/layout/LayoutMenuItem.tsx +++ b/interface/src/components/layout/LayoutMenuItem.tsx @@ -27,13 +27,11 @@ const LayoutMenuItemComponent = ({ const buttonStyles: SxProps = useMemo( () => ({ transition: 'all 0.05s cubic-bezier(0.55, 0.085, 0.68, 0.53)', - transform: selected ? 'scale(1.02)' : 'scale(1)', backgroundColor: selected ? 'rgba(144, 202, 249, 0.1)' : 'transparent', borderRadius: '8px', margin: '2px 8px', '&:hover': { - backgroundColor: 'rgba(68, 82, 211, 0.39)', - transform: selected ? 'scale(1.02)' : 'scale(1.01)' + backgroundColor: 'rgba(68, 82, 211, 0.39)' }, '&::before': { content: '""',