mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-05-07 02:26:41 +07:00
Добавили заметки в сайдбар (#126)
* added notes sidebar * added note dropping and editing * added sidebar navigation * handling sidebarchanges over time * using router back for closing sidebar * fixed tripping inside single sidebar * added superpowers toggle to sidebar * user button opens sidebar now * added profile cover for profile sidebar * removed profile sidebar completely * ran prettier over project * added note not found error literal
This commit is contained in:
parent
fe3db608d6
commit
5d34090238
72 changed files with 1241 additions and 664 deletions
src/components/main/UserButton
|
@ -1,52 +1,35 @@
|
|||
import React, { FC, useCallback } from 'react';
|
||||
import { FC } from 'react';
|
||||
|
||||
import { Group } from '~/components/containers/Group';
|
||||
import { Icon } from '~/components/input/Icon';
|
||||
import { MenuButton, MenuItemWithIcon } from '~/components/menu';
|
||||
import { ImagePresets } from '~/constants/urls';
|
||||
import { IUser } from '~/types/auth';
|
||||
import { IFile } from '~/types';
|
||||
import { getURL } from '~/utils/dom';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
interface IProps {
|
||||
user: Partial<IUser>;
|
||||
onLogout: () => void;
|
||||
authOpenProfile: () => void;
|
||||
username: string;
|
||||
photo?: IFile;
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
const UserButton: FC<IProps> = ({ user: { username, photo }, authOpenProfile, onLogout }) => {
|
||||
const onProfileOpen = useCallback(() => {
|
||||
authOpenProfile();
|
||||
}, [authOpenProfile]);
|
||||
|
||||
const onSettingsOpen = useCallback(() => {
|
||||
authOpenProfile();
|
||||
}, [authOpenProfile]);
|
||||
|
||||
const UserButton: FC<IProps> = ({ username, photo, onClick }) => {
|
||||
return (
|
||||
<div className={styles.wrap}>
|
||||
<button className={styles.wrap} onClick={onClick}>
|
||||
<Group horizontal className={styles.user_button}>
|
||||
<div className={styles.username}>{username}</div>
|
||||
|
||||
<MenuButton
|
||||
position="bottom"
|
||||
translucent={false}
|
||||
icon={
|
||||
<div
|
||||
className={styles.user_avatar}
|
||||
style={{ backgroundImage: `url('${getURL(photo, ImagePresets.avatar)}')` }}
|
||||
>
|
||||
{(!photo || !photo.id) && <Icon icon="profile" />}
|
||||
</div>
|
||||
}
|
||||
<div
|
||||
className={styles.user_avatar}
|
||||
style={{
|
||||
backgroundImage: `url('${getURL(photo, ImagePresets.avatar)}')`,
|
||||
}}
|
||||
>
|
||||
<MenuItemWithIcon onClick={onProfileOpen}>Профиль</MenuItemWithIcon>
|
||||
<MenuItemWithIcon onClick={onSettingsOpen}>Настройки</MenuItemWithIcon>
|
||||
<MenuItemWithIcon onClick={onLogout}>Выдох</MenuItemWithIcon>
|
||||
</MenuButton>
|
||||
{(!photo || !photo.id) && <Icon icon="profile" />}
|
||||
</div>
|
||||
</Group>
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue