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
4 changes: 2 additions & 2 deletions app/components/subjects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const subjectCodes: Record<string, string> = {

"Data Science using Python Libraries": "dsp",
"Artificial Intelligence": "ai",
"Algorithm Design and Analysis": "ada",
"Algorithm Design and Analysis": "ada2",
"Cloud Computing": "cc",
"Economics for Engineers": "ee",
"IoT (Internet of Things)": "iot",
Expand All @@ -125,7 +125,7 @@ const subjectCodes: Record<string, string> = {
};

// Available subjects
const available = ["ep", "c", "em1", "em2", "oops", "dsc", "os", "ml", "dops"];
const available = ["ep", "c", "em1", "em2", "oops", "dsc", "os", "ml", "dops", "ada2"];

export default function SubjectsSection() {
return (
Expand Down
133 changes: 85 additions & 48 deletions app/sem4/dbms/components/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"use client";

import { Righteous } from "next/font/google";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { useState } from "react";
import { useState, useEffect } from "react";

const righteous = Righteous({
subsets: ["latin"],
Expand All @@ -12,62 +13,98 @@ const righteous = Righteous({

export default function Sidebar() {
const pathname = usePathname();
const [open, setOpen] = useState(true);
const [open, setOpen] = useState(false);

useEffect(() => {
if (window.innerWidth >= 768) {
setOpen(true);
}
}, []);

// Combined chapters (DBMS + ADA ready structure)
const chapters = [
{ id: "ch0", title: "Course Outline" },
{ id: "ch1", title: "Introduction to Databases" },
{ id: "ch2", title: "Entity-Relationship Model" },
{ id: "ch3", title: "Relational Model and SQL" },
// { id: "ch4", title: "Normalization" },
// { id: "ch5", title: "Transactions and Concurrency Control" },
// { id: "ch6", title: "Indexing and Hashing" },
// { id: "ch7", title: "Query Processing and Optimization" },
// { id: "ch8", title: "Recovery and Security" },
{ id: "ch1", title: "Introduction" },
{ id: "ch2", title: "Core Concepts" },
{ id: "ch3", title: "Advanced Topics" },
];

const quizHref = "/quiz";
const quizActive = pathname.startsWith("/quiz");

return (
<div className="flex relative">
<aside
className={`h-[100vh] sticky top-0 bg-[#fae8d7] text-[#1B0D00] p-0 flex flex-col transition-all duration-300 ${
open ? "w-64" : "w-0 overflow-hidden"
<>
{/* Mobile Backdrop */}
<div
className={`fixed inset-0 md:hidden bg-black/50 z-30 transition-opacity duration-300 ${
open ? "opacity-100" : "opacity-0 pointer-events-none"
}`}
>
<h2
className="flex items-center text-2xl font-normal pt-3 pl-3 mb-2 bg-[#cebb9c] text-[#1B0D00] pb-2 border-b-4 border-[#1B0D00]"
style={{ fontFamily: "Rockwell, Serif, serif" }}
onClick={() => setOpen(false)}
/>

<div className="flex sticky top-14 z-40 h-[calc(100vh-3.5rem)] w-[50px] md:w-auto pointer-events-none md:pointer-events-auto">

{/* Sidebar */}
<aside
className={`h-full shrink-0 bg-[#fae8d7] text-[#1B0D00] flex flex-col transition-all duration-300 pointer-events-auto ${
open ? "w-64 border-r-2" : "w-0 overflow-hidden"
}`}
>
Chapters
</h2>
{/* Heading */}
<h2
className="text-2xl p-3 border-b-4 bg-[#cebb9c]"
style={{ fontFamily: "Rockwell, Serif, serif" }}
>
Chapters
</h2>

{/* Chapters */}
<ul className="flex-1 overflow-y-auto">
{chapters.map((ch) => {
const active = pathname.includes(ch.id);

<ul className="flex-1 overflow-y-auto space-y-0">
{chapters.map((ch) => {
const active = pathname === `/sem4/dbms/${ch.id}`;
return (
<li key={ch.id}>
<Link
href={`/sem4/dbms/${ch.id}`}
className={`block px-3 py-2 text-xl transition ${
active ? "bg-[#fccc7e]" : "hover:bg-[#ffdda7af]"
} ${righteous.className}`}
>
{ch.title}
</Link>
</li>
);
})}
</ul>
</aside>
return (
<li key={ch.id}>
<Link
href={`/sem4/${ch.id}`}
className={`block px-3 py-2 text-xl transition ${
active ? "bg-[#fccc7e]" : "hover:bg-[#ffdda7af]"
} ${righteous.className}`}
>
{ch.title}
</Link>
</li>
);
})}
</ul>

<button
onClick={() => setOpen(!open)}
className="toggle-sidebar sticky top-[10%] left-full bg-[#ffdda7d0] h-[85vh] w-[50px] text-[#1B0D00] text-center font-semibold text-2xl border-l-4 rounded-r-2xl border-[#1B0D00] flex items-center justify-center transition-all duration-300"
style={{ fontFamily: "Rockwell, Serif, serif" }}
>
<p className="leading-5">
C<br />H<br />A<br />P<br />T<br />E<br />R<br />S
</p>
</button>
</div>
{/* Quiz Section */}
<div className="border-t-4 border-[#1B0D00]">
<Link
href={quizHref}
className={`block px-3 py-3 text-xl transition ${
quizActive ? "bg-[#fccc7e]" : "hover:bg-[#ffdda7af]"
} ${righteous.className}`}
>
Take Quiz
</Link>
</div>
</aside>

{/* Toggle Button */}
<button
onClick={() => setOpen(!open)}
className="shrink-0 pointer-events-auto bg-[#ffdda7] h-full w-[50px] text-[#1B0D00] text-center font-semibold text-2xl border-l-4 rounded-r-2xl border-[#1B0D00] flex items-center justify-center"
style={{
fontFamily: "Rockwell, Serif, serif",
boxShadow: open ? "4px 0 15px rgba(0,0,0,0.1)" : "none",
}}
>
<p className="leading-5">
C<br />H<br />A<br />P<br />T<br />E<br />R<br />S
</p>
</button>
</div>
</>
);
}
199 changes: 199 additions & 0 deletions app/sem5/ada2/[chapter]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import Link from "next/link";

import { Ch0Content } from "../content/chapter0";
import { Ch1Content } from "../content/chapter1";
import { Ch2Content } from "../content/chapter2";
import { Ch3Content } from "../content/chapter3";
import { Ch4Content } from "../content/chapter4";
import { Ch5Content } from "../content/chapter5";
import { Ch6Content } from "../content/chapter6";
import { Ch7Content } from "../content/chapter7";
import { Ch8Content } from "../content/chapter8";

import { ArrowBigLeft, ArrowBigRight } from "lucide-react";
import { Righteous } from "next/font/google";

const righteous = Righteous({
subsets: ["latin"],
weight: "400",
variable: "--font-righteous",
});

const chapters = [
{
id: "ch0",
title: "Course Outline",
component: Ch0Content,
},

{
id: "ch1",
title: "Introduction to Algorithms",
component: Ch1Content,
},

{
id: "ch2",
title: "Time and Space Complexity",
component: Ch2Content,
},

{
id: "ch3",
title: "Searching and Sorting Algorithms",
component: Ch3Content,
},

{
id: "ch4",
title: "Divide and Conquer Technique",
component: Ch4Content,
},

{
id: "ch5",
title: "Greedy Method",
component: Ch5Content,
},

{
id: "ch6",
title: "Dynamic Programming",
component: Ch6Content,
},

{
id: "ch7",
title: "Graph Algorithms",
component: Ch7Content,
},

{
id: "ch8",
title: "Backtracking and Branch & Bound",
component: Ch8Content,
},
];

type ChapterProps = {
params: { chapter: string };
};

export default function ChapterPage({ params }: ChapterProps) {

const currentIndex = chapters.findIndex(
(c) => c.id === params.chapter
);

const chapter = chapters[currentIndex];

if (!chapter) {
return (
<h1 className="text-2xl font-bold text-[#e2d1c1]">
Chapter not found
</h1>
);
}

const ChapterComponent = chapter.component;

const prevChapter =
currentIndex > 0
? chapters[currentIndex - 1]
: null;

const nextChapter =
currentIndex < chapters.length - 1
? chapters[currentIndex + 1]
: null;

return (
<div className="flex flex-col bg-[#1B0D00] min-h-full p-3 pt-6 text-[#e2d1c1]">

{/* Main Content */}
<div className="flex-1">

<h1
className={`text-4xl md:text-5xl font-bold mb-3 ${righteous.className}`}
>
Algorithm Design and Analysis
</h1>

<p
className={`text-2xl md:text-3xl ${righteous.className}`}
>
{chapter.title}
</p>

{/* Top Navigation */}
<div className="flex justify-between mt-5 gap-4 flex-wrap">

{prevChapter ? (
<Link
href={`/sem5/ada2/${prevChapter.id}`}
className="px-4 py-2 text-xl flex items-center justify-center bg-[#e2d1c1] text-[#1b0d00] rounded-lg hover:bg-[#ac9e91] transition"
style={{ fontFamily: "Rockwell, serif" }}
>
<ArrowBigLeft className="inline-block mr-1" />
Previous
</Link>
) : (
<div />
)}

{nextChapter ? (
<Link
href={`/sem5/ada2/${nextChapter.id}`}
className="px-4 py-2 text-xl flex items-center justify-center bg-[#e2d1c1] text-[#1b0d00] rounded-lg hover:bg-[#ac9e91] transition"
style={{ fontFamily: "Rockwell, serif" }}
>
Next
<ArrowBigRight className="inline-block ml-1" />
</Link>
) : (
<div />
)}

</div>

<hr className="my-6 border-[#c7a669] opacity-40" />

<ChapterComponent />

</div>

{/* Bottom Navigation */}
<div className="flex justify-between gap-4 my-8 flex-wrap">

{prevChapter ? (

<Link
href={`/sem5/ada2/${prevChapter.id}`}
className="px-4 py-2 bg-[#e2d1c1] text-lg md:text-xl flex items-center justify-center text-[#1b0d00] rounded-lg hover:bg-[#ac9e91] transition"
style={{ fontFamily: "Rockwell, serif" }}
>
<ArrowBigLeft className="inline-block mr-1" />
{prevChapter.title}
</Link>
) : (
<div />
)}

{nextChapter ? (
<Link
href={`/sem5/ada2/${nextChapter.id}`}
className="px-4 py-2 bg-[#e2d1c1] text-lg md:text-xl flex items-center justify-center text-[#1b0d00] rounded-lg hover:bg-[#ac9e91] transition"
style={{ fontFamily: "Rockwell, serif" }}
>
{nextChapter.title}
<ArrowBigRight className="inline-block ml-1" />
</Link>
) : (
<div />
)}

</div>

</div>
);
}
Loading