Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion app/components/subjects.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"use client";
import Link from "next/link";
import { useState } from "react";

const subjects = {
"Semester-1": [
Expand Down Expand Up @@ -132,6 +133,7 @@ const subjectCodes: Record<string, string> = {
const available = ["ep", "c", "em1", "em2", "oops", "dsc", "coa", "os", "ml", "dops", "cd", "cle", "ec", "dbms", "bme", "cns", "vlsi", "mb"];

export default function SubjectsSection() {
const [searchTerm, setSearchTerm] = useState("");
return (
<section id="subjects" className="px-6 pb-12 md:pt-12 text-center scroll-mt-20">
<h2
Expand All @@ -146,17 +148,31 @@ export default function SubjectsSection() {
>
Explore Subjects divided Semester-wise for your convenience.
</p>
<div className="px-6 mb-8">
<input
type="text"
placeholder="Search subjects..."
value={searchTerm}
onChange={(e) => setSearchTerm(e.target.value)}
className="w-full max-w-xl p-3 border-2 border-[#d2b48c] rounded-lg text-black text-lg"
/>
</div>
<div
className="space-y-10 px-6 py-6 text-3xl flex flex-col"
style={{ fontFamily: "'Rockwell', 'Serif', serif" }}
>
{Object.entries(subjects).map(([semester, list]) => {
const filteredList = list.filter((subj) =>
subj.toLowerCase().includes(searchTerm.toLowerCase())
);

if (filteredList.length === 0) return null;
const semCode = semester.toLowerCase().replace("semester-", "sem");
return (
<div key={semester}>
<h3 className="text-3xl flex mb-4">{semester}</h3>
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4">
{list.map((subj) => {
{filteredList.map((subj) => {
const code = subjectCodes[subj];
const href = `/${semCode}/${code}/ch0`;
const isAvailable = available.includes(code);
Expand Down Expand Up @@ -190,6 +206,16 @@ export default function SubjectsSection() {
})}
</div>

{Object.values(subjects)
.flat()
.filter((subj) =>
subj.toLowerCase().includes(searchTerm.toLowerCase())
).length === 0 &&
searchTerm && (
<p className="text-xl mt-6 text-center">
No subjects found.
</p>
)}
</section>
);
}
1 change: 1 addition & 0 deletions refactor_reading_time.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ pageFiles.forEach(file => {
console.log('Updated:', file);
}
}

});