-
Notifications
You must be signed in to change notification settings - Fork 881
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
92 additions
and
48 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<JSX.Element>() | ||
|
||
useEffect(() => { | ||
if (entry?.content) { | ||
parseHtml(entry?.content).then((parsed) => { | ||
setContent(parsed.content) | ||
}) | ||
} | ||
}, [entry?.content]) | ||
|
||
return ( | ||
<> | ||
<EntryShare url={entry?.url} /> | ||
<m.div | ||
className="px-5 py-5 overflow-y-auto h-full" | ||
initial={{ opacity: 0.01, y: 100 }} | ||
animate={{ opacity: 1, y: 0 }} | ||
exit={{ opacity: 0.01, y: -100 }} | ||
key={entry?.id} | ||
> | ||
<div> | ||
<a | ||
href={entry?.url} | ||
target="_blank" | ||
className="block hover:bg-zinc-100 max-w-[598px] mx-auto p-6 rounded-md transition-colors cursor-pointer" | ||
> | ||
<div className="text-3xl font-bold select-text break-words"> | ||
{entry?.title} | ||
</div> | ||
<div className="mt-2 text-[13px] text-zinc-500 font-medium"> | ||
{entry?.feeds?.title} | ||
</div> | ||
<div className="text-[13px] text-zinc-500"> | ||
{entry?.publishedAt && new Date(entry?.publishedAt).toUTCString()} | ||
</div> | ||
</a> | ||
<div className="max-w-[550px] mx-auto mt-10 mb-32 prose text-[15px] prose-zinc select-text cursor-auto"> | ||
{content} | ||
</div> | ||
</div> | ||
</m.div> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<div className="px-5 h-14 flex items-center text-lg justify-end text-zinc-500 gap-5"> | ||
<TooltipProvider delayDuration={300}> | ||
<Tooltip> | ||
<TooltipTrigger className="flex items-center my-2"> | ||
<i | ||
className="i-mingcute-link-line cursor-pointer no-drag-region" | ||
onClick={() => copyLink()} | ||
/> | ||
</TooltipTrigger> | ||
<TooltipContent side="bottom">Copy Link</TooltipContent> | ||
</Tooltip> | ||
<i className="i-mingcute-world-2-line cursor-pointer no-drag-region" /> | ||
<i className="i-mingcute-share-2-line cursor-pointer no-drag-region" /> | ||
</TooltipProvider> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters