Skip to content

Commit ce4f6cf

Browse files
modify dp page and add side bar open and close feature
1 parent bd0142c commit ce4f6cf

File tree

1 file changed

+43
-19
lines changed

1 file changed

+43
-19
lines changed

src/pages/dynamic-programming/DyanmicProgrammingPage.jsx

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import React, { useState } from "react";
2-
import { Grid,Brain,Layers,Code } from "lucide-react";
2+
import { Grid, Brain, Layers, Code, Menu, X } from "lucide-react";
33
import Levenshtein from "./Levenshtein";
44

55
export default function DynamicProgrammingPage() {
66
const [selectedAlgo, setSelectedAlgo] = useState("");
7+
const [sidebarOpen, setSidebarOpen] = useState(true);
78

89
const renderAlgorithm = () => {
910
switch (selectedAlgo) {
1011
case "Levenshtein":
1112
return (
12-
<div className="w-full h-full overflow-auto p-4">
13+
<div className="md:w-full w-screen overflow-clip p-2">
1314
<Levenshtein />
1415
</div>
1516
);
@@ -21,16 +22,16 @@ export default function DynamicProgrammingPage() {
2122
<div className="flex justify-center mb-4">
2223
<Grid className="w-16 h-16 text-cyan-400 animate-spin-slow" />
2324
</div>
24-
<div className="flex flex-col items-center">
25-
<h2 className="text-3xl font-extrabold bg-gradient-to-r from-cyan-400 via-indigo-400 to-purple-400 bg-clip-text text-transparent mb-4">
26-
Dynamic Programming Visualizer
27-
</h2>
28-
<p className="text-gray-400 mb-6 max-w-md">
29-
Understand how overlapping subproblems and optimal
30-
substructures work in real time. Visualize table-filling,
31-
recursion trees, and memoization flow with stunning
32-
animations! ⚙️🧩
33-
</p>
25+
<div className="flex flex-col items-center">
26+
<h2 className="text-3xl font-extrabold bg-gradient-to-r from-cyan-400 via-indigo-400 to-purple-400 bg-clip-text text-transparent mb-4">
27+
Dynamic Programming Visualizer
28+
</h2>
29+
<p className="text-gray-400 mb-6 max-w-md">
30+
Understand how overlapping subproblems and optimal
31+
substructures work in real time. Visualize table-filling,
32+
recursion trees, and memoization flow with stunning
33+
animations! ⚙️🧩
34+
</p>
3435
</div>
3536
<div className="flex items-center justify-center gap-6">
3637
<Brain className="w-8 h-8 text-indigo-400 animate-pulse" />
@@ -45,12 +46,25 @@ export default function DynamicProgrammingPage() {
4546
};
4647

4748
return (
48-
<div className="flex h-screen bg-black text-white">
49+
<div className="flex h-screen bg-black text-white relative">
4950
{/* Sidebar */}
50-
<div className="w-64 bg-[#0f172a] p-6 border-r border-gray-800 flex-shrink-0">
51-
<h2 className="text-xl font-bold mb-6 text-indigo-400 tracking-wide">
52-
DP Panel
53-
</h2>
51+
<div
52+
className={`${
53+
sidebarOpen ? "translate-x-0" : "hidden"
54+
} fixed md:static md:translate-x-0 transition-transform duration-300 w-64 bg-[#0f172a] min-h-screen p-6 border-r border-gray-800 flex-shrink-0 z-20`}
55+
>
56+
<div className="flex justify-between items-center mb-6">
57+
<h2 className="text-xl font-bold text-indigo-400 tracking-wide">
58+
DP Panel
59+
</h2>
60+
61+
<button
62+
onClick={() => setSidebarOpen(false)}
63+
className="p-1 rounded hover:bg-gray-800"
64+
>
65+
<X className="w-5 h-5" />
66+
</button>
67+
</div>
5468

5569
<label className="block mb-2 text-sm">Algorithm:</label>
5670
<select
@@ -77,9 +91,19 @@ export default function DynamicProgrammingPage() {
7791
</a>
7892
</div>
7993

94+
{/* Open sidebar button */}
95+
{!sidebarOpen && (
96+
<button
97+
onClick={() => setSidebarOpen(true)}
98+
className="absolute top-4 left-4 p-2 bg-gray-800 rounded-md hover:bg-gray-700 z-10"
99+
>
100+
<Menu className="w-6 h-6 text-indigo-400" />
101+
</button>
102+
)}
103+
80104
{/* Visualization Area */}
81-
<div className="flex-1 flex overflow-auto">
82-
<div className="flex-1 min-w-[800px] min-h-full">
105+
<div className="flex-1 flex overflow-auto ml-0 md:ml-0">
106+
<div className="flex-1 min-h-full">
83107
{renderAlgorithm()}
84108
</div>
85109
</div>

0 commit comments

Comments
 (0)