1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-26 05:16:41 +07:00
vault-frontend/src/components/node/NodeEditMenu/index.tsx
muerwre 080d59858c
Отрефакторил бэк, исправил ошибки (#138)
* fixed paths to match refactored backend

* fixed some paths according to new backend

* fixed auth urls for new endpoints

* fixed urls

* fixed error handling

* fixes

* fixed error handling on user form

* fixed error handling on oauth

* using fallback: true on node pages

* type button for comment attach buttons

* fixed return types of social delete

* changed the way we upload user avatars
2022-09-16 14:53:52 +07:00

91 lines
2.3 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { VFC } from 'react';
import Tippy from '@tippyjs/react';
import { Icon } from '~/components/input/Icon';
import { MenuButton } from '~/components/menu/MenuButton';
import { MenuItemWithIcon } from '~/components/menu/MenuItemWithIcon';
import { SeparatedMenu } from '~/components/menu/SeparatedMenu';
import { useWindowSize } from '~/hooks/dom/useWindowSize';
import styles from './styles.module.scss';
interface NodeEditMenuProps {
className?: string;
canStar: boolean;
isHeroic: boolean;
isLocked: boolean;
onStar: () => void;
onLock: () => void;
onEdit: () => void;
}
const NodeEditMenu: VFC<NodeEditMenuProps> = ({
className,
canStar,
isHeroic,
isLocked,
onStar,
onLock,
onEdit,
}) => {
const { isTablet } = useWindowSize();
if (isTablet) {
return (
<MenuButton
icon={<Icon icon="dots-vertical" className={styles.icon} size={24} />}
className={className}
>
{canStar && (
<MenuItemWithIcon
icon={isHeroic ? 'star_full' : 'star'}
onClick={onStar}
>
{isHeroic ? 'Убрать с главной' : 'На главную'}
</MenuItemWithIcon>
)}
<MenuItemWithIcon icon="edit" onClick={onEdit}>
Редактировать
</MenuItemWithIcon>
<MenuItemWithIcon
icon={isLocked ? 'locked' : 'unlocked'}
onClick={onLock}
>
{isLocked ? 'Восстановить' : 'Удалить'}
</MenuItemWithIcon>
</MenuButton>
);
}
return (
<SeparatedMenu>
{canStar && (
<Tippy content={isHeroic ? 'Убрать с главной' : 'На главную'}>
<button className={className} onClick={onStar}>
<Icon icon={isHeroic ? 'star_full' : 'star'} size={24} />
</button>
</Tippy>
)}
<Tippy content="Редактировать">
<button className={className} onClick={onEdit}>
<Icon icon="edit" size={24} />
</button>
</Tippy>
<Tippy content={isLocked ? 'Восстановить' : 'Удалить'}>
<button className={className} onClick={onLock}>
<Icon icon={isLocked ? 'locked' : 'unlocked'} size={24} />
</button>
</Tippy>
</SeparatedMenu>
);
};
export { NodeEditMenu };