-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathLearnContent.tsx
More file actions
90 lines (83 loc) · 2.49 KB
/
LearnContent.tsx
File metadata and controls
90 lines (83 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
'use client'
import Link from 'next/link'
import { useSearchParams } from 'next/navigation'
import { learnLevels, LearnLevelType, LearnContentType } from './constants'
const LearnItem = ({
index,
id,
content
}: {
index: number
id: string
content: LearnContentType
}) => {
return (
<div className="group w-full items-center justify-between py-1">
<Link
href={{
pathname: `/learn/content/${id}_${content.value}`
}}
className="flex w-full rounded-xl px-6 py-3 font-display shadow-md transition group-hover:shadow-lg dark:bg-slate-700"
>
<span className="flex w-full flex-col">
<p className="py-1 text-sm font-medium text-gray-500 dark:text-gray-100">
{index}. {content.label}
</p>
</span>
</Link>
</div>
)
}
const LearnList = ({ level }: { level: LearnLevelType }) => {
return (
<div className="m-6 flex gap-6">
<div className="relative flex-1">
<h2 className="my-5 text-3xl text-gray-500">{level.label}</h2>
<div className="space-y-6">
{level.sections.map(section => {
return (
<div key={section.value} className="relative pl-6">
{/* Section header */}
<h3 className="text-2xl text-gray-500">{section.label}</h3>
{/* Section items */}
{true && (
<ul className="mt-2 space-y-1">
{section.content.map((content, idx) => (
<li
key={content.value}
className="flex items-center gap-2 text-sm"
>
<LearnItem
index={idx + 1}
id={`${level.value}_${section.value}`}
content={content}
/>
</li>
))}
</ul>
)}
</div>
)
})}
</div>
</div>
</div>
)
}
export const LearnContent = () => {
const searchParams = useSearchParams()
const level = searchParams.get('level')
return (
<div className="h-full w-full">
<div className="w-full px-6 font-display">
{learnLevels.map(learnLevel => {
return !level || level == learnLevel.value ? (
<LearnList key={learnLevel.value} level={learnLevel} />
) : (
<></>
)
})}
</div>
</div>
)
}