Skip to content

Commit 74c18c7

Browse files
committed
feat: enhance note-taking interface with toggle functionality and layout adjustments
This commit introduces a toggle button for the note list visibility in the NoteEditor component, improving user interaction. Additionally, the layout of the right panel in the Layout component has been updated to conditionally display the NoteList and NoteEditor, enhancing the overall user experience. The NotesView component has been removed as its functionality is now integrated into the Layout component.
1 parent e0072b6 commit 74c18c7

File tree

4 files changed

+44
-33
lines changed

4 files changed

+44
-33
lines changed

src/components/layout/index.tsx

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ import ClaudeCodeApp from "@/pages/cc";
2020
import { WebPreview } from "../WebPreview";
2121
import { useLayoutStore } from "@/stores";
2222
import { DiffViewer } from "../filetree/DiffViewer";
23-
import { NoteList } from "../notes";
24-
import { NotesView } from "../notes/NotesView";
23+
import { NoteList, NoteEditor } from "../notes";
24+
import { useNoteStore } from "@/stores/useNoteStore";
2525

2626
export function Layout() {
2727
const { mainView, rightView, setRightView, setMainView } = useNavigationStore();
2828
const { webPreviewUrl, setWebPreviewUrl, diffFile } = useLayoutStore();
29+
const { showNoteList } = useNoteStore();
2930

3031
const handleTabChange = (view: string) => {
3132
setMainView(view as any);
@@ -93,19 +94,25 @@ export function Layout() {
9394

9495
{/* Right Panel - Editor or Notepad */}
9596
{rightView && (
96-
<Panel defaultSize={mainView ? 30 : 100} minSize={20}>
97-
<div className="h-full overflow-auto">
98-
{rightView === "notepad" ? (
99-
<ResizablePanelGroup direction="horizontal" className="h-full">
100-
<ResizablePanel defaultSize={30} minSize={0}>
101-
<NoteList />
102-
</ResizablePanel>
103-
<ResizableHandle withHandle />
104-
<ResizablePanel defaultSize={70} minSize={50}>
105-
<NotesView />
106-
</ResizablePanel>
107-
</ResizablePanelGroup>
108-
) : rightView === "webPreview" ? (
97+
<Panel defaultSize={mainView ? 30 : 100} minSize={20} className="overflow-hidden">
98+
{rightView === "notepad" ? (
99+
<ResizablePanelGroup direction="horizontal" className="h-full w-full overflow-hidden">
100+
{showNoteList && (
101+
<>
102+
<ResizablePanel defaultSize={25} minSize={15} maxSize={40} className="min-w-0 overflow-hidden">
103+
<div className="h-full w-full overflow-auto">
104+
<NoteList />
105+
</div>
106+
</ResizablePanel>
107+
<ResizableHandle withHandle />
108+
</>
109+
)}
110+
<ResizablePanel defaultSize={showNoteList ? 75 : 100} minSize={50} className="min-w-0 overflow-hidden">
111+
<NoteEditor />
112+
</ResizablePanel>
113+
</ResizablePanelGroup>
114+
) : rightView === "webPreview" ? (
115+
<div className="h-full overflow-auto">
109116
<WebPreview
110117
url={webPreviewUrl || ""}
111118
onClose={() => {
@@ -114,8 +121,8 @@ export function Layout() {
114121
}}
115122
onUrlChange={(url) => setWebPreviewUrl(url)}
116123
/>
117-
) : null}
118-
</div>
124+
</div>
125+
) : null}
119126
</Panel>
120127
)}
121128
</PanelGroup>

src/components/notes/NoteEditor.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useNoteStore } from "@/stores/useNoteStore";
33
import { useThemeContext } from "@/contexts/ThemeContext";
44
import { Button } from "@/components/ui/button";
55
import { Input } from "@/components/ui/input";
6-
import { Save, Eye, Code, PencilIcon } from "lucide-react";
6+
import { Save, Eye, Code, PencilIcon, PanelLeft } from "lucide-react";
77
import AceEditor from "react-ace";
88
import { NoteToChat } from "./NoteToChat";
99

@@ -44,6 +44,7 @@ export function NoteEditor() {
4444
createNote,
4545
getCurrentNote, setCurrentNote,
4646
updateNote,
47+
toggleNoteListVisibility,
4748
} = useNoteStore();
4849

4950
const { theme } = useThemeContext();
@@ -159,6 +160,15 @@ export function NoteEditor() {
159160
<div className="flex flex-col h-full">
160161
{/* Note Header */}
161162
<div className="flex items-center gap-3 px-2 border-b bg-white dark:bg-gray-800 dark:border-gray-700">
163+
<Button
164+
onClick={toggleNoteListVisibility}
165+
size="icon"
166+
variant="ghost"
167+
className="h-7 w-7 p-0"
168+
title="Toggle Note List"
169+
>
170+
<PanelLeft className="h-4 w-4" />
171+
</Button>
162172
<Button
163173
onClick={async () => {
164174
const newNote = await createNote();

src/components/notes/NotesView.tsx

Lines changed: 0 additions & 15 deletions
This file was deleted.

src/stores/useNoteStore.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ interface NoteStore {
3131
currentNoteId: string | null;
3232
isLoading: boolean;
3333
migrated: boolean;
34+
showNoteList: boolean;
3435

3536
// Actions
3637
loadNotes: () => Promise<void>;
@@ -44,6 +45,7 @@ interface NoteStore {
4445
addContentToNote: (id: string, content: string, source?: string) => Promise<void>;
4546
createNoteFromContent: (content: string, source?: string) => Promise<Note>;
4647
toggleFavorite: (id: string) => Promise<void>;
48+
toggleNoteListVisibility: () => void;
4749

4850
// Getters
4951
getCurrentNote: () => Note | null;
@@ -125,6 +127,7 @@ export const useNoteStore = create<NoteStore>((set, get) => ({
125127
currentNoteId: null,
126128
isLoading: false,
127129
migrated: false,
130+
showNoteList: true,
128131

129132
loadNotes: async () => {
130133
try {
@@ -277,6 +280,12 @@ export const useNoteStore = create<NoteStore>((set, get) => ({
277280
throw err;
278281
}
279282
},
283+
284+
toggleNoteListVisibility: () => {
285+
set((state) => ({
286+
showNoteList: !state.showNoteList,
287+
}));
288+
},
280289
}));
281290

282291
// Auto-load notes on store creation

0 commit comments

Comments
 (0)