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:
parent
86622d6aa6
commit
aed888e894
3 changed files with 45 additions and 22 deletions
|
@ -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 && (
|
||||
|
|
|
@ -1,37 +1,51 @@
|
|||
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 }) => (
|
||||
<div className={styles.wrap}>
|
||||
<Group horizontal className={styles.user_button}>
|
||||
<div className={styles.username} onClick={onProfileClick}>
|
||||
{username}
|
||||
</div>
|
||||
const UserButton: FC<IProps> = ({ user: { username, photo }, authOpenProfile, onLogout }) => {
|
||||
const onProfileOpen = useCallback(() => {
|
||||
authOpenProfile(username, 'profile');
|
||||
}, [authOpenProfile, username]);
|
||||
|
||||
<div
|
||||
className={styles.user_avatar}
|
||||
style={{ backgroundImage: `url('${getURL(photo, PRESETS.avatar)}')` }}
|
||||
>
|
||||
{(!photo || !photo.id) && <Icon icon="profile" />}
|
||||
</div>
|
||||
</Group>
|
||||
const onSettingsOpen = useCallback(() => {
|
||||
authOpenProfile(username, 'settings');
|
||||
}, [authOpenProfile, username]);
|
||||
|
||||
<div className={styles.menu}>
|
||||
<div onClick={onLogout}>Выдох</div>
|
||||
// const onMessagesOpen = useCallback(() => {
|
||||
// authOpenProfile(username, 'messages');
|
||||
// }, [authOpenProfile, username]);
|
||||
|
||||
return (
|
||||
<div className={styles.wrap}>
|
||||
<Group horizontal className={styles.user_button}>
|
||||
<div className={styles.username}>{username}</div>
|
||||
|
||||
<div
|
||||
className={styles.user_avatar}
|
||||
style={{ backgroundImage: `url('${getURL(photo, PRESETS.avatar)}')` }}
|
||||
>
|
||||
{(!photo || !photo.id) && <Icon icon="profile" />}
|
||||
</div>
|
||||
</Group>
|
||||
|
||||
<div className={styles.menu}>
|
||||
<div onClick={onProfileOpen}>Профиль</div>
|
||||
<div onClick={onSettingsOpen}>Настройки</div>
|
||||
<div onClick={onLogout}>Выдох</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
);
|
||||
};
|
||||
|
||||
export { UserButton };
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue