forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBc35a83aBurak Boduroğlu4 months ago440 commits

note-list.tsx52 lines, 1.4 KiBHistoryRawDownload
1import { For, Show, createSignal } from "solid-js";
2import type { Note } from "@/api/client";
3import { NoteCard } from "@/components/notes/note-card";
4import { NoteReaderPanel } from "@/components/notes/note-reader-panel";
5import { EmptyState } from "@/components/ui/empty-state";
6
7export function NoteList(props: {
8 notes: Note[];
9 emptyTitle: string;
10 emptyDescription?: string;
11 onUpdate: (id: string, values: { title: string; content: string }) => Promise<void>;
12 onDelete: (id: string) => Promise<void>;
13}) {
14 const [readingNote, setReadingNote] = createSignal<Note | null>(null);
15
16 return (
17 <>
18 <Show
19 when={props.notes.length > 0}
20 fallback={
21 <EmptyState
22 title={props.emptyTitle}
23 description={props.emptyDescription}
24 />
25 }
26 >
27 <ul class="grid grid-cols-2 gap-3 xl:grid-cols-3">
28 <For each={props.notes}>
29 {(note) => (
30 <li class="animate-fade-up">
31 <NoteCard
32 note={note}
33 onOpen={setReadingNote}
34 onUpdate={props.onUpdate}
35 onDelete={props.onDelete}
36 />
37 </li>
38 )}
39 </For>
40 </ul>
41 </Show>
42
43 <NoteReaderPanel
44 note={readingNote()}
45 open={readingNote() != null}
46 onOpenChange={(open) => {
47 if (!open) setReadingNote(null);
48 }}
49 />
50 </>
51 );
52}