mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
refactored some common components
This commit is contained in:
parent
5e9c111e0f
commit
a9a220273f
67 changed files with 238 additions and 220 deletions
|
@ -1,19 +1,18 @@
|
|||
import React, { FC, memo, useMemo } from 'react';
|
||||
|
||||
import { Icon } from '~/components/input/Icon';
|
||||
import { Icon } from '~/components/common/Icon';
|
||||
import { ICommentBlockProps } from '~/constants/comment';
|
||||
import { useYoutubeMetadata } from '~/hooks/metadata/useYoutubeMetadata';
|
||||
import { getYoutubeThumb } from '~/utils/dom';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
||||
type Props = ICommentBlockProps & {};
|
||||
|
||||
const CommentEmbedBlock: FC<Props> = memo(({ block }) => {
|
||||
const id = useMemo(() => {
|
||||
const match = block.content.match(
|
||||
/https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch)?(?:\?v=)?([\w\-=]+)/
|
||||
/https?:\/\/(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch)?(?:\?v=)?([\w\-=]+)/,
|
||||
);
|
||||
|
||||
return (match && match[1]) || '';
|
||||
|
@ -21,7 +20,10 @@ const CommentEmbedBlock: FC<Props> = memo(({ block }) => {
|
|||
|
||||
const url = useMemo(() => `https://youtube.com/watch?v=${id}`, [id]);
|
||||
|
||||
const preview = useMemo(() => getYoutubeThumb(block.content), [block.content]);
|
||||
const preview = useMemo(
|
||||
() => getYoutubeThumb(block.content),
|
||||
[block.content],
|
||||
);
|
||||
|
||||
const metadata = useYoutubeMetadata(id);
|
||||
const title = metadata?.metadata?.title || '';
|
||||
|
|
|
@ -3,7 +3,7 @@ import { FC } from 'react';
|
|||
import classNames from 'classnames';
|
||||
|
||||
import { Hoverable } from '~/components/common/Hoverable';
|
||||
import { Icon } from '~/components/input/Icon';
|
||||
import { Icon } from '~/components/common/Icon';
|
||||
import { imagePresets } from '~/constants/urls';
|
||||
import { IFile } from '~/types';
|
||||
import { getURL } from '~/utils/dom';
|
||||
|
|
|
@ -2,7 +2,7 @@ import React, { FC } from 'react';
|
|||
|
||||
import classnames from 'classnames';
|
||||
|
||||
import { Icon } from '~/components/input/Icon';
|
||||
import { Icon } from '~/components/common/Icon';
|
||||
|
||||
import styles from './styles.module.scss';
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React, { FC, useMemo } from 'react';
|
||||
|
||||
import { CornerMenu } from '~/components/common/CornerMenu';
|
||||
import { CornerMenu } from '~/components/menu/CornerMenu';
|
||||
|
||||
interface IProps {
|
||||
onEdit: () => void;
|
||||
|
@ -16,7 +16,7 @@ const CommentMenu: FC<IProps> = ({ onEdit, onDelete }) => {
|
|||
},
|
||||
{ title: 'Удалить', action: onDelete },
|
||||
],
|
||||
[onEdit, onDelete]
|
||||
[onEdit, onDelete],
|
||||
);
|
||||
|
||||
return <CornerMenu actions={actions} />;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue