diff --git a/src/components/node/Comment/index.tsx b/src/components/node/Comment/index.tsx index 2ec98a02..08432595 100644 --- a/src/components/node/Comment/index.tsx +++ b/src/components/node/Comment/index.tsx @@ -2,6 +2,8 @@ import React, { FC, HTMLAttributes } from 'react'; import { CommentWrapper } from '~/components/containers/CommentWrapper'; import { IComment } from '~/redux/types'; import * as styles from './styles.scss'; +import { formatCommentText } from '~/utils/dom'; +import { Group } from '~/components/containers/Group'; type IProps = HTMLAttributes & { is_empty?: boolean; @@ -12,7 +14,14 @@ type IProps = HTMLAttributes & { const Comment: FC = ({ comment, is_empty, is_loading, className, photo, ...props }) => ( - {comment.text &&
{comment.text}
} + {comment.text && ( + + )}
); diff --git a/src/components/node/Comment/styles.scss b/src/components/node/Comment/styles.scss index 39eb504e..1531367a 100644 --- a/src/components/node/Comment/styles.scss +++ b/src/components/node/Comment/styles.scss @@ -1,3 +1,8 @@ .text { padding: $gap / 2; + font-weight: 300; + + b { + font-weight: 600; + } } diff --git a/src/redux/node/constants.ts b/src/redux/node/constants.ts index 7a10fd33..2eef245f 100644 --- a/src/redux/node/constants.ts +++ b/src/redux/node/constants.ts @@ -63,5 +63,5 @@ export const EMPTY_COMMENT: IComment = { text: '', files: [], is_private: false, - owner: null, + user: null, }; diff --git a/src/redux/types.ts b/src/redux/types.ts index eb6383a6..b3d6eaa1 100644 --- a/src/redux/types.ts +++ b/src/redux/types.ts @@ -118,7 +118,7 @@ export interface IComment { text: string; files: IFile[]; is_private: boolean; - owner: IUser; + user: IUser; created_at?: string; update_at?: string; diff --git a/src/utils/dom.ts b/src/utils/dom.ts index 7edebc03..af073a8a 100644 --- a/src/utils/dom.ts +++ b/src/utils/dom.ts @@ -55,4 +55,13 @@ export const describeArc = ( export const getURL = url => `${process.env.API_HOST}${url}`; export const getImageSize = (image: string, size?: string): string => - `${process.env.API_HOST}${image}`; + `${process.env.API_HOST}${image}`.replace('{size}', size); + +export const formatCommentText = (author, text: string) => + text + .replace(/(\n{2,})/gi, '\n') + .replace(//g, '>') + .split('\n') + .map((el, index) => (index === 0 ? `

${author}: ${el}

` : `

${el}

`)) + .join('');