diff options
Diffstat (limited to 'bs5/server/pages/SidebarNote.re')
-rw-r--r-- | bs5/server/pages/SidebarNote.re | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bs5/server/pages/SidebarNote.re b/bs5/server/pages/SidebarNote.re new file mode 100644 index 0000000..334ca74 --- /dev/null +++ b/bs5/server/pages/SidebarNote.re @@ -0,0 +1,32 @@ +open Rsc; +[@react.component] +let make = (~note: Note.t) => { + let lastUpdatedAt = + if (Date.is_today(note.updated_at)) { + Date.format_time(note.updated_at); + } else { + Date.format_date(note.updated_at); + }; + + let summary = + note.content |> Markdown.extract_text |> Markdown.summarize(~words=20); + + <SidebarNoteContent + id={note.id} + title={note.title} + expandedChildren={ + <div className="mt-2"> + {switch (String.trim(summary)) { + | "" => <i> {React.string("(No content)")} </i> + | s => <Text size=Small color=Theme.Color.Gray11> s </Text> + }} + </div> + }> + <header + className={Cx.make(["max-w-[85%] flex flex-col gap-2"])} + style={ReactDOM.Style.make(~zIndex="1", ())}> + <Text size=Large weight=Bold> {note.title} </Text> + <Text size=Small> lastUpdatedAt </Text> + </header> + </SidebarNoteContent>; +}; |