hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB7122d71Burak Boduroğlu4 months ago419 commits
| 1 | import { For, Show, createMemo } from "solid-js"; |
| 2 | import type { Note } from "@/api/client"; |
| 3 | import { NoteFilesPanel } from "@/components/notes/note-files-panel"; |
| 4 | import { SidePanel } from "@/components/ui/side-panel"; |
| 5 | import { useT } from "@/stores/preferences-context"; |
| 6 | |
| 7 | export function NoteReaderPanel(props: { |
| 8 | note: Note | null; |
| 9 | open: boolean; |
| 10 | onOpenChange: (open: boolean) => void; |
| 11 | }) { |
| 12 | const t = useT(); |
| 13 | const note = () => props.note; |
| 14 | const paragraphs = createMemo(() => |
| 15 | (note()?.content ?? "") |
| 16 | .split(/\n{2,}/) |
| 17 | .map((part) => part.trim()) |
| 18 | .filter(Boolean), |
| 19 | ); |
| 20 | |
| 21 | return ( |
| 22 | <SidePanel |
| 23 | open={props.open && note() != null} |
| 24 | onOpenChange={props.onOpenChange} |
| 25 | title={note()?.title ?? t("notes.title")} |
| 26 | size="wide" |
| 27 | > |
| 28 | <Show when={note()}> |
| 29 | {(n) => ( |
| 30 | <div class="space-y-4"> |
| 31 | <article class="overflow-hidden rounded-2xl border border-amber-200/70 bg-[linear-gradient(90deg,rgba(245,158,11,0.14)_0,rgba(245,158,11,0.14)_3rem,transparent_3rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.45rem,rgba(120,113,108,0.16)_2.5rem)] shadow-xs dark:border-amber-500/20 dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.12)_0,rgba(245,158,11,0.12)_3rem,transparent_3rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.45rem,rgba(214,211,209,0.12)_2.5rem)]"> |
| 32 | <div class="min-h-80 space-y-4 px-5 py-5 pl-16"> |
| 33 | <Show |
| 34 | when={paragraphs().length > 0} |
| 35 | fallback={<p class="text-sm italic leading-8 text-muted-foreground">{t("notes.noContent")}</p>} |
| 36 | > |
| 37 | <For each={paragraphs()}> |
| 38 | {(paragraph) => <p class="whitespace-pre-wrap text-sm leading-8 text-foreground">{paragraph}</p>} |
| 39 | </For> |
| 40 | </Show> |
| 41 | </div> |
| 42 | </article> |
| 43 | <NoteFilesPanel noteId={n().id} active={props.open} /> |
| 44 | </div> |
| 45 | )} |
| 46 | </Show> |
| 47 | </SidePanel> |
| 48 | ); |
| 49 | } |