1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 12:56:41 +07:00

added settings and profile to user menu

This commit is contained in:
Fedor Katurov 2019-12-03 12:24:42 +07:00
parent 86622d6aa6
commit aed888e894
3 changed files with 45 additions and 22 deletions

View file

@ -36,7 +36,7 @@ const HeaderUnconnected: FC<IProps> = memo(
const [is_scrolled, setIsScrolled] = useState(false);
const onLogin = useCallback(() => showDialog(DIALOGS.LOGIN), [showDialog]);
const onProfileClick = useCallback(() => authOpenProfile(username), [authOpenProfile, user]);
// const onProfileClick = useCallback(() => authOpenProfile(username), [authOpenProfile, user]);
const onScroll = useCallback(() => {
const active = window.scrollY > 32;
@ -77,7 +77,7 @@ const HeaderUnconnected: FC<IProps> = memo(
)}
{is_user && (
<UserButton user={user} onLogout={authLogout} onProfileClick={onProfileClick} />
<UserButton user={user} onLogout={authLogout} authOpenProfile={authOpenProfile} />
)}
{!is_user && (

View file

@ -1,24 +1,35 @@
import React, { FC } from 'react';
import React, { FC, useCallback } from 'react';
import { Group } from '~/components/containers/Group';
import styles from './styles.scss';
import { getURL } from '~/utils/dom';
import { Icon } from '~/components/input/Icon';
import { IUser } from '~/redux/auth/types';
import { PRESETS } from '~/constants/urls';
import { Link } from 'react-router-dom';
import { authOpenProfile } from '~/redux/auth/actions';
interface IProps {
user: Partial<IUser>;
onLogout: () => void;
onProfileClick: () => void;
authOpenProfile: typeof authOpenProfile;
}
const UserButton: FC<IProps> = ({ user: { username, photo }, onProfileClick, onLogout }) => (
const UserButton: FC<IProps> = ({ user: { username, photo }, authOpenProfile, onLogout }) => {
const onProfileOpen = useCallback(() => {
authOpenProfile(username, 'profile');
}, [authOpenProfile, username]);
const onSettingsOpen = useCallback(() => {
authOpenProfile(username, 'settings');
}, [authOpenProfile, username]);
// const onMessagesOpen = useCallback(() => {
// authOpenProfile(username, 'messages');
// }, [authOpenProfile, username]);
return (
<div className={styles.wrap}>
<Group horizontal className={styles.user_button}>
<div className={styles.username} onClick={onProfileClick}>
{username}
</div>
<div className={styles.username}>{username}</div>
<div
className={styles.user_avatar}
@ -29,9 +40,12 @@ const UserButton: FC<IProps> = ({ user: { username, photo }, onProfileClick, onL
</Group>
<div className={styles.menu}>
<div onClick={onProfileOpen}>Профиль</div>
<div onClick={onSettingsOpen}>Настройки</div>
<div onClick={onLogout}>Выдох</div>
</div>
</div>
);
};
export { UserButton };

View file

@ -17,6 +17,8 @@
z-index: 1;
box-sizing: border-box;
padding: $gap;
display: none;
flex-direction: column;
&::after {
content: ' ';
@ -29,6 +31,7 @@
right: 0;
top: -4px;
transform: translate(-20px, 0);
z-index: -1;
}
& > div {
@ -38,6 +41,8 @@
box-sizing: border-box;
transition: opacity 0.25s;
width: 100%;
padding-right: 40px;
transition: background-color 0.25s;
&:first-child {
border-top-left-radius: $radius;
@ -48,6 +53,10 @@
border-bottom-left-radius: $radius;
border-bottom-right-radius: $radius;
}
&:hover {
background-color: $secondary;
}
}
&:hover > div {