From c2599d6a8c49a368e5862cb6a68cedfea77f1ea2 Mon Sep 17 00:00:00 2001 From: Jeff Sieu Date: Wed, 9 Nov 2022 12:48:45 +0800 Subject: [PATCH] [questions][ui] move QuestionTypeBadge icon to start --- .../questions/QuestionTypeBadge.tsx | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/apps/portal/src/components/questions/QuestionTypeBadge.tsx b/apps/portal/src/components/questions/QuestionTypeBadge.tsx index fe62351e..2f40467d 100644 --- a/apps/portal/src/components/questions/QuestionTypeBadge.tsx +++ b/apps/portal/src/components/questions/QuestionTypeBadge.tsx @@ -1,4 +1,12 @@ +import type { ComponentProps } from 'react'; +import { + BookOpenIcon, + ChatBubbleLeftRightIcon, + CodeBracketIcon, + WrenchIcon, +} from '@heroicons/react/20/solid'; import type { QuestionsQuestionType } from '@prisma/client'; +import type { BadgeVariant } from '@tih/ui'; import { Badge } from '@tih/ui'; import { QUESTION_TYPES } from '~/utils/questions/constants'; @@ -7,11 +15,29 @@ export type QuestionTypeBadgeProps = { type: QuestionsQuestionType; }; +type BadgeProps = ComponentProps; + +const variantMap: Record = { + BEHAVIORAL: 'danger', + CODING: 'info', + SYSTEM_DESIGN: 'warning', + THEORY: 'success', +}; + +const iconMap: Record['endAddOn']> = + { + BEHAVIORAL: ChatBubbleLeftRightIcon, + CODING: CodeBracketIcon, + SYSTEM_DESIGN: WrenchIcon, + THEORY: BookOpenIcon, + }; + export default function QuestionTypeBadge({ type }: QuestionTypeBadgeProps) { return ( value === type)!.label} - variant="info" + startAddOn={iconMap[type]} + variant={variantMap[type]} /> ); }