1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-25 04:46:40 +07:00

Merge branch 'master' into 15-use-cra-or-nextjs

# Conflicts:
#	src/components/node/CommentForm/index.tsx
#	src/utils/node.ts
This commit is contained in:
Fedor Katurov 2020-11-19 16:29:03 +07:00
commit 332d09e3bd
46 changed files with 936 additions and 487 deletions

View file

@ -0,0 +1,33 @@
import React, { FC, useState, useCallback } from 'react';
import styles from './styles.module.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 };

View file

@ -0,0 +1,73 @@
@import "src/styles/variables";
.wrap {
position: absolute;
right: 0;
top: 0;
width: 48px;
height: 48px;
z-index: 10;
outline: none;
cursor: pointer;
&:hover {
.dot {
background: $secondary;
}
}
}
.dot {
width: 10px;
height: 10px;
border-radius: 100%;
background: transparentize(black, 0.7);
position: absolute;
right: 6px;
top: 6px;
transition: background 0.25s;
}
@keyframes appear {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
.menu {
position: absolute;
right: 5px;
top: 5px;
display: flex;
flex-direction: column;
z-index: 6;
white-space: nowrap;
animation: appear 0.25s forwards;
}
.item {
user-select: none;
font: $font_12_semibold;
text-transform: uppercase;
padding: 8px $gap;
background: $content_bg;
cursor: pointer;
&:first-child {
border-top-left-radius: $radius;
border-top-right-radius: $radius;
}
&:last-child {
border-bottom-left-radius: $radius;
border-bottom-right-radius: $radius;
}
&:hover {
background: $primary;
}
}