From 25920fcb68e72842245e076e4f25a9e388d1b3dc Mon Sep 17 00:00:00 2001 From: cfngc4594 Date: Sun, 30 Mar 2025 20:30:58 +0800 Subject: [PATCH] feat(utils): add difficulty color utility and update type imports --- src/lib/utils.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 17c7ba2..155ffeb 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,6 +1,6 @@ import { twMerge } from "tailwind-merge"; import { clsx, type ClassValue } from "clsx"; -import { EditorLanguageConfig } from "@prisma/client"; +import type { EditorLanguageConfig, Difficulty } from "@prisma/client"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); @@ -12,3 +12,16 @@ export function getPath( ) { return `file:///${problemId}/${editorLanguageConfig.fileName}${editorLanguageConfig.fileExtension}`; } + +export const getDifficultyColorClass = (difficulty: Difficulty) => { + switch (difficulty) { + case "EASY": + return "text-green-500"; + case "MEDIUM": + return "text-yellow-500"; + case "HARD": + return "text-red-500"; + default: + return "text-gray-500"; + } +};