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

displaying comment images

This commit is contained in:
Fedor Katurov 2019-10-09 19:30:55 +07:00
parent 1974feb042
commit 4ed2957cb4
3 changed files with 18 additions and 2 deletions

View file

@ -2,8 +2,9 @@ import React, { FC, HTMLAttributes } from 'react';
import { CommentWrapper } from '~/components/containers/CommentWrapper'; import { CommentWrapper } from '~/components/containers/CommentWrapper';
import { IComment } from '~/redux/types'; import { IComment } from '~/redux/types';
import * as styles from './styles.scss'; import * as styles from './styles.scss';
import { formatCommentText } from '~/utils/dom'; import { formatCommentText, getURL } from '~/utils/dom';
import { Group } from '~/components/containers/Group'; import { Group } from '~/components/containers/Group';
import { ImageUpload } from '~/components/upload/ImageUpload';
type IProps = HTMLAttributes<HTMLDivElement> & { type IProps = HTMLAttributes<HTMLDivElement> & {
is_empty?: boolean; is_empty?: boolean;
@ -22,6 +23,14 @@ const Comment: FC<IProps> = ({ comment, is_empty, is_loading, className, photo,
}} }}
/> />
)} )}
{comment.files && comment.files.length > 0 && (
<div className={styles.images}>
{comment.files.map(file => (
<ImageUpload thumb={getURL(file.url)} />
))}
</div>
)}
</CommentWrapper> </CommentWrapper>
); );

View file

@ -6,3 +6,10 @@
font-weight: 600; font-weight: 600;
} }
} }
.images {
padding: 10px;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
column-gap: $grid_line;
}

View file

@ -86,7 +86,7 @@ function* onPostComment({ id }: ReturnType<typeof nodePostComment>) {
yield put(nodeSetSendingComment(true)); yield put(nodeSetSendingComment(true));
const { const {
data: { comment, id: target_id }, data: { comment },
error, error,
} = yield call(reqWrapper, postNodeComment, { data: comment_data[id], id: current.id }); } = yield call(reqWrapper, postNodeComment, { data: comment_data[id], id: current.id });
yield put(nodeSetSendingComment(false)); yield put(nodeSetSendingComment(false));