From 10435bad4087e8d4d77875ba0e22b72058b99b43 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Tue, 8 Nov 2022 21:51:17 +0800 Subject: [PATCH] [questions][feat] tweak comment and answer pages --- .../questions/SortOptionsSelect.tsx | 4 +- .../components/questions/card/AnswerCard.tsx | 50 +++++--- .../card/question/BaseQuestionCard.tsx | 2 +- .../questions/comments/CommentListItem.tsx | 22 ++-- .../forms/CreateQuestionEncounterForm.tsx | 3 + .../questions/layout/BackButtonLayout.tsx | 7 +- .../questions/typeahead/ExpandedTypeahead.tsx | 3 +- .../answer/[answerId]/[answerSlug]/index.tsx | 8 +- .../[questionId]/[questionSlug]/index.tsx | 120 +++++++++--------- 9 files changed, 123 insertions(+), 96 deletions(-) diff --git a/apps/portal/src/components/questions/SortOptionsSelect.tsx b/apps/portal/src/components/questions/SortOptionsSelect.tsx index 14e2d841..f9e8fa5a 100644 --- a/apps/portal/src/components/questions/SortOptionsSelect.tsx +++ b/apps/portal/src/components/questions/SortOptionsSelect.tsx @@ -36,7 +36,7 @@ export default function SortOptionsSelect({ return (
-
+
+ className={clsx( + 'flex gap-4 rounded-md border border-slate-200 bg-white p-4 sm:rounded-lg', + showHover && 'hover:bg-slate-50', + )}> -
+
{`${authorName} -

{authorName}

-

- Posted on: {format(createdAt, 'h:mm a, MMMM dd, yyyy')} + alt={authorName} + className="h-7 w-7 rounded-full" + src={authorImageUrl} + /> +

{authorName}

+ · +

+ {formatDistanceToNow(createdAt, { + addSuffix: true, + })}

-

{content}

- {commentCount !== undefined && ( -
- -

+

{content}

+
+ {commentCount !== undefined && ( +
- )} + + )} +
); diff --git a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx index d3a01231..0ebe99fe 100644 --- a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx +++ b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx @@ -315,7 +315,7 @@ export default function BaseQuestionCard({ return (
diff --git a/apps/portal/src/components/questions/comments/CommentListItem.tsx b/apps/portal/src/components/questions/comments/CommentListItem.tsx index 50c44f11..9af93929 100644 --- a/apps/portal/src/components/questions/comments/CommentListItem.tsx +++ b/apps/portal/src/components/questions/comments/CommentListItem.tsx @@ -1,4 +1,4 @@ -import { format } from 'date-fns'; +import { formatDistanceToNow } from 'date-fns'; import type { BackendVote } from '../VotingButtons'; import VotingButtons from '../VotingButtons'; @@ -25,7 +25,7 @@ export default function CommentListItem({ onUpvote, }: CommentListItemProps) { return ( -
+
{`${authorName} -

{authorName}

-

- Posted on: {format(createdAt, 'h:mm a, MMMM dd, yyyy')} + alt={authorName} + className="h-7 w-7 rounded-full" + src={authorImageUrl} + /> +

{authorName}

+ · +

+ {formatDistanceToNow(createdAt, { + addSuffix: true, + })}

-

{content}

+

{content}

); diff --git a/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx b/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx index 55e589a8..b230606a 100644 --- a/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx +++ b/apps/portal/src/components/questions/forms/CreateQuestionEncounterForm.tsx @@ -142,6 +142,7 @@ export default function CreateQuestionEncounterForm({ (step === 2 && selectedRole === null) } label="Next" + size="sm" variant="primary" onClick={() => { setStep(step + 1); @@ -152,6 +153,7 @@ export default function CreateQuestionEncounterForm({
{children}
-
+ ); } diff --git a/apps/portal/src/components/questions/typeahead/ExpandedTypeahead.tsx b/apps/portal/src/components/questions/typeahead/ExpandedTypeahead.tsx index f624f69d..7d56ea20 100644 --- a/apps/portal/src/components/questions/typeahead/ExpandedTypeahead.tsx +++ b/apps/portal/src/components/questions/typeahead/ExpandedTypeahead.tsx @@ -44,11 +44,12 @@ export default function ExpandedTypeahead({ ); return ( -
+
{suggestions.map((suggestion) => (
-
+

Comments

diff --git a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx index 0e981294..c526a9be 100644 --- a/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx +++ b/apps/portal/src/pages/questions/[questionId]/[questionSlug]/index.tsx @@ -200,8 +200,8 @@ export default function QuestionPage() { -
-
+
+
-
+
{`${question.numComments} comment(s)`}
}> -
-
-
-
- -
+
+
+
+
+
+
{(commentData?.pages ?? []).flatMap(({ data: comments }) => comments.map((comment) => ( )), )} - -
-