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

fixed youtube block

This commit is contained in:
Fedor Katurov 2019-11-26 11:07:40 +07:00
parent 93afa626db
commit b87487ed1f
7 changed files with 34 additions and 7 deletions

View file

@ -0,0 +1,23 @@
import React, { FC, memo } from 'react';
import { ICommentBlock } from '~/constants/comment';
import styles from './styles.scss';
interface IProps {
block: ICommentBlock;
}
const CommentEmbedBlock: FC<IProps> = memo(({ block }) => {
const link = block.content.match(
/(https?:\/\/(www\.)?(youtube\.com|youtu\.be)\/(watch)?(\?v=)?[\w\-]+)/gi
);
return (
<div className={styles.text}>
<a href={link[0]} target="_blank">
{link[0]}
</a>
</div>
);
});
export { CommentEmbedBlock };

View file

@ -0,0 +1,3 @@
.text {
padding: 0 $gap;
}

View file

@ -1,5 +1,5 @@
.text {
padding: $gap;
padding: 0 $gap;
font-weight: 300;
font: $font_16_medium;
line-height: 20px;

View file

@ -31,7 +31,7 @@ const CommentContent: FC<IProps> = memo(({ comment }) => {
return (
<>
{comment.text && (
<div className={styles.block}>
<Group className={styles.block}>
{formatCommentText(path(['user', 'username'], comment), comment.text).map(
(block, key) =>
COMMENT_BLOCK_RENDERERS[block.type] &&
@ -39,7 +39,7 @@ const CommentContent: FC<IProps> = memo(({ comment }) => {
)}
<div className={styles.date}>{getPrettyDate(comment.created_at)}</div>
</div>
</Group>
)}
{groupped.image && groupped.image.length > 0 && (

View file

@ -11,6 +11,7 @@
padding-bottom: 10px;
box-sizing: border-box;
flex-direction: column;
padding: $gap 0;
&:first-child {
border-top-right-radius: $radius;

View file

@ -1,4 +1,5 @@
import { CommentTextBlock } from '~/components/comment/CommentTextBlock';
import { CommentEmbedBlock } from '~/components/comment/CommentEmbedBlock';
export const COMMENT_BLOCK_TYPES = {
TEXT: 'TEXT',
@ -29,5 +30,5 @@ export type ICommentBlock = {
export const COMMENT_BLOCK_RENDERERS = {
[COMMENT_BLOCK_TYPES.TEXT]: CommentTextBlock,
[COMMENT_BLOCK_TYPES.MARK]: CommentTextBlock,
[COMMENT_BLOCK_TYPES.EMBED]: CommentTextBlock,
[COMMENT_BLOCK_TYPES.EMBED]: CommentEmbedBlock,
};

View file

@ -21,9 +21,6 @@ render(
/*
[Stage 0]:
- <...> format
- youtube embeds
- check if email is registered at social login
- friendship
- cover change
@ -48,6 +45,8 @@ render(
- comment editing
Done:
- <...> format
- youtube embeds
- mobile header
- sticky header
- password restore