Skip to content

Commit c232643

Browse files
committed
PEER-249 Add Question Details UI
Signed-off-by: SeeuSim <[email protected]>
1 parent 1cbb83c commit c232643

File tree

4 files changed

+1873
-43
lines changed

4 files changed

+1873
-43
lines changed

frontend/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,19 @@
3030
"react": "^18.3.1",
3131
"react-dom": "^18.3.1",
3232
"react-hook-form": "^7.53.0",
33+
"react-katex": "^3.0.1",
34+
"react-markdown": "^9.0.1",
3335
"react-router-dom": "^6.26.2",
36+
"rehype-katex": "^7.0.1",
37+
"remark-gfm": "^4.0.0",
38+
"remark-math": "^6.0.0",
3439
"tailwind-merge": "^2.5.2",
3540
"tailwindcss-animate": "^1.0.7",
3641
"zod": "^3.23.8"
3742
},
3843
"devDependencies": {
3944
"@eslint/js": "^9.9.0",
45+
"@tailwindcss/typography": "^0.5.15",
4046
"@tanstack/eslint-plugin-query": "^5.56.1",
4147
"@types/node": "^22.5.5",
4248
"@types/react": "^18.3.3",

frontend/src/routes/questions/details.tsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
import { Badge } from '@/components/ui/badge';
2-
import { Card, CardHeader, CardTitle } from '@/components/ui/card';
3-
import { getQuestionDetails } from '@/services/question-service';
41
import { QueryClient, queryOptions, useSuspenseQuery } from '@tanstack/react-query';
2+
import Markdown from 'react-markdown';
53
import { LoaderFunctionArgs, useLoaderData } from 'react-router-dom';
4+
import rehypeKatex from 'rehype-katex';
5+
import remarkGfm from 'remark-gfm';
6+
import remarkMath from 'remark-math';
7+
8+
import { Badge } from '@/components/ui/badge';
9+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
10+
import { getQuestionDetails } from '@/services/question-service';
611

712
const questionDetailsQuery = (id: number) =>
813
queryOptions({
@@ -24,9 +29,11 @@ export const QuestionDetails = () => {
2429
return (
2530
<Card>
2631
<CardHeader>
27-
<CardTitle>{details.title}</CardTitle>
28-
<div className='flex flex-col gap-2'>
29-
<Badge className='flex w-min grow-0'>{details.difficulty}</Badge>
32+
<div className='flex flex-col gap-4'>
33+
<div className='flex w-full items-center gap-4'>
34+
<CardTitle className='text-2xl'>{details.title}</CardTitle>
35+
<Badge className='flex w-min grow-0'>{details.difficulty}</Badge>
36+
</div>
3037
<div className='flex flex-wrap items-center gap-1'>
3138
{details.topics.map((v, i) => (
3239
<Badge className='flex w-min grow-0 whitespace-nowrap' key={i}>
@@ -36,6 +43,15 @@ export const QuestionDetails = () => {
3643
</div>
3744
</div>
3845
</CardHeader>
46+
<CardContent>
47+
<Markdown
48+
rehypePlugins={[rehypeKatex]}
49+
remarkPlugins={[remarkMath, remarkGfm]}
50+
className='prose prose-neutral'
51+
>
52+
{details.description}
53+
</Markdown>
54+
</CardContent>
3955
</Card>
4056
);
4157
};

frontend/tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const config = {
5757
},
5858
},
5959
},
60-
plugins: [require('tailwindcss-animate')],
60+
plugins: [require('tailwindcss-animate'), require('@tailwindcss/typography')],
6161
};
6262

6363
export default config;

0 commit comments

Comments
 (0)