diff --git a/src/renderer/src/components/feed-icon.tsx b/src/renderer/src/components/feed-icon.tsx index 7c8d8d8db..acb77d157 100644 --- a/src/renderer/src/components/feed-icon.tsx +++ b/src/renderer/src/components/feed-icon.tsx @@ -8,28 +8,52 @@ export function FeedIcon({ entry, fallbackUrl, className, + size = 20, }: { feed: FeedModel entry?: EntryModel["entries"] fallbackUrl?: string className?: string + size?: number }) { const image = entry?.authorAvatar || feed.image if (image) { return ( ) } else if (feed.siteUrl) { - return + return ( + + ) } else if (fallbackUrl) { - return + return ( + + ) } else { return null } diff --git a/src/renderer/src/components/feed-summary.tsx b/src/renderer/src/components/feed-summary.tsx index ed5806492..0338bc63e 100644 --- a/src/renderer/src/components/feed-summary.tsx +++ b/src/renderer/src/components/feed-summary.tsx @@ -22,7 +22,8 @@ export function FollowSummary({
{feed.title} diff --git a/src/renderer/src/components/site-icon.tsx b/src/renderer/src/components/site-icon.tsx index eb3f26b9a..421a588c8 100644 --- a/src/renderer/src/components/site-icon.tsx +++ b/src/renderer/src/components/site-icon.tsx @@ -4,9 +4,11 @@ import { parse } from "tldts" export function SiteIcon({ url, className, + style, }: { url?: string className?: string + style?: React.CSSProperties }) { let host let src @@ -34,6 +36,7 @@ export function SiteIcon({ e.currentTarget.src = fallback } }} + style={style} /> ) } diff --git a/src/renderer/src/components/ui/image.tsx b/src/renderer/src/components/ui/image.tsx index e3d4b3ce8..edcfa9dae 100644 --- a/src/renderer/src/components/ui/image.tsx +++ b/src/renderer/src/components/ui/image.tsx @@ -25,7 +25,7 @@ const ImageImpl: FC = ({ popper = false, ...props }) => { - const { src, ...rest } = props + const { src, style, ...rest } = props const [hidden, setHidden] = useState(!src) const [imgSrc, setImgSrc] = useState( proxy && src && !failedList.has(src) ? @@ -59,7 +59,7 @@ const ImageImpl: FC = ({ ) return ( -
+
- return ( -
- -
-
- {entry.feeds.title} - · - - {dayjs - .duration( - dayjs(entry.entries.publishedAt).diff(dayjs(), "minute"), - "minute", - ) - .humanize()} - -
-
- {entry.entries.title ? ( - - ) : ( - - )} - {!!entry.collections && ( - - )} -
-
- -
-
- {entry.entries.images?.[0] && ( - - )} -
+ ) } diff --git a/src/renderer/src/modules/entry-column/audio-item.tsx b/src/renderer/src/modules/entry-column/audio-item.tsx index 60a795dc7..7614845c2 100644 --- a/src/renderer/src/modules/entry-column/audio-item.tsx +++ b/src/renderer/src/modules/entry-column/audio-item.tsx @@ -1,45 +1,9 @@ -import { FeedIcon } from "@renderer/components/feed-icon" -import { useAsRead } from "@renderer/hooks" -import dayjs from "@renderer/lib/dayjs" -import { cn } from "@renderer/lib/utils" -import { EntryTranslation } from "@renderer/modules/entry-column/translation" -import { useEntry } from "@renderer/store/entry/hooks" +import { ListItem } from "@renderer/modules/entry-column/list-item-template" -import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder" import type { UniversalItemProps } from "./types" export function AudioItem({ entryId, entryPreview, translation }: UniversalItemProps) { - const entry = useEntry(entryId) || entryPreview - - const asRead = useAsRead(entry) - - if (!entry) return return ( -
- -
-
- {entry.feeds.title} - · - - {dayjs - .duration( - dayjs(entry.entries.publishedAt).diff(dayjs(), "minute"), - "minute", - ) - .humanize()} - -
-
- - {!!entry.collections && ( - - )} -
- {entry.entries?.enclosures?.[0].url && ( -
-
+ ) } diff --git a/src/renderer/src/modules/entry-column/grid-item-template.tsx b/src/renderer/src/modules/entry-column/grid-item-template.tsx new file mode 100644 index 000000000..fac70f4db --- /dev/null +++ b/src/renderer/src/modules/entry-column/grid-item-template.tsx @@ -0,0 +1,60 @@ +import { FeedIcon } from "@renderer/components/feed-icon" +import { ReactVirtuosoItemPlaceholder } from "@renderer/components/ui/placeholder" +import { useAsRead } from "@renderer/hooks" +import dayjs from "@renderer/lib/dayjs" +import { cn } from "@renderer/lib/utils" +import { EntryTranslation } from "@renderer/modules/entry-column/translation" +import { useEntry } from "@renderer/store/entry/hooks" + +import type { UniversalItemProps } from "./types" + +export function GridItem({ + entryId, + entryPreview, + translation, + children, +}: UniversalItemProps & { + children?: React.ReactNode +}) { + const entry = useEntry(entryId) || entryPreview + + const asRead = useAsRead(entry) + + if (!entry) return + return ( +
+ {children} +
+
+ + {!!entry.collections && ( + + )} +
+
+ + {entry.feeds.title} + · + + {dayjs + .duration( + dayjs(entry.entries.publishedAt).diff(dayjs(), "minute"), + "minute", + ) + .humanize()} + +
+
+
+ ) +} diff --git a/src/renderer/src/modules/entry-column/list-item-template.tsx b/src/renderer/src/modules/entry-column/list-item-template.tsx new file mode 100644 index 000000000..7ec112bb0 --- /dev/null +++ b/src/renderer/src/modules/entry-column/list-item-template.tsx @@ -0,0 +1,77 @@ +import { FeedIcon } from "@renderer/components/feed-icon" +import { Image } from "@renderer/components/ui/image" +import { useAsRead } from "@renderer/hooks" +import dayjs from "@renderer/lib/dayjs" +import { cn } from "@renderer/lib/utils" +import { EntryTranslation } from "@renderer/modules/entry-column/translation" +import { useEntry } from "@renderer/store/entry/hooks" + +import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder" +import type { UniversalItemProps } from "./types" + +export function ListItem({ + entryId, + entryPreview, + translation, + withDetails, + withAudio, +}: UniversalItemProps & { + withDetails?: boolean + withAudio?: boolean +}) { + const entry = useEntry(entryId) || entryPreview + + const asRead = useAsRead(entry) + + // NOTE: prevent 0 height element, react virtuoso will not stop render any more + if (!entry) return + + return ( +
+ +
+
+ {entry.feeds.title} + · + + {dayjs + .duration( + dayjs(entry.entries.publishedAt).diff(dayjs(), "minute"), + "minute", + ) + .humanize()} + +
+
+ {entry.entries.title ? ( + + ) : ( + + )} + {!!entry.collections && ( + + )} +
+ {withDetails && ( +
+ +
+ )} + {withAudio && entry.entries?.enclosures?.[0].url && ( +
+ {withDetails && entry.entries.images?.[0] && ( + + )} +
+ ) +} diff --git a/src/renderer/src/modules/entry-column/notification-item.tsx b/src/renderer/src/modules/entry-column/notification-item.tsx index 92e51c2af..b695fea03 100644 --- a/src/renderer/src/modules/entry-column/notification-item.tsx +++ b/src/renderer/src/modules/entry-column/notification-item.tsx @@ -1,42 +1,9 @@ -import { FeedIcon } from "@renderer/components/feed-icon" -import { useAsRead } from "@renderer/hooks" -import dayjs from "@renderer/lib/dayjs" -import { cn } from "@renderer/lib/utils" -import { EntryTranslation } from "@renderer/modules/entry-column/translation" -import { useEntry } from "@renderer/store/entry/hooks" +import { ListItem } from "@renderer/modules/entry-column/list-item-template" -import { ReactVirtuosoItemPlaceholder } from "../../components/ui/placeholder" import type { UniversalItemProps } from "./types" export function NotificationItem({ entryId, entryPreview, translation }: UniversalItemProps) { - const entry = useEntry(entryId) || entryPreview - - const asRead = useAsRead(entry) - - if (!entry) return return ( -
- -
-
- {entry.feeds.title} - · - - {dayjs - .duration( - dayjs(entry.entries.publishedAt).diff(dayjs(), "minute"), - "minute", - ) - .humanize()} - -
-
- - {!!entry.collections && ( - - )} -
-
-
+ ) } diff --git a/src/renderer/src/modules/entry-column/picture-item.tsx b/src/renderer/src/modules/entry-column/picture-item.tsx index 7193112aa..a286f1135 100644 --- a/src/renderer/src/modules/entry-column/picture-item.tsx +++ b/src/renderer/src/modules/entry-column/picture-item.tsx @@ -1,10 +1,6 @@ -import { FeedIcon } from "@renderer/components/feed-icon" import { SwipeImages } from "@renderer/components/ui/image/swipe-images" import { ReactVirtuosoItemPlaceholder } from "@renderer/components/ui/placeholder" -import { useAsRead } from "@renderer/hooks" -import dayjs from "@renderer/lib/dayjs" -import { cn } from "@renderer/lib/utils" -import { EntryTranslation } from "@renderer/modules/entry-column/translation" +import { GridItem } from "@renderer/modules/entry-column/grid-item-template" import { useEntry } from "@renderer/store/entry/hooks" import { usePreviewImages } from "../../components/ui/image/hooks" @@ -13,12 +9,10 @@ import type { UniversalItemProps } from "./types" export function PictureItem({ entryId, entryPreview, translation }: UniversalItemProps) { const entry = useEntry(entryId) || entryPreview - const asRead = useAsRead(entry) - const previewImage = usePreviewImages() if (!entry) return return ( -
+
-
-
- - {!!entry.collections && ( - - )} -
-
- - {entry.feeds.title} - · - - {dayjs - .duration( - dayjs(entry.entries.publishedAt).diff(dayjs(), "minute"), - "minute", - ) - .humanize()} - -
-
-
+ ) } diff --git a/src/renderer/src/modules/entry-column/social-media-item.tsx b/src/renderer/src/modules/entry-column/social-media-item.tsx index 6487079c9..f6775e4f9 100644 --- a/src/renderer/src/modules/entry-column/social-media-item.tsx +++ b/src/renderer/src/modules/entry-column/social-media-item.tsx @@ -17,8 +17,8 @@ export function SocialMediaItem({ entryId, entryPreview, translation }: Universa // NOTE: prevent 0 height element, react virtuoso will not stop render any more if (!entry) return return ( -
- +
+
@@ -36,7 +36,7 @@ export function SocialMediaItem({ entryId, entryPreview, translation }: Universa
{!!entry.collections && ( - + )}
diff --git a/src/renderer/src/modules/entry-column/video-item.tsx b/src/renderer/src/modules/entry-column/video-item.tsx index efb6b195e..d3292c4a9 100644 --- a/src/renderer/src/modules/entry-column/video-item.tsx +++ b/src/renderer/src/modules/entry-column/video-item.tsx @@ -1,9 +1,6 @@ -import { FeedIcon } from "@renderer/components/feed-icon" import { Image } from "@renderer/components/ui/image" -import { useAsRead } from "@renderer/hooks" -import dayjs from "@renderer/lib/dayjs" import { urlToIframe } from "@renderer/lib/url-to-iframe" -import { cn } from "@renderer/lib/utils" +import { GridItem } from "@renderer/modules/entry-column/grid-item-template" import { useEntry } from "@renderer/store/entry/hooks" import { useHover } from "@use-gesture/react" import { useMemo, useRef, useState } from "react" @@ -14,8 +11,6 @@ import type { UniversalItemProps } from "./types" export function VideoItem({ entryId, entryPreview, translation }: UniversalItemProps) { const entry = useEntry(entryId) || entryPreview - const asRead = useAsRead(entry) - const iframeSrc = useMemo(() => urlToIframe(entry?.entries.url), [entry?.entries.url]) const ref = useRef(null) @@ -31,10 +26,11 @@ export function VideoItem({ entryId, entryPreview, translation }: UniversalItemP if (!entry) return return ( -
+
{iframeSrc && hovered ? ( + // eslint-disable-next-line @eslint-react/dom/no-missing-iframe-sandbox