Skip to content

Commit 8a2a1f9

Browse files
authored
Merge pull request #512 from CodeHarborHub/dev-3
Add: Resources Section
2 parents a826f43 + 3662d70 commit 8a2a1f9

File tree

13 files changed

+475
-26
lines changed

13 files changed

+475
-26
lines changed

package-lock.json

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"@docusaurus/theme-mermaid": "^3.3.2",
2929
"@docusaurus/theme-search-algolia": "^3.3.2",
3030
"@docusaurus/utils-validation": "^3.3.2",
31+
"@fluentui/react-icons": "^2.0.242",
3132
"@fortawesome/fontawesome-svg-core": "^6.5.1",
3233
"@fortawesome/free-solid-svg-icons": "^6.5.1",
3334
"@fortawesome/react-fontawesome": "^0.2.0",
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
import Link from "@docusaurus/Link";
2+
import React, { useState } from "react";
3+
import "./style.css";
4+
import {
5+
ArrowRightFilled,
6+
ChevronLeftRegular,
7+
ChevronRightRegular,
8+
} from "@fluentui/react-icons";
9+
10+
interface Resource {
11+
url: string;
12+
type: string;
13+
title: string;
14+
description: string;
15+
image: string;
16+
duration: string;
17+
}
18+
19+
const ALL_RESOURCES: Resource[] = [
20+
{
21+
url: "https://www.codeharborhub.live/docs/",
22+
type: "tutorial",
23+
title: "Tutorial: For Beginners",
24+
description:
25+
"Get started with CodeHarborHub and learn how to use it to manage your codebases. This tutorial is for beginners.",
26+
image: "/img/resources/tutorials.jpg",
27+
duration: "10 min",
28+
},
29+
{
30+
url: "https://www.codeharborhub.live/courses/",
31+
type: "courses",
32+
title: "Courses: For Advanced Users",
33+
description:
34+
"Learn advanced topics in CodeHarborHub and become a pro. This course is for advanced users.",
35+
image: "/img/resources/courses.jpg",
36+
duration: "3 min",
37+
},
38+
{
39+
url: "https://www.codeharborhub.live/blog/",
40+
type: "blog",
41+
title: "Blog: For All Users",
42+
description:
43+
"Read our blog to get the latest updates, news, and articles on CodeHarborHub.",
44+
image: "/img/resources/blogs.jpg",
45+
duration: "7 min",
46+
},
47+
{
48+
url: "https://www.codeharborhub.live/dsa/",
49+
type: "dsa",
50+
title: "DSA: For Competitive Programmers",
51+
description:
52+
"Prepare for your next coding interview with our Data Structures and Algorithms course.",
53+
image: "/img/resources/dsa.jpg",
54+
duration: "5 min",
55+
},
56+
];
57+
58+
function Resource({
59+
type,
60+
url,
61+
image,
62+
title,
63+
description,
64+
duration,
65+
}: Resource) {
66+
return (
67+
<Link className="resource fade-in" key={title} href={url}>
68+
<div>
69+
<div className="resource-image-container">
70+
<img
71+
src={image}
72+
alt={title}
73+
loading="lazy"
74+
className="resource-image"
75+
/>
76+
</div>
77+
<h3 className="resource-title">{title}</h3>
78+
<p className="resource-description">{description}</p>
79+
</div>
80+
<div className="resource-footer">
81+
<div className="resource-duration">
82+
{`${duration} ${type === "video" ? "watch" : "read"}`}
83+
</div>
84+
</div>
85+
</Link>
86+
);
87+
}
88+
89+
export default function ResourcesSection() {
90+
const [page, setPage] = useState(1);
91+
const [activeType, setActiveType] = useState<
92+
"all" | "blog" | "tutorial" | "courses" | "dsa"
93+
>("all");
94+
95+
const resources =
96+
activeType === "all"
97+
? ALL_RESOURCES
98+
: ALL_RESOURCES.filter((r) => r.type === activeType);
99+
100+
const currentResources = resources.slice((page - 1) * 3, page * 3);
101+
102+
const pages = Math.ceil(resources.length / 3);
103+
104+
const nextPage = () => {
105+
if (page < pages) {
106+
setPage(page + 1);
107+
}
108+
};
109+
110+
const prevPage = () => {
111+
if (page > 1) {
112+
setPage(page - 1);
113+
}
114+
};
115+
116+
return (
117+
<section className="resources-section">
118+
<div className="resources-container">
119+
<div className="resources-header">
120+
<div>
121+
<span className="codeharborhub-badge">RESOURCES</span>
122+
<h2 className="resources-title">Want to know more?</h2>
123+
</div>
124+
<Link to="/blog" className="resources-all-blogs">
125+
All Blogs <ArrowRightFilled className="arrow-icon" />
126+
</Link>
127+
</div>
128+
129+
<div className="resources-filters bg-secondary-700">
130+
<button
131+
className={`filter-button ${activeType === "all" ? "active" : ""}`}
132+
onClick={() => setActiveType("all")}
133+
>
134+
All
135+
</button>
136+
<button
137+
className={`filter-button ${activeType === "blog" ? "active" : ""}`}
138+
onClick={() => setActiveType("blog")}
139+
>
140+
Blogs
141+
</button>
142+
<button
143+
className={`filter-button ${
144+
activeType === "tutorial" ? "active" : ""
145+
}`}
146+
onClick={() => setActiveType("tutorial")}
147+
>
148+
Tutorials
149+
</button>
150+
<button
151+
className={`filter-button ${
152+
activeType === "courses" ? "active" : ""
153+
}`}
154+
onClick={() => setActiveType("courses")}
155+
>
156+
Courses
157+
</button>
158+
<button
159+
className={`filter-button ${activeType === "dsa" ? "active" : ""}`}
160+
onClick={() => setActiveType("dsa")}
161+
>
162+
DSA
163+
</button>
164+
</div>
165+
166+
<div className="resources-content">
167+
<div className="resources-grid">
168+
{currentResources.map((resource, idx) => {
169+
return <Resource {...resource} key={idx} />;
170+
})}
171+
</div>
172+
173+
<div className="pagination">
174+
<button onClick={prevPage} className="pagination-button">
175+
<ChevronLeftRegular className="chevron-icon" />
176+
</button>
177+
178+
<button onClick={nextPage} className="pagination-button">
179+
<ChevronRightRegular className="chevron-icon" />
180+
</button>
181+
</div>
182+
</div>
183+
</div>
184+
</section>
185+
);
186+
}

src/components/HomePage/header.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
.chh__header-content p {
4242
font-weight: 400;
4343
font-size: 22px;
44+
text-align: justify;
4445
line-height: 30px;
4546
margin-top: 1.5rem;
4647
}

src/components/HomePage/home.module.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99

1010

11-
.feature_item:hover ,.course_card:hover {
11+
.feature_item:hover, .course_card:hover {
1212
scale: 1.03;
1313
box-shadow: 0 0 0 1px #f2f2f24a, 0 0 10px 0 #f2f2f255;
1414
transition: scale 0.3s ease-in;
@@ -196,4 +196,4 @@ scale: 1.03;
196196

197197
.play_icon {
198198
color: #f2f2f2;
199-
}
199+
}

0 commit comments

Comments
 (0)