From 362c8391d92677afc8d890017d563b6122a454c1 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Tue, 8 Nov 2022 20:54:54 +0800 Subject: [PATCH] [questions][feat] tweak card UI --- .../questions/AddToListDropdown.tsx | 2 +- .../questions/QuestionAggregateBadge.tsx | 23 +++-- .../components/questions/VotingButtons.tsx | 56 +++++++----- .../card/question/BaseQuestionCard.tsx | 90 +++++++++---------- apps/portal/src/pages/questions/browse.tsx | 2 +- 5 files changed, 89 insertions(+), 84 deletions(-) diff --git a/apps/portal/src/components/questions/AddToListDropdown.tsx b/apps/portal/src/components/questions/AddToListDropdown.tsx index 039edd7e..d238bd6e 100644 --- a/apps/portal/src/components/questions/AddToListDropdown.tsx +++ b/apps/portal/src/components/questions/AddToListDropdown.tsx @@ -106,7 +106,7 @@ export default function AddToListDropdown({ const CustomMenuButton = ({ children }: PropsWithChildren) => ( {visible && (
diff --git a/apps/portal/src/components/questions/VotingButtons.tsx b/apps/portal/src/components/questions/VotingButtons.tsx index 28824715..62d4ebcf 100644 --- a/apps/portal/src/components/questions/VotingButtons.tsx +++ b/apps/portal/src/components/questions/VotingButtons.tsx @@ -1,8 +1,7 @@ +import clsx from 'clsx'; import React from 'react'; import { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'; import type { Vote } from '@prisma/client'; -import type { ButtonSize } from '@tih/ui'; -import { Button } from '@tih/ui'; import { useProtectedCallback } from '~/utils/questions/useProtectedCallback'; @@ -18,7 +17,7 @@ export type VotingButtonsCallbackProps = { }; export type VotingButtonsProps = VotingButtonsCallbackProps & { - size?: ButtonSize; + size?: 'md' | 'sm'; upvoteCount: number; }; @@ -29,11 +28,6 @@ export default function VotingButtons({ upvoteCount, size = 'md', }: VotingButtonsProps) { - const upvoteButtonVariant = - vote?.vote === 'UPVOTE' ? 'secondary' : 'tertiary'; - const downvoteButtonVariant = - vote?.vote === 'DOWNVOTE' ? 'secondary' : 'tertiary'; - const handleUpvoteClick = useProtectedCallback(() => { onUpvote(); }); @@ -44,31 +38,45 @@ export default function VotingButtons({ return (
-

{upvoteCount}

-
); } diff --git a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx index 2e7eff53..d3a01231 100644 --- a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx +++ b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx @@ -1,5 +1,10 @@ import clsx from 'clsx'; import { useMemo, useState } from 'react'; +import { + BuildingOfficeIcon, + MapPinIcon, + UserCircleIcon, +} from '@heroicons/react/20/solid'; import { ChatBubbleBottomCenterTextIcon, CheckIcon, @@ -198,21 +203,24 @@ export default function BaseQuestionCard({
)} -
-
-
+
+
+
{showAggregateStatistics && ( <> - + )} {timestamp !== null && ( @@ -240,59 +248,43 @@ export default function BaseQuestionCard({

{content}

+ {!showReceivedForm && (showAnswerStatistics || showReceivedStatistics || showCreateEncounterButton) && ( -
+
{showAnswerStatistics && ( - <> -
-
-
-
- + {answerCount} {answerCount === 1 ? 'answer' : 'answers'} + +
)} {showReceivedStatistics && ( - <> -
-
-
-
- +
+ +
)} {showCreateEncounterButton && (
-
+
{(questionsQueryData?.pages ?? []).flatMap( ({ data: questions }) => questions.map((question) => {