diff --git a/frontend/src/components/questions/question-card.tsx b/frontend/src/components/questions/question-card.tsx new file mode 100644 index 0000000..6ba37f7 --- /dev/null +++ b/frontend/src/components/questions/question-card.tsx @@ -0,0 +1,41 @@ +import Link from "next/link"; +import { Badge } from "@/components/ui/badge"; +import { getDifficultyColor, capitalize } from "@/lib/utils"; +import type { QuestionListItem } from "@/types"; + +interface QuestionCardProps { + question: QuestionListItem; +} + +export function QuestionCard({ question }: QuestionCardProps) { + return ( + +
+

{question.title}

+ + {capitalize(question.difficulty)} + +
+ +
+ {question.categories.map((cat) => ( + + {cat.name} + + ))} +
+ +
+ {question.leetcode_id && ( + LeetCode #{question.leetcode_id} + )} + {question.patterns.length > 0 && ( + {question.patterns.map((p) => p.name).join(", ")} + )} +
+ + ); +} diff --git a/frontend/src/components/ui/badge.tsx b/frontend/src/components/ui/badge.tsx new file mode 100644 index 0000000..87fc31a --- /dev/null +++ b/frontend/src/components/ui/badge.tsx @@ -0,0 +1,28 @@ +import { cn } from "@/lib/utils"; + +interface BadgeProps { + children: React.ReactNode; + className?: string; + variant?: "default" | "outline"; +} + +export function Badge({ + children, + className, + variant = "default", +}: BadgeProps) { + return ( + + {children} + + ); +} diff --git a/frontend/src/components/ui/card.tsx b/frontend/src/components/ui/card.tsx new file mode 100644 index 0000000..fe1931e --- /dev/null +++ b/frontend/src/components/ui/card.tsx @@ -0,0 +1,39 @@ +import { cn } from "@/lib/utils"; + +interface CardProps { + children: React.ReactNode; + className?: string; +} + +export function Card({ children, className }: CardProps) { + return ( +
+ {children} +
+ ); +} + +export function CardHeader({ children, className }: CardProps) { + return
{children}
; +} + +export function CardTitle({ children, className }: CardProps) { + return

{children}

; +} + +export function CardDescription({ children, className }: CardProps) { + return ( +

+ {children} +

+ ); +} + +export function CardContent({ children, className }: CardProps) { + return
{children}
; +} diff --git a/frontend/src/components/ui/code-block.tsx b/frontend/src/components/ui/code-block.tsx new file mode 100644 index 0000000..c2b200c --- /dev/null +++ b/frontend/src/components/ui/code-block.tsx @@ -0,0 +1,37 @@ +"use client"; + +import { useState } from "react"; + +interface CodeBlockProps { + code: string; + language?: string; +} + +export function CodeBlock({ code, language = "python" }: CodeBlockProps) { + const [copied, setCopied] = useState(false); + + const handleCopy = async () => { + await navigator.clipboard.writeText(code); + setCopied(true); + setTimeout(() => setCopied(false), 2000); + }; + + return ( +
+
+ +
+
+ {language} +
+
+        {code}
+      
+
+ ); +}