aboutsummaryrefslogtreecommitdiffstats
path: root/apps/web/components/dashboard/preview/TextContentSection.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-04-07 18:30:00 +0100
committerMohamedBassem <me@mbassem.com>2024-04-07 19:00:00 +0100
commit79d61be7e15dc5d23fb687a5f71e0097088a99ac (patch)
treeda72f19cdb74ef4ed2a75bcfddd13bdfb874f205 /apps/web/components/dashboard/preview/TextContentSection.tsx
parent44918316007ed3153dc802a4b11db3ea09024a8b (diff)
downloadkarakeep-79d61be7e15dc5d23fb687a5f71e0097088a99ac.tar.zst
feature: Extract hook logic into separate package and add a new action bar in bookmark preview
Diffstat (limited to 'apps/web/components/dashboard/preview/TextContentSection.tsx')
-rw-r--r--apps/web/components/dashboard/preview/TextContentSection.tsx39
1 files changed, 39 insertions, 0 deletions
diff --git a/apps/web/components/dashboard/preview/TextContentSection.tsx b/apps/web/components/dashboard/preview/TextContentSection.tsx
new file mode 100644
index 00000000..35ee1b33
--- /dev/null
+++ b/apps/web/components/dashboard/preview/TextContentSection.tsx
@@ -0,0 +1,39 @@
+import { ScrollArea } from "@radix-ui/react-scroll-area";
+import Markdown from "react-markdown";
+
+import type { ZBookmark } from "@hoarder/trpc/types/bookmarks";
+
+export function TextContentSection({ bookmark }: { bookmark: ZBookmark }) {
+ let content;
+ switch (bookmark.content.type) {
+ case "link": {
+ if (!bookmark.content.htmlContent) {
+ content = (
+ <div className="text-destructive">
+ Failed to fetch link content ...
+ </div>
+ );
+ } else {
+ content = (
+ <div
+ dangerouslySetInnerHTML={{
+ __html: bookmark.content.htmlContent || "",
+ }}
+ className="prose mx-auto dark:prose-invert"
+ />
+ );
+ }
+ break;
+ }
+ case "text": {
+ content = (
+ <Markdown className="prose mx-auto dark:prose-invert">
+ {bookmark.content.text}
+ </Markdown>
+ );
+ break;
+ }
+ }
+
+ return <ScrollArea className="h-full">{content}</ScrollArea>;
+}