forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits

note-reader-panel.tsx44 lines, 1.5 KiBHistoryRawDownload
1import { Show } from "solid-js";
2import type { Note } from "@/api/client";
3import type { NoteFileSource } from "@/lib/note-source";
4import { NoteFilesPanel } from "@/components/notes/note-files-panel";
5import { SidePanel } from "@/components/ui/side-panel";
6import { toRichTextHtml } from "@/lib/rich-text";
7import { useT } from "@/stores/preferences-context";
8
9export function NoteReaderPanel(props: {
10 note: Note | null;
11 source: NoteFileSource;
12 /** Read-only file section when false. Defaults to true. */
13 canManage?: boolean;
14 open: boolean;
15 onOpenChange: (open: boolean) => void;
16}) {
17 const t = useT();
18 const note = () => props.note;
19
20 return (
21 <SidePanel
22 open={props.open && note() != null}
23 onOpenChange={props.onOpenChange}
24 title={note()?.title ?? t("notes.title")}
25 size="wide"
26 >
27 <Show when={note()}>
28 {(n) => (
29 <div class="space-y-4">
30 <article class="rounded-xl border border-border bg-card px-5 py-5 shadow-xs sm:px-7">
31 <Show
32 when={note()?.content?.trim()}
33 fallback={<p class="text-sm italic text-muted-foreground">{t("notes.noContent")}</p>}
34 >
35 <div class="note-prose" innerHTML={toRichTextHtml(note()?.content)} />
36 </Show>
37 </article>
38 <NoteFilesPanel noteId={n().id} source={props.source} canManage={props.canManage} active={props.open} />
39 </div>
40 )}
41 </Show>
42 </SidePanel>
43 );
44}