From 467db03eaa014aa038f005ba57a2f90ba2fbb567 Mon Sep 17 00:00:00 2001 From: sumitahmed Date: Fri, 4 Sep 2026 15:50:11 +0530 Subject: [PATCH 1/3] fixed(uiux): added sidebar toggle controls, and improved the responsiveness of the application --- frontend/src/components/Chat/FlashCards.tsx | 27 ++++- frontend/src/components/Chat/MarkdownView.tsx | 18 +-- frontend/src/components/Sidebar.tsx | 110 +++++++++++++++--- frontend/src/pages/Chat.tsx | 38 +++++- 4 files changed, 154 insertions(+), 39 deletions(-) diff --git a/frontend/src/components/Chat/FlashCards.tsx b/frontend/src/components/Chat/FlashCards.tsx index a2d2aab7..b60b1f42 100755 --- a/frontend/src/components/Chat/FlashCards.tsx +++ b/frontend/src/components/Chat/FlashCards.tsx @@ -3,16 +3,33 @@ import type { FlashCard } from "../../lib/api"; type Props = { items?: FlashCard[]; onAdd: (item: { kind: "flashcard" | "note"; title: string; content: string }) => void; + onToggleCollapse?: () => void; }; -export default function FlashCards({ items = [], onAdd }: Props) { +export default function FlashCards({ items = [], onAdd, onToggleCollapse }: Props) { return ( -
+
-
+
-

Important Topics

- {items.length} +
+

Important Topics

+ + {items.length} + +
+ {onToggleCollapse && ( + + )}
diff --git a/frontend/src/components/Chat/MarkdownView.tsx b/frontend/src/components/Chat/MarkdownView.tsx index a401131d..24db4367 100755 --- a/frontend/src/components/Chat/MarkdownView.tsx +++ b/frontend/src/components/Chat/MarkdownView.tsx @@ -8,20 +8,20 @@ import rehypeHighlight from "rehype-highlight"; type Props = { md: string }; const components: Components = { - h1: (p) =>

, - h2: (p) =>

, - h3: (p) =>

, - p: (p) =>

, + h1: (p) =>

, + h2: (p) =>

, + h3: (p) =>

, + p: (p) =>

, ul: (p) =>

    , ol: (p) =>
      , - li: (p) =>
    1. , + li: (p) =>
    2. , strong: (p) => , hr: (p) =>
      , blockquote: (p) => (
      ), table: (p) => ( -
      +
      ), @@ -31,13 +31,13 @@ const components: Components = { code: ({ inline, className, children, ...rest }: any) => { if (inline) { return ( - + {children} ); } return ( -
      +      
               
                 {children}
               
      @@ -48,7 +48,7 @@ const components: Components = {
       
       export default function MarkdownView({ md }: Props) {
         return (
      -    
      +
      setChats(data)); }, []); + // Fetch updated list whenever the drawer is toggled open + useEffect(() => { + if (isToggled) { + getChats().then(data => setChats(data)); + } + }, [isToggled]); + + // Dismiss drawer on Escape key press + useEffect(() => { + const onKeyDown = (e: KeyboardEvent) => { + if (e.key === 'Escape' && isToggled) { + setIsToggled(false); + } + }; + window.addEventListener('keydown', onKeyDown); + return () => window.removeEventListener('keydown', onKeyDown); + }, [isToggled]); + const b = (t: string) => `p-2 rounded-xl duration-300 transition-all ${p === t ? 'text-white bg-stone-800' : 'hover:bg-stone-900 hover:text-stone-200'}` const chatButtonClass = `p-2 rounded-xl duration-300 transition-all ${isToggled ? 'text-white bg-stone-800' : 'hover:bg-stone-900 hover:text-stone-200'}` - function toggleC() { - const idk = document.getElementById("idk") - idk?.classList.toggle("flex"); - idk?.classList.toggle("hidden"); - document.getElementById("idk0")?.classList.toggle("md:rounded-r-none") - setIsToggled(!isToggled) - } return ( -