From a7b4daec212a7e0275ec7e5184de5e644e695a3c Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Fri, 4 Nov 2022 11:21:01 +0800 Subject: [PATCH] [offers][feat] revamp comments section --- .../offers/profile/ProfileComments.tsx | 22 ++++-------- .../offers/profile/ProfileDetails.tsx | 2 +- .../offers/profile/ProfilePhotoHolder.tsx | 4 +-- .../offers/profile/comments/CommentCard.tsx | 35 +++++++++++-------- .../comments/ExpandableCommentCard.tsx | 26 +++++++------- 5 files changed, 43 insertions(+), 46 deletions(-) diff --git a/apps/portal/src/components/offers/profile/ProfileComments.tsx b/apps/portal/src/components/offers/profile/ProfileComments.tsx index 34ac8b67..0eeaa1a3 100644 --- a/apps/portal/src/components/offers/profile/ProfileComments.tsx +++ b/apps/portal/src/components/offers/profile/ProfileComments.tsx @@ -1,13 +1,7 @@ import { signIn, useSession } from 'next-auth/react'; import { useState } from 'react'; import { ClipboardDocumentIcon, ShareIcon } from '@heroicons/react/24/outline'; -import { - Button, - HorizontalDivider, - Spinner, - TextArea, - useToast, -} from '@tih/ui'; +import { Button, Spinner, TextArea, useToast } from '@tih/ui'; import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics'; import ExpandableCommentCard from '~/components/offers/profile/comments/ExpandableCommentCard'; @@ -110,8 +104,8 @@ export default function ProfileComments({ ); } return ( -
-
+
+
@@ -169,7 +163,7 @@ export default function ProfileComments({
-
+

Discussions

{isEditable || session?.user?.name ? (
@@ -199,11 +193,9 @@ export default function ProfileComments({ />
-
) : (
-
-
    +
    +
      {replies?.map((reply: Reply) => ( -
    • +
    • +
      {!analysis ? (

      No analysis available.

      ) : ( diff --git a/apps/portal/src/components/offers/profile/ProfilePhotoHolder.tsx b/apps/portal/src/components/offers/profile/ProfilePhotoHolder.tsx index 3cfb3745..372d9f06 100644 --- a/apps/portal/src/components/offers/profile/ProfilePhotoHolder.tsx +++ b/apps/portal/src/components/offers/profile/ProfilePhotoHolder.tsx @@ -1,11 +1,11 @@ type ProfilePhotoHolderProps = Readonly<{ - size?: 'lg' | 'sm'; + size?: 'lg' | 'sm' | 'xs'; }>; export default function ProfilePhotoHolder({ size = 'lg', }: ProfilePhotoHolderProps) { - const sizeMap = { lg: '16', sm: '12' }; + const sizeMap = { lg: '16', sm: '12', xs: '10' }; return ( diff --git a/apps/portal/src/components/offers/profile/comments/CommentCard.tsx b/apps/portal/src/components/offers/profile/comments/CommentCard.tsx index 9f0a0bef..b958d329 100644 --- a/apps/portal/src/components/offers/profile/comments/CommentCard.tsx +++ b/apps/portal/src/components/offers/profile/comments/CommentCard.tsx @@ -2,6 +2,8 @@ import { signIn, useSession } from 'next-auth/react'; import { useState } from 'react'; import { Button, Dialog, TextArea, useToast } from '@tih/ui'; +import ProfilePhotoHolder from '~/components/offers/profile/ProfilePhotoHolder'; + import { timeSinceNow } from '~/utils/offers/time'; import { trpc } from '~/utils/trpc'; @@ -121,14 +123,18 @@ export default function CommentCard({ return (
      - {/*
      - -
      */} -
      +
      + {user?.image ? ( + {user?.name + ) : ( + + )} +
      +

      {user?.name ?? 'unknown user'} @@ -137,35 +143,35 @@ export default function CommentCard({

      {message}

      -
      +
      {timeSinceNow(createdAt)} ago {' '} - ·{' '} {replyLength > 0 && ( <> + ·{' '} - ·{' '} )} {!disableReply && ( <> + ·{' '} - ·{' '} )} {deletable && ( <> + ·{' '}