1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-05-07 02:26:41 +07:00

Добавили заметки в сайдбар ()

* 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:
muerwre 2022-08-12 14:07:19 +07:00 committed by GitHub
parent fe3db608d6
commit 5d34090238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
72 changed files with 1241 additions and 664 deletions
src/components/main/UserButton

View file

@ -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>
);
};