Prakhar Singh
commited on
Commit
·
df64837
1
Parent(s):
923418b
style: change in the UI of the Notes
Browse files- Frontend/src/pages/note.tsx +139 -121
Frontend/src/pages/note.tsx
CHANGED
|
@@ -1,166 +1,184 @@
|
|
| 1 |
import React from "react";
|
| 2 |
-
import {
|
| 3 |
|
| 4 |
-
// Placeholder data for the
|
| 5 |
-
const
|
| 6 |
-
"DP weakness identified. Must solve 10 hard DP problems this week.",
|
| 7 |
-
"Crucial to articulate Time/Space Complexity for every solution.",
|
| 8 |
-
"Practice conversational pacing to reduce filler words.",
|
| 9 |
-
];
|
| 10 |
|
| 11 |
const Notes: React.FC = () => {
|
| 12 |
-
// State
|
| 13 |
-
const [notesContent, setNotesContent] = React.useState(
|
| 14 |
-
`Goal: Focus on Dynamic Programming and explanation clarity.\n\nKey DP Concepts to review:\n1. Overlapping Subproblems\n2. Optimal Substructure\n3. Memoization vs. Tabulation\n\nInterview Explanation Focus:\n1. State the approach (e.g., "I will use DP with memoization").\n2. Clearly define the state/subproblem (e.g., "dp[i] represents...").\n3. State the base case(s).\n4. Define the recurrence relation.\n5. Analyze Time/Space Complexity (O(n)).\n\n*Self-Reminder: Use fewer 'um's and 'like's.*`
|
| 15 |
-
);
|
| 16 |
-
|
| 17 |
-
// NEW STATE: State to manage the sidebar's open/close status
|
| 18 |
const [isSidebarOpen, setIsSidebarOpen] = React.useState(true);
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
// Toggle function
|
| 21 |
const toggleSidebar = () => {
|
| 22 |
setIsSidebarOpen(!isSidebarOpen);
|
| 23 |
};
|
| 24 |
-
|
| 25 |
-
//
|
| 26 |
-
const
|
| 27 |
-
|
| 28 |
-
// In a real app, you would call an API here
|
| 29 |
};
|
| 30 |
|
| 31 |
return (
|
| 32 |
-
//
|
| 33 |
<div className="flex bg-black h-screen overflow-hidden">
|
| 34 |
|
| 35 |
-
{/* 1. Left Sidebar:
|
| 36 |
<div
|
| 37 |
className={`
|
| 38 |
-
// Full height and transition for sliding
|
| 39 |
h-screen flex-shrink-0 transition-all duration-300 ease-in-out
|
| 40 |
-
bg-gray-
|
| 41 |
-
${isSidebarOpen ? 'w-
|
| 42 |
`}
|
| 43 |
>
|
| 44 |
-
{isSidebarOpen && (
|
| 45 |
<>
|
| 46 |
-
<h3 className="text-xl font-bold text-white mb-2 border-b border-gray-700 pb-2">
|
|
|
|
|
|
|
| 47 |
|
|
|
|
| 48 |
<button
|
| 49 |
-
className="flex items-center gap-3 w-full bg-blue-600 text-white px-4 py-3 rounded-
|
| 50 |
aria-label="Create New Note"
|
| 51 |
>
|
| 52 |
<Plus size={20} />
|
| 53 |
-
New
|
| 54 |
</button>
|
| 55 |
|
| 56 |
<button
|
| 57 |
-
className="flex items-center gap-3 w-full text-gray-300 px-4 py-3 rounded-
|
| 58 |
aria-label="Upload Notes"
|
| 59 |
>
|
| 60 |
<Upload size={20} />
|
| 61 |
Upload
|
| 62 |
</button>
|
| 63 |
-
|
| 64 |
-
<
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
</button>
|
| 71 |
</>
|
| 72 |
)}
|
| 73 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 74 |
|
| 75 |
-
|
| 76 |
-
<div className="flex-1 p-8 overflow-y-auto"> {/* Allow main content to scroll */}
|
| 77 |
-
|
| 78 |
-
<header className="flex justify-between items-center mb-6">
|
| 79 |
-
{/* Toggle Button for Sidebar - Moved to the header of the main content */}
|
| 80 |
-
<div className="flex items-center gap-4">
|
| 81 |
-
<button
|
| 82 |
-
onClick={toggleSidebar}
|
| 83 |
-
className="p-2 rounded-full bg-gray-200 hover:bg-gray-300 text-gray-800 transition-colors duration-200"
|
| 84 |
-
aria-label={isSidebarOpen ? "Close Sidebar" : "Open Sidebar"}
|
| 85 |
-
>
|
| 86 |
-
{isSidebarOpen ? <X size={24} /> : <Menu size={24} />}
|
| 87 |
-
</button>
|
| 88 |
-
<h2 className="text-4xl font-extrabold text-white"> My Prep Notes</h2>
|
| 89 |
-
</div>
|
| 90 |
-
|
| 91 |
-
{/* Top Right Actions (Save, Rephrase, Download) */}
|
| 92 |
-
<div className="flex gap-3">
|
| 93 |
-
<button
|
| 94 |
-
onClick={handleSave}
|
| 95 |
-
className="flex items-center gap-2 bg-green-600 text-white px-4 py-2 rounded-lg hover:bg-green-700 transition duration-150 font-medium shadow-md"
|
| 96 |
-
aria-label="Save Current Note"
|
| 97 |
-
>
|
| 98 |
-
<Save size={18} />
|
| 99 |
-
Save
|
| 100 |
-
</button>
|
| 101 |
-
|
| 102 |
-
<button
|
| 103 |
-
className="flex items-center gap-2 bg-purple-600 text-white px-4 py-2 rounded-lg hover:bg-purple-700 transition duration-150"
|
| 104 |
-
aria-label="Rephrase Selected Text"
|
| 105 |
-
>
|
| 106 |
-
<RefreshCw size={18} />
|
| 107 |
-
Rephrase
|
| 108 |
-
</button>
|
| 109 |
|
| 110 |
-
<button
|
| 111 |
-
className="flex items-center gap-2 bg-indigo-600 text-white px-4 py-2 rounded-lg hover:bg-indigo-700 transition duration-150"
|
| 112 |
-
aria-label="Download Notes"
|
| 113 |
-
>
|
| 114 |
-
<Download size={18} />
|
| 115 |
-
Download
|
| 116 |
-
</button>
|
| 117 |
</div>
|
| 118 |
-
</header>
|
| 119 |
-
|
| 120 |
-
{/* Note Editor and Summary Section */}
|
| 121 |
-
<div className="grid grid-cols-1 md:grid-cols-3 gap-8">
|
| 122 |
|
| 123 |
-
{/*
|
| 124 |
-
<div
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
<
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
</div>
|
| 162 |
-
|
| 163 |
</div>
|
|
|
|
| 164 |
</div>
|
| 165 |
);
|
| 166 |
};
|
|
|
|
| 1 |
import React from "react";
|
| 2 |
+
import { History, RefreshCw, Plus, Upload, Menu, X, Send, MessageSquare } from "lucide-react";
|
| 3 |
|
| 4 |
+
// Placeholder data for the long text at the bottom (PDF Highlighting)
|
| 5 |
+
const samplePDFHighlight = `So far, we've applied log() to the softmax output, but have neither explained what "log" is nor why we use it. We do this for one key reason. In deep learning and optimization, where derivatives, gradients, and optimizations suffice it to say that the log function has some desirable properties. Log is short for logarithm and is defined as the solution to: "The integer a must be taken of the base b so that the equation b^x = a can be solved with a log function which evaluates log_b(a)." This property of the log function is especially beneficial where e (Euler's number or ≈ 2.71828) is used in the base (where 10 is in the example). The logarithm with e as the base is referred to as the natural logarithm and doesn't use the 'log_e' - you may also see this written as ln(x) or log(x)`;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
const Notes: React.FC = () => {
|
| 8 |
+
// State to manage the left sidebar's open/close status
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
const [isSidebarOpen, setIsSidebarOpen] = React.useState(true);
|
| 10 |
+
|
| 11 |
+
// NEW STATE: State to manage the right chat panel's open/close status
|
| 12 |
+
const [isChatOpen, setIsChatOpen] = React.useState(true);
|
| 13 |
|
| 14 |
+
// Toggle function for the left sidebar
|
| 15 |
const toggleSidebar = () => {
|
| 16 |
setIsSidebarOpen(!isSidebarOpen);
|
| 17 |
};
|
| 18 |
+
|
| 19 |
+
// Toggle function for the right chat panel
|
| 20 |
+
const toggleChat = () => {
|
| 21 |
+
setIsChatOpen(!isChatOpen);
|
|
|
|
| 22 |
};
|
| 23 |
|
| 24 |
return (
|
| 25 |
+
// Outer container: Black background, full height, flex layout
|
| 26 |
<div className="flex bg-black h-screen overflow-hidden">
|
| 27 |
|
| 28 |
+
{/* 1. Left Sidebar: My Notes (Toggleable) */}
|
| 29 |
<div
|
| 30 |
className={`
|
|
|
|
| 31 |
h-screen flex-shrink-0 transition-all duration-300 ease-in-out
|
| 32 |
+
bg-gray-900 border-r border-gray-700 flex flex-col gap-4 shadow-2xl
|
| 33 |
+
${isSidebarOpen ? 'w-64 p-4' : 'w-0 p-0 overflow-hidden'}
|
| 34 |
`}
|
| 35 |
>
|
| 36 |
+
{isSidebarOpen && (
|
| 37 |
<>
|
| 38 |
+
<h3 className="text-xl font-bold text-white mb-2 border-b border-gray-700 pb-2">
|
| 39 |
+
My Notes
|
| 40 |
+
</h3>
|
| 41 |
|
| 42 |
+
{/* Navigation/Action Buttons */}
|
| 43 |
<button
|
| 44 |
+
className="flex items-center gap-3 w-full bg-blue-600 text-white px-4 py-3 rounded-lg hover:bg-blue-700 transition duration-150 font-semibold whitespace-nowrap"
|
| 45 |
aria-label="Create New Note"
|
| 46 |
>
|
| 47 |
<Plus size={20} />
|
| 48 |
+
New Notes
|
| 49 |
</button>
|
| 50 |
|
| 51 |
<button
|
| 52 |
+
className="flex items-center gap-3 w-full text-gray-300 px-4 py-3 rounded-lg hover:bg-gray-700 hover:text-white transition duration-150 whitespace-nowrap"
|
| 53 |
aria-label="Upload Notes"
|
| 54 |
>
|
| 55 |
<Upload size={20} />
|
| 56 |
Upload
|
| 57 |
</button>
|
| 58 |
+
|
| 59 |
+
<div className="mt-4 pt-4 border-t border-gray-700 space-y-2">
|
| 60 |
+
<p className="text-sm text-gray-400">History</p>
|
| 61 |
+
<div className="text-gray-200 bg-gray-700 p-2 rounded-md cursor-pointer hover:bg-gray-600">notes.pdf</div>
|
| 62 |
+
<div className="text-gray-200 p-2 rounded-md cursor-pointer hover:bg-gray-600">notes2.pdf</div>
|
| 63 |
+
<div className="text-gray-200 p-2 rounded-md cursor-pointer hover:bg-gray-600">notes3.pdf</div>
|
| 64 |
+
</div>
|
|
|
|
| 65 |
</>
|
| 66 |
)}
|
| 67 |
</div>
|
| 68 |
+
|
| 69 |
+
{/* 2. Middle & Right Columns Container */}
|
| 70 |
+
<div className="flex flex-1 overflow-hidden">
|
| 71 |
+
|
| 72 |
+
{/* Main Content (PDF Viewer & Highlighting) */}
|
| 73 |
+
<div className="flex flex-col flex-1 p-6 overflow-y-auto">
|
| 74 |
+
|
| 75 |
+
{/* Top Header/Toggle */}
|
| 76 |
+
<header className="flex justify-between items-center mb-6">
|
| 77 |
+
<div className="flex items-center gap-4">
|
| 78 |
+
{/* Left Sidebar Toggle Button */}
|
| 79 |
+
<button
|
| 80 |
+
onClick={toggleSidebar}
|
| 81 |
+
className="p-2 rounded-full bg-gray-700 hover:bg-gray-600 text-white transition-colors duration-200"
|
| 82 |
+
aria-label={isSidebarOpen ? "Close Left Sidebar" : "Open Left Sidebar"}
|
| 83 |
+
>
|
| 84 |
+
{isSidebarOpen ? <X size={24} /> : <Menu size={24} />}
|
| 85 |
+
</button>
|
| 86 |
+
<h2 className="text-2xl font-extrabold text-white">Notes Page / PDF Viewer</h2>
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
<div className="flex items-center gap-4">
|
| 90 |
+
{/* Right Chat Toggle Button (Visible only when chat is CLOSED) */}
|
| 91 |
+
{!isChatOpen && (
|
| 92 |
+
<button
|
| 93 |
+
onClick={toggleChat}
|
| 94 |
+
className="flex items-center gap-2 bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition duration-150 font-medium shadow-md"
|
| 95 |
+
aria-label="Open AI Chat"
|
| 96 |
+
>
|
| 97 |
+
<MessageSquare size={18} />
|
| 98 |
+
AI Chat
|
| 99 |
+
</button>
|
| 100 |
+
)}
|
| 101 |
+
|
| 102 |
+
{/* Top Right Utility (e.g., Generate New Notes) */}
|
| 103 |
+
<button
|
| 104 |
+
className="flex items-center gap-2 bg-blue-600 text-white px-4 py-2 rounded-lg hover:bg-blue-700 transition duration-150 font-medium shadow-md"
|
| 105 |
+
aria-label="Generate New Notes"
|
| 106 |
+
>
|
| 107 |
+
<RefreshCw size={18} />
|
| 108 |
+
Generate New Notes
|
| 109 |
+
</button>
|
| 110 |
+
</div>
|
| 111 |
+
</header>
|
| 112 |
+
|
| 113 |
+
{/* PDF Viewer Area */}
|
| 114 |
+
<div className="flex-1 bg-gray-700 rounded-xl shadow-inner border-2 border-gray-600 mb-6 p-4 flex-col items-center justify-center">
|
| 115 |
+
<p className="text-white text-xl font-medium">PDF View</p>
|
| 116 |
+
<p className="text-white text-xl font-medium">{samplePDFHighlight}</p>
|
| 117 |
+
</div>
|
| 118 |
|
| 119 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 122 |
|
| 123 |
+
{/* 3. Right Chat Panel (Toggleable) */}
|
| 124 |
+
<div
|
| 125 |
+
className={`
|
| 126 |
+
flex flex-col bg-gray-900 border-l border-gray-700 p-4 flex-shrink-0 transition-all duration-300 ease-in-out
|
| 127 |
+
${isChatOpen ? 'w-80' : 'w-0 p-0 overflow-hidden'}
|
| 128 |
+
`}
|
| 129 |
+
>
|
| 130 |
+
{isChatOpen && (
|
| 131 |
+
<>
|
| 132 |
+
<header className="flex justify-between items-center mb-4 border-b border-gray-700 pb-2">
|
| 133 |
+
<h3 className="text-xl font-bold text-white">
|
| 134 |
+
Chat
|
| 135 |
+
</h3>
|
| 136 |
+
{/* Close button for the chat panel */}
|
| 137 |
+
<button
|
| 138 |
+
onClick={toggleChat}
|
| 139 |
+
className="p-1 rounded-full text-gray-400 hover:bg-gray-700 hover:text-white transition duration-150"
|
| 140 |
+
aria-label="Close Chat Panel"
|
| 141 |
+
>
|
| 142 |
+
<X size={20} />
|
| 143 |
+
</button>
|
| 144 |
+
</header>
|
| 145 |
+
|
| 146 |
+
{/* Chat Messages Area */}
|
| 147 |
+
<div className="flex-1 overflow-y-auto space-y-3 mb-4">
|
| 148 |
+
<p className="text-gray-400 text-sm">AI to chat with notes</p>
|
| 149 |
+
{/* Mock Chat Messages */}
|
| 150 |
+
<div className="flex justify-end">
|
| 151 |
+
<div className="bg-blue-600 text-white p-3 rounded-lg max-w-[80%]">
|
| 152 |
+
What are the key concepts on this page?
|
| 153 |
+
</div>
|
| 154 |
+
</div>
|
| 155 |
+
<div className="flex justify-start">
|
| 156 |
+
<div className="bg-gray-700 text-white p-3 rounded-lg max-w-[80%]">
|
| 157 |
+
The key concepts are the definition of the $\\log$ function and why it is used in deep learning and optimization due to its desirable properties for derivatives and gradients.
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
|
| 162 |
+
{/* Chat Input Area */}
|
| 163 |
+
<div className="flex items-center gap-2 flex-shrink-0">
|
| 164 |
+
<input
|
| 165 |
+
type="text"
|
| 166 |
+
placeholder="Type here..."
|
| 167 |
+
className="flex-1 p-3 rounded-lg bg-gray-800 text-white border border-gray-700 focus:outline-none focus:ring-1 focus:ring-blue-500"
|
| 168 |
+
/>
|
| 169 |
+
<button
|
| 170 |
+
className="bg-blue-600 text-white p-3 rounded-full hover:bg-blue-700 transition duration-150"
|
| 171 |
+
aria-label="Send Message"
|
| 172 |
+
>
|
| 173 |
+
<Send size={20} />
|
| 174 |
+
</button>
|
| 175 |
+
</div>
|
| 176 |
+
</>
|
| 177 |
+
)}
|
| 178 |
</div>
|
| 179 |
+
|
| 180 |
</div>
|
| 181 |
+
|
| 182 |
</div>
|
| 183 |
);
|
| 184 |
};
|