-
Notifications
You must be signed in to change notification settings - Fork 523
/
Copy pathmodules-list.tsx
78 lines (75 loc) · 2.08 KB
/
modules-list.tsx
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
import { CurriculumIndexEntry } from "../../../libs/types/curriculum";
import { TopicIcon } from "./topic-icon";
import { topic2css } from "./utils";
import "./modules-list.scss";
import { useState } from "react";
import { Button } from "../ui/atoms/button";
export function ModulesListList({
modules,
}: {
modules: CurriculumIndexEntry[];
}) {
const [tab, setTab] = useState(1);
return (
<ol className="modules-list-list">
<hr />
{modules.map((modulesList, i) => {
return (
<li
id={`modules-${i}`}
className="modules-list-list-item"
key={`mll-${i}`}
>
<input
className="visually-hidden"
id={`module-${i}`}
name="selected"
type="radio"
checked={i === tab}
onChange={() => setTab(i)}
/>
<label htmlFor={`module-${i}`}>{modulesList.title}</label>
{modulesList.children?.length && (
<>
<ModulesList modules={modulesList.children} />
<Button
extraClasses={"lets-begin"}
type="primary"
target="_self"
href={modulesList.children[0]?.url}
>
Let's begin
</Button>
</>
)}
</li>
);
})}
</ol>
);
}
export function ModulesList({ modules }: { modules: CurriculumIndexEntry[] }) {
return (
<ol className="modules-list">
{modules.map((module, j) => {
return (
<li
key={`ml-${j}`}
className={`module-list-item topic-${topic2css(module.topic)}`}
>
<header>
<a href={module.url}>
{module.topic && <TopicIcon topic={module.topic} />}
<span>{module.title}</span>
</a>
</header>
<section>
<p>{module.summary}</p>
<p>{module.topic}</p>
</section>
</li>
);
})}
</ol>
);
}