mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 21:06:42 +07:00
added notes menu
This commit is contained in:
parent
fce11163aa
commit
57f37723fa
14 changed files with 203 additions and 105 deletions
|
@ -3,6 +3,7 @@ import React, { VFC } from 'react';
|
|||
import { Card } from '~/components/containers/Card';
|
||||
import { Markdown } from '~/components/containers/Markdown';
|
||||
import { Padder } from '~/components/containers/Padder';
|
||||
import { NoteMenu } from '~/components/notes/NoteMenu';
|
||||
import { formatText, getPrettyDate } from '~/utils/dom';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
@ -15,8 +16,10 @@ interface NoteCardProps {
|
|||
const NoteCard: VFC<NoteCardProps> = ({ content, createdAt }) => (
|
||||
<Card className={styles.note}>
|
||||
<Padder>
|
||||
<NoteMenu onEdit={console.log} onDelete={console.log} />
|
||||
<Markdown className={styles.wrap} dangerouslySetInnerHTML={{ __html: formatText(content) }} />
|
||||
</Padder>
|
||||
|
||||
<Padder className={styles.footer}>{getPrettyDate(createdAt)}</Padder>
|
||||
</Card>
|
||||
);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
min-width: 0;
|
||||
word-break: break-word;
|
||||
padding: 0;
|
||||
position: relative;
|
||||
|
||||
& > * {
|
||||
@include row_shadow;
|
||||
|
|
25
src/components/notes/NoteMenu/index.tsx
Normal file
25
src/components/notes/NoteMenu/index.tsx
Normal file
|
@ -0,0 +1,25 @@
|
|||
import React, { useMemo, VFC } from 'react';
|
||||
|
||||
import { CornerMenu } from '~/components/common/CornerMenu';
|
||||
|
||||
interface NoteMenuProps {
|
||||
onEdit: () => void;
|
||||
onDelete: () => void;
|
||||
}
|
||||
|
||||
const NoteMenu: VFC<NoteMenuProps> = ({ onEdit, onDelete }) => {
|
||||
const actions = useMemo(
|
||||
() => [
|
||||
{
|
||||
title: 'Редактировать',
|
||||
action: onEdit,
|
||||
},
|
||||
{ title: 'Удалить', action: onDelete },
|
||||
],
|
||||
[onEdit, onDelete]
|
||||
);
|
||||
|
||||
return <CornerMenu actions={actions} />;
|
||||
};
|
||||
|
||||
export { NoteMenu };
|
Loading…
Add table
Add a link
Reference in a new issue