1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 21:06:42 +07:00
vault-frontend/src/components/node/CommentMenu/index.tsx
2019-12-03 15:08:20 +07:00

33 lines
932 B
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, { FC, useState, useCallback } from 'react';
import styles from './styles.scss';
interface IProps {
onEdit: () => void;
onDelete: () => void;
}
const CommentMenu: FC<IProps> = ({ onEdit, onDelete }) => {
const [is_menu_opened, setIsMenuOpened] = useState(false);
const onFocus = useCallback(() => setIsMenuOpened(true), [setIsMenuOpened]);
const onBlur = useCallback(() => setIsMenuOpened(false), [setIsMenuOpened]);
return (
<div className={styles.wrap} onFocus={onFocus} onBlur={onBlur} tabIndex={-1}>
<div className={styles.dot} />
{is_menu_opened && (
<div className={styles.menu}>
<div className={styles.item} onMouseDown={onEdit}>
Редактировать
</div>
<div className={styles.item} onMouseDown={onDelete}>
Удалить
</div>
</div>
)}
</div>
);
};
export { CommentMenu };