From 95ad3a7c0dcb85d59ef4b106b168bc34fb6abda4 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Thu, 16 May 2024 19:55:58 +0800 Subject: [PATCH] feat: entry share component --- src/renderer/src/components/entry-content.tsx | 47 ----------------- .../src/components/entry-content/index.tsx | 51 +++++++++++++++++++ .../src/components/entry-content/share.tsx | 40 +++++++++++++++ src/renderer/src/pages/(main)/index.tsx | 2 +- 4 files changed, 92 insertions(+), 48 deletions(-) delete mode 100644 src/renderer/src/components/entry-content.tsx create mode 100644 src/renderer/src/components/entry-content/index.tsx create mode 100644 src/renderer/src/components/entry-content/share.tsx diff --git a/src/renderer/src/components/entry-content.tsx b/src/renderer/src/components/entry-content.tsx deleted file mode 100644 index 117cc51f4..000000000 --- a/src/renderer/src/components/entry-content.tsx +++ /dev/null @@ -1,47 +0,0 @@ -import { parseHtml } from "@renderer/lib/parse-html" -import { ActivedEntry } from "@renderer/lib/types" -import { useEffect, useState } from "react" -import { m } from "framer-motion" - -export function EntryContent({ entry }: { entry: ActivedEntry }) { - const [content, setContent] = useState() - - useEffect(() => { - if (entry?.content) { - parseHtml(entry?.content).then((parsed) => { - setContent(parsed.content) - }) - } - }, [entry?.content]) - - return ( - -
- -
- {entry?.title} -
-
- {entry?.feeds?.title} -
-
- {entry?.publishedAt && new Date(entry?.publishedAt).toUTCString()} -
-
-
- {content} -
-
-
- ) -} diff --git a/src/renderer/src/components/entry-content/index.tsx b/src/renderer/src/components/entry-content/index.tsx new file mode 100644 index 000000000..21316d5af --- /dev/null +++ b/src/renderer/src/components/entry-content/index.tsx @@ -0,0 +1,51 @@ +import { parseHtml } from "@renderer/lib/parse-html" +import { ActivedEntry } from "@renderer/lib/types" +import { useEffect, useState } from "react" +import { m } from "framer-motion" +import { EntryShare } from "./share" + +export function EntryContent({ entry }: { entry: ActivedEntry }) { + const [content, setContent] = useState() + + useEffect(() => { + if (entry?.content) { + parseHtml(entry?.content).then((parsed) => { + setContent(parsed.content) + }) + } + }, [entry?.content]) + + return ( + <> + + + + + + ) +} diff --git a/src/renderer/src/components/entry-content/share.tsx b/src/renderer/src/components/entry-content/share.tsx new file mode 100644 index 000000000..8c972a505 --- /dev/null +++ b/src/renderer/src/components/entry-content/share.tsx @@ -0,0 +1,40 @@ +import { + Tooltip, + TooltipContent, + TooltipProvider, + TooltipTrigger, +} from "@renderer/components/ui/tooltip" +import { useCallback } from "react" +import { useToast } from "@renderer/components/ui/use-toast" + +export function EntryShare({ url }: { url?: string }) { + if (!url) return null + + const { toast } = useToast() + + const copyLink = useCallback(() => { + navigator.clipboard.writeText(url) + toast({ + duration: 1000, + description: "Link copied to clipboard.", + }) + }, [url]) + + return ( +
+ + + + copyLink()} + /> + + Copy Link + + + + +
+ ) +} diff --git a/src/renderer/src/pages/(main)/index.tsx b/src/renderer/src/pages/(main)/index.tsx index 0374c63cc..3b4ec8015 100644 --- a/src/renderer/src/pages/(main)/index.tsx +++ b/src/renderer/src/pages/(main)/index.tsx @@ -38,7 +38,7 @@ export function Component() { {!(activedList && wideMode.includes(activedList.view)) && activedEntry && ( -
+
)}