forge
Explore
Log in

Don't you dare go Hollow

📝 rich-text notes with write/preview tabs and compact row actions

Browse files at this commit

f8b967cf2c883ee38157e59c7803eca95d5dd6f2Burak BoduroğluParent: f6ff360
  • feat
    • 📝 rich-text notes with write/preview tabs and compact row actions
Show full message
feat: 📝 rich-text notes with write/preview tabs and compact row actions
- note-form swaps the plain textarea for RichTextEditor with a
  write/preview toggle; note-card and note-reader render content as
  HTML with list styling instead of paragraph splitting
- TableRowActions gains a compact icon-only variant; payments page uses
  it with a centered actions column
- combobox always mounts the listbox so child content composes with the
  default scrollable list
src/components/notes/note-card.tsxmodified+7 -4
@@ -1,4 +1,4 @@
1-import { createSignal } from "solid-js";1+import { Show, createSignal } from "solid-js";
2 import { formatApiError } from "@/api/client";2 import { formatApiError } from "@/api/client";
3 import type { Note } from "@/api/client";3 import type { Note } from "@/api/client";
4 import { NoteForm } from "@/components/notes/note-form";4 import { NoteForm } from "@/components/notes/note-form";
@@ -55,9 +55,12 @@ export function NoteCard(props: {
55 </div>55 </div>
56 </div>56 </div>
57 <div class="flex flex-1 flex-col gap-4 bg-[linear-gradient(90deg,rgba(245,158,11,0.12)_0,rgba(245,158,11,0.12)_2.25rem,transparent_2.25rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.05rem,rgba(120,113,108,0.14)_2.1rem)] px-4 py-4 pl-12 dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.1)_0,rgba(245,158,11,0.1)_2.25rem,transparent_2.25rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.05rem,rgba(214,211,209,0.1)_2.1rem)]">57 <div class="flex flex-1 flex-col gap-4 bg-[linear-gradient(90deg,rgba(245,158,11,0.12)_0,rgba(245,158,11,0.12)_2.25rem,transparent_2.25rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.05rem,rgba(120,113,108,0.14)_2.1rem)] px-4 py-4 pl-12 dark:bg-[linear-gradient(90deg,rgba(245,158,11,0.1)_0,rgba(245,158,11,0.1)_2.25rem,transparent_2.25rem),repeating-linear-gradient(0deg,transparent_0,transparent_2.05rem,rgba(214,211,209,0.1)_2.1rem)]">
58- <p class="line-clamp-6 whitespace-pre-wrap text-[13px] leading-8 text-muted-foreground group-hover:text-foreground">58+ <Show
59- {props.note.content || t("notes.noContent")}59+ when={props.note.content?.trim()}
60- </p>60+ fallback={<p class="text-[13px] leading-8 text-muted-foreground">{t("notes.noContent")}</p>}
61+ >
62+ <div class="line-clamp-6 whitespace-pre-wrap text-[13px] leading-8 text-muted-foreground group-hover:text-foreground [&_ol]:ml-5 [&_ol]:list-decimal [&_ul]:ml-5 [&_ul]:list-disc" innerHTML={props.note.content} />
63+ </Show>
61 {error() && <p class="text-sm text-destructive">{error()}</p>}64 {error() && <p class="text-sm text-destructive">{error()}</p>}
62 </div>65 </div>
63 </article>66 </article>
src/components/notes/note-form.tsxmodified+31 -10
@@ -9,7 +9,8 @@ import { IconEdit, IconPlus, IconTrash } from "@/components/ui/icons";
9 import { Input } from "@/components/ui/input";9 import { Input } from "@/components/ui/input";
10 import { Label } from "@/components/ui/label";10 import { Label } from "@/components/ui/label";
11 import { PageSpinner } from "@/components/ui/page-spinner";11 import { PageSpinner } from "@/components/ui/page-spinner";
12-import { Textarea } from "@/components/ui/textarea";12+import { RichTextEditor } from "@/components/ui/rich-text-editor";
13+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
13 import { formatBytes, maxUploadBytes } from "@/lib/upload-limits";14 import { formatBytes, maxUploadBytes } from "@/lib/upload-limits";
14 import { useT } from "@/stores/preferences-context";15 import { useT } from "@/stores/preferences-context";
15 16
@@ -36,6 +37,7 @@ export function NoteForm(props: {
36 const isUpdate = () => !!props.initial?.id;37 const isUpdate = () => !!props.initial?.id;
37 const [title, setTitle] = createSignal(props.initial?.title ?? "");38 const [title, setTitle] = createSignal(props.initial?.title ?? "");
38 const [content, setContent] = createSignal(props.initial?.content ?? "");39 const [content, setContent] = createSignal(props.initial?.content ?? "");
40+ const [contentView, setContentView] = createSignal<"write" | "preview">("write");
39 const [files, setFiles] = createSignal<File[]>([]);41 const [files, setFiles] = createSignal<File[]>([]);
40 const [error, setError] = createSignal("");42 const [error, setError] = createSignal("");
41 const [pending, setPending] = createSignal(false);43 const [pending, setPending] = createSignal(false);
@@ -123,15 +125,34 @@ export function NoteForm(props: {
123 />125 />
124 </div>126 </div>
125 <div class="space-y-1.5 rounded-xl border border-border/80 bg-card p-4 shadow-xs">127 <div class="space-y-1.5 rounded-xl border border-border/80 bg-card p-4 shadow-xs">
126- <Label for="note-content">{t("form.content")}</Label>128+ <div class="flex flex-wrap items-center justify-between gap-2">
127- <Textarea129+ <Label for="note-content">{t("form.content")}</Label>
128- id="note-content"130+ <Tabs value={contentView()} onChange={(value) => setContentView(value as "write" | "preview")}>
129- class="min-h-32 rounded-lg bg-background/80"131+ <TabsList class="w-auto">
130- value={content()}132+ <TabsTrigger value="write" class="h-8 px-2.5 text-xs">{t("notes.write")}</TabsTrigger>
131- maxlength={10000}133+ <TabsTrigger value="preview" class="h-8 px-2.5 text-xs">{t("notes.preview")}</TabsTrigger>
132- rows={4}134+ </TabsList>
133- onInput={(e) => setContent(e.currentTarget.value)}135+ <TabsContent value="write" class="hidden" />
134- />136+ <TabsContent value="preview" class="hidden" />
137+ </Tabs>
138+ </div>
139+ <Show
140+ when={contentView() === "write"}
141+ fallback={
142+ <div class="min-h-40 rounded-lg border border-input bg-background/80 p-3 text-sm leading-relaxed text-foreground [&_ol]:ml-5 [&_ol]:list-decimal [&_ul]:ml-5 [&_ul]:list-disc">
143+ <Show when={content().trim()} fallback={<p class="text-muted-foreground">{t("notes.noContent")}</p>}>
144+ <div innerHTML={content()} />
145+ </Show>
146+ </div>
147+ }
148+ >
149+ <RichTextEditor
150+ value={content()}
151+ onChange={setContent}
152+ placeholder={t("form.content")}
153+ minHeight="min-h-40"
154+ />
155+ </Show>
135 </div>156 </div>
136 157
137 <Show when={showFiles()}>158 <Show when={showFiles()}>
src/components/notes/note-reader-panel.tsxmodified+3 -11
@@ -1,4 +1,4 @@
1-import { For, Show, createMemo } from "solid-js";1+import { Show } from "solid-js";
2 import type { Note } from "@/api/client";2 import type { Note } from "@/api/client";
3 import { NoteFilesPanel } from "@/components/notes/note-files-panel";3 import { NoteFilesPanel } from "@/components/notes/note-files-panel";
4 import { SidePanel } from "@/components/ui/side-panel";4 import { SidePanel } from "@/components/ui/side-panel";
@@ -11,12 +11,6 @@ export function NoteReaderPanel(props: {
11 }) {11 }) {
12 const t = useT();12 const t = useT();
13 const note = () => props.note;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 14
21 return (15 return (
22 <SidePanel16 <SidePanel
@@ -31,12 +25,10 @@ export function NoteReaderPanel(props: {
31 <article class="overflow-hidden rounded-lg 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)]">25 <article class="overflow-hidden rounded-lg 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">26 <div class="min-h-80 space-y-4 px-5 py-5 pl-16">
33 <Show27 <Show
34- when={paragraphs().length > 0}28+ when={note()?.content?.trim()}
35 fallback={<p class="text-sm italic leading-8 text-muted-foreground">{t("notes.noContent")}</p>}29 fallback={<p class="text-sm italic leading-8 text-muted-foreground">{t("notes.noContent")}</p>}
36 >30 >
37- <For each={paragraphs()}>31+ <div class="whitespace-pre-wrap text-sm leading-8 text-foreground [&_ol]:ml-5 [&_ol]:list-decimal [&_ul]:ml-5 [&_ul]:list-disc" innerHTML={note()?.content ?? ""} />
38- {(paragraph) => <p class="whitespace-pre-wrap text-sm leading-8 text-foreground">{paragraph}</p>}
39- </For>
40 </Show>32 </Show>
41 </div>33 </div>
42 </article>34 </article>
src/components/ui/combobox.tsxmodified+2 -1
@@ -72,7 +72,8 @@ export function ComboboxContent<T extends ValidComponent = "div">(
72 )}72 )}
73 {...rest}73 {...rest}
74 >74 >
75- {local.children ?? <ComboboxPrimitive.Listbox class="max-h-64 overflow-y-auto" />}75+ <ComboboxPrimitive.Listbox class="max-h-64 overflow-y-auto" />
76+ {local.children}
76 </ComboboxPrimitive.Content>77 </ComboboxPrimitive.Content>
77 </ComboboxPrimitive.Portal>78 </ComboboxPrimitive.Portal>
78 );79 );
src/components/ui/table-row-actions.tsxmodified+5 -3
@@ -17,18 +17,20 @@ type TableRowAction = {
17 disabled?: boolean;17 disabled?: boolean;
18 };18 };
19 19
20-export function TableRowActions(props: { label: string; actions: TableRowAction[] }) {20+export function TableRowActions(props: { label: string; actions: TableRowAction[]; compact?: boolean }) {
21 const t = useT();21 const t = useT();
22 22
23 return (23 return (
24 <div class="flex justify-center">24 <div class="flex justify-center">
25 <DropdownMenu placement="bottom-end" gutter={6}>25 <DropdownMenu placement="bottom-end" gutter={6}>
26 <DropdownMenuTrigger26 <DropdownMenuTrigger
27- class="inline-flex h-8 min-w-[78px] items-center justify-center gap-1.5 rounded-lg border border-border/80 bg-muted/45 px-2 text-xs font-semibold text-foreground outline-hidden transition-colors hover:border-primary/30 hover:bg-primary/8 hover:text-primary focus-visible:ring-2 focus-visible:ring-ring data-expanded:border-primary/30 data-expanded:bg-primary/10 data-expanded:text-primary"27+ class={props.compact
28+ ? "inline-flex h-8 w-8 items-center justify-center rounded-lg border border-border/80 bg-muted/45 text-foreground outline-hidden transition-colors hover:border-primary/30 hover:bg-primary/8 hover:text-primary focus-visible:ring-2 focus-visible:ring-ring data-expanded:border-primary/30 data-expanded:bg-primary/10 data-expanded:text-primary"
29+ : "inline-flex h-8 min-w-[78px] items-center justify-center gap-1.5 rounded-lg border border-border/80 bg-muted/45 px-2 text-xs font-semibold text-foreground outline-hidden transition-colors hover:border-primary/30 hover:bg-primary/8 hover:text-primary focus-visible:ring-2 focus-visible:ring-ring data-expanded:border-primary/30 data-expanded:bg-primary/10 data-expanded:text-primary"}
28 aria-label={props.label}30 aria-label={props.label}
29 title={props.label}31 title={props.label}
30 >32 >
31- <span>{t("common.action")}</span>33+ {!props.compact && <span>{t("common.action")}</span>}
32 <IconDotsVertical class="h-3.5 w-3.5" />34 <IconDotsVertical class="h-3.5 w-3.5" />
33 </DropdownMenuTrigger>35 </DropdownMenuTrigger>
34 <DropdownMenuContent class="w-48">36 <DropdownMenuContent class="w-48">
src/pages/payments-page.tsxmodified+4 -3
@@ -406,15 +406,16 @@ function PaymentsContent() {
406 {406 {
407 id: "actions",407 id: "actions",
408 header: t("common.actions"),408 header: t("common.actions"),
409- meta: { headerClass: "w-40 min-w-40 text-right whitespace-nowrap", cellClass: "text-right" },409+ meta: { headerClass: "text-center", cellClass: "text-center" },
410 cell: (cell) => (410 cell: (cell) => (
411- <div class="flex items-center justify-end gap-1">411+ <div class="flex items-center justify-center gap-1">
412- <Button size="sm" variant="outline" class="rounded-lg" onClick={() => openAssign(cell.row.original)}>412+ <Button size="sm" variant="outline" class="h-8 gap-1 rounded-lg px-2 text-xs" onClick={() => openAssign(cell.row.original)}>
413 <IconPlus class="h-4 w-4" />413 <IconPlus class="h-4 w-4" />
414 {t("payments.assign")}414 {t("payments.assign")}
415 </Button>415 </Button>
416 <TableRowActions416 <TableRowActions
417 label={t("common.actions")}417 label={t("common.actions")}
418+ compact
418 actions={[419 actions={[
419 { label: t("common.view"), icon: <IconEye class="h-4 w-4" />, onSelect: () => setViewPlan(cell.row.original) },420 { label: t("common.view"), icon: <IconEye class="h-4 w-4" />, onSelect: () => setViewPlan(cell.row.original) },
420 { label: t("common.edit"), icon: <IconEdit class="h-4 w-4" />, onSelect: () => startEdit(cell.row.original) },421 { label: t("common.edit"), icon: <IconEdit class="h-4 w-4" />, onSelect: () => startEdit(cell.row.original) },