feat(utils): add difficulty color utility and update type imports

This commit is contained in:
cfngc4594 2025-03-30 20:30:58 +08:00
parent 192d882fdd
commit 25920fcb68

View File

@ -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";
}
};