From 971e222d6bb5f03ad642d7acbbee30929b49b400 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Wed, 24 Mar 2021 17:21:27 +0700 Subject: [PATCH] #23 fixed lab post appearance --- src/components/lab/LabBottomPanel/index.tsx | 44 ++++++++++++------- .../lab/LabBottomPanel/styles.module.scss | 10 ++--- src/components/lab/LabPad/index.tsx | 12 +++-- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/components/lab/LabBottomPanel/index.tsx b/src/components/lab/LabBottomPanel/index.tsx index e1789a98..5139686a 100644 --- a/src/components/lab/LabBottomPanel/index.tsx +++ b/src/components/lab/LabBottomPanel/index.tsx @@ -1,4 +1,4 @@ -import React, { FC } from 'react'; +import React, { FC, useCallback } from 'react'; import { Group } from '~/components/containers/Group'; import { Filler } from '~/components/containers/Filler'; import styles from './styles.module.scss'; @@ -7,6 +7,8 @@ import { INode } from '~/redux/types'; import { Icon } from '~/components/input/Icon'; import classNames from 'classnames'; import { Grid } from '~/components/containers/Grid'; +import { useHistory } from 'react-router'; +import { URLS } from '~/constants/urls'; type Props = { node: INode; @@ -15,21 +17,33 @@ type Props = { commentCount: number; }; -const LabBottomPanel: FC = ({ node, hasNewComments, commentCount }) => ( - -
{getPrettyDate(node.created_at)}
- +const LabBottomPanel: FC = ({ node, hasNewComments, commentCount }) => { + const history = useHistory(); + const onClick = useCallback(() => history.push(URLS.NODE_URL(node.id)), [node.id]); - - - {node.like_count} - + return ( + +
{getPrettyDate(node.created_at)}
+ - - - {commentCount} - -
-); + {commentCount > 0 && ( + + + {commentCount} + + )} + + {!!node.like_count && node.like_count > 0 && ( + + + {node.like_count} + + )} +
+ ); +}; export { LabBottomPanel }; diff --git a/src/components/lab/LabBottomPanel/styles.module.scss b/src/components/lab/LabBottomPanel/styles.module.scss index 0a4be156..09a69c46 100644 --- a/src/components/lab/LabBottomPanel/styles.module.scss +++ b/src/components/lab/LabBottomPanel/styles.module.scss @@ -9,19 +9,17 @@ color: darken(white, 40%); } -.comments.comments { +.comments, .like { flex: 0; - font: $font_16_semibold; + font: $font_14_semibold; color: darken(white, 50%); fill: currentColor; stroke: none; column-gap: $gap / 2 !important; + align-items: center; + justify-content: center; &.active { color: $red; } } - -.like { - -} diff --git a/src/components/lab/LabPad/index.tsx b/src/components/lab/LabPad/index.tsx index 5432ad99..5d853a39 100644 --- a/src/components/lab/LabPad/index.tsx +++ b/src/components/lab/LabPad/index.tsx @@ -1,8 +1,14 @@ -import React, { FC } from 'react'; +import React, { FC, useCallback } from 'react'; import styles from './styles.module.scss'; +import { useHistory } from 'react-router'; +import { URLS } from '~/constants/urls'; +import { INodeComponentProps } from '~/redux/node/constants'; -interface IProps {} +const LabPad: FC = ({ node }) => { + const history = useHistory(); + const onClick = useCallback(() => history.push(URLS.NODE_URL(node.id)), [node.id]); -const LabPad: FC = () =>
; + return
; +}; export { LabPad };