Skip to content

Commit

Permalink
Merge pull request #479 from sirraminyavari/dev-redesign
Browse files Browse the repository at this point in the history
feat: 💄 improve user profile dropdown menu
  • Loading branch information
sorenabedi committed Jun 7, 2023
2 parents 8c3db8a + 5e83dc7 commit 706bb9d
Show file tree
Hide file tree
Showing 11 changed files with 1,404 additions and 28 deletions.
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
></script>

<link rel="shortcut icon" href="/api/rv/fav_icon" />
<link rel="stylesheet" type="text/css" href="/api/rv/theme" />
<!-- <link rel="stylesheet" type="text/css" href="/api/rv/theme" /> -->
<link rel="stylesheet" type="text/css" href="/api/rv/css_direction" />
<script
type="text/javascript"
Expand Down
10 changes: 7 additions & 3 deletions src/components/ThemeProvider/ThemeProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { WindowContext } from 'context/WindowProvider';
import useWindowContext from 'hooks/useWindowContext';
import { PropsWithChildren, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { useDispatch, useSelector } from 'react-redux';
import { useThemeSlice } from 'store/slice/theme';
import { selectTheme } from 'store/slice/theme/selectors';

const ThemeProvider = ({ children }: PropsWithChildren<void>) => {
const { RV_RTL } = useWindowContext();
const themeState = useSelector(selectTheme);
const dispatch = useDispatch();
const { actions: themeActions } = useThemeSlice();
useEffect(() => {
dispatch(themeActions.getCurrentTheme({}));
const directionState = RV_RTL ? 'direction-rtl' : 'direction-ltr';

document.body.setAttribute('dir', RV_RTL ? 'rtl' : 'ltr');
Expand All @@ -24,7 +27,8 @@ const ThemeProvider = ({ children }: PropsWithChildren<void>) => {
'overflow-enabled',
directionState,
].join(' ');
}, [themeState.currentTheme, RV_RTL]);
}, [themeState.currentTheme, RV_RTL, dispatch, themeActions]);

return <>{children}</>;
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/withTheme/withTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ const withTheme = (Component) => (props) => {

return <Component theme={{ states, actions }} {...props} />;
};

withTheme.displayName = 'withTheme';
export default withTheme;
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ const SidebarContentDefault: SidebarContentFunction = ({
path: `${TEAMS_PATH}`,
},
{
Icon: SidebarUserAvatar,
Icon: () => SidebarUserAvatar({ history }),
noIndicator: false,
onClick: () => {
history.push(`/${PROFILE_USER}`);
setIsSubMenuToggled(false);
},
path: `/${PROFILE_USER}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,6 @@
display: flex;
flex-direction: column;
gap: 0.5rem;
justify-content: center;
align-items: center;
}
13 changes: 7 additions & 6 deletions src/layouts/NewSidebar/sidebarContents/sidebarUserAvatar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import Button from 'components/Buttons/Button';
import { PROFILE_USER } from 'constant/constants';
import { useDispatch, useSelector } from 'react-redux';
import { selectAuth } from 'store/slice/auth/selectors';
import { useHistory } from 'react-router-dom';
import { useAuthSlice } from 'store/slice/auth';
import Popover from '@mui/base/PopperUnstyled';
import { useState } from 'react';
Expand All @@ -22,9 +21,8 @@ const AvatarUser = WithAvatar({
componentURLProp: 'src',
});

const SidebarUserAvatar = (props: Record<string, any>) => {
const SidebarUserAvatar = ({ history, ...props }: Record<string, any>) => {
const { authUser } = useSelector(selectAuth);
const history = useHistory();
const dispatch = useDispatch();
const [open, setOpen] = useState<boolean>(false);
const [anchorEl, setAnchorEl] = useState<HTMLDivElement>();
Expand Down Expand Up @@ -75,17 +73,20 @@ const SidebarUserAvatar = (props: Record<string, any>) => {
placement="auto"
>
<div
className={clsx(RVColorProp.oxford, styles.userAvatarDropdownPanel)}
className={clsx(RVColorProp.platinum, styles.userAvatarDropdownPanel)}
>
<Button
onClick={() => {
history.push(`/${PROFILE_USER}`);
setOpen((prev) => !prev);
}}
color={RVColorProp.platinum}
>
profile
Profile
</Button>
<Button color={RVColorProp.platinum} onClick={handleLogout}>
Logout
</Button>
<Button onClick={handleLogout}>logout</Button>
</div>
</Popover>
</>
Expand Down
Loading

0 comments on commit 706bb9d

Please sign in to comment.