hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { Show } from "solid-js"; |
| 2 | import type { Note } from "@/api/client"; |
| 3 | import type { NoteFileSource } from "@/lib/note-source"; |
| 4 | import { NoteFilesPanel } from "@/components/notes/note-files-panel"; |
| 5 | import { SidePanel } from "@/components/ui/side-panel"; |
| 6 | import { toRichTextHtml } from "@/lib/rich-text"; |
| 7 | import { useT } from "@/stores/preferences-context"; |
| 8 | |
| 9 | export 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 | } |