From 1cd242532d93a1b6f4d63beeebba15a8f30e5bef Mon Sep 17 00:00:00 2001 From: DIYgod Date: Tue, 16 Apr 2024 16:25:15 +0800 Subject: [PATCH] feat: video item --- .../src/components/entry-column/index.tsx | 8 ++++- .../components/entry-column/picture-item.tsx | 12 ++++--- .../components/entry-column/video-item.tsx | 36 +++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 src/renderer/src/components/entry-column/video-item.tsx diff --git a/src/renderer/src/components/entry-column/index.tsx b/src/renderer/src/components/entry-column/index.tsx index ad246181b..105fc9ffe 100644 --- a/src/renderer/src/components/entry-column/index.tsx +++ b/src/renderer/src/components/entry-column/index.tsx @@ -5,6 +5,9 @@ import { cn } from '@renderer/lib/utils' import { ArticleItem } from './article-item' import { SocialMediaItem } from './social-media-item' import { PictureItem } from './picture-item' +import { VideoItem } from './video-item' + +const gridMode = ['Pictures', 'Videos'] export function EntryColumn({ activedList, @@ -31,6 +34,9 @@ export function EntryColumn({ case 'Pictures': Item = PictureItem break + case 'Videos': + Item = VideoItem + break default: Item = ArticleItem } @@ -56,7 +62,7 @@ export function EntryColumn({ animate={{ opacity: 1 }} exit={{ opacity: 0 }} className={cn( - activedList?.type === 'Pictures' && 'grid gap-2 grid-cols-2 md:grid-cols-3 lg:grid-cols-4 px-2' + gridMode.includes(activedList?.type || '') && 'grid gap-2 grid-cols-2 md:grid-cols-3 lg:grid-cols-4 px-2' )} > {page.entries.map((entry) => ( diff --git a/src/renderer/src/components/entry-column/picture-item.tsx b/src/renderer/src/components/entry-column/picture-item.tsx index 1f626a010..115469887 100644 --- a/src/renderer/src/components/entry-column/picture-item.tsx +++ b/src/renderer/src/components/entry-column/picture-item.tsx @@ -20,10 +20,14 @@ export function PictureItem({
{entry.title}
-
- {dayjs - .duration(dayjs(entry.published_at).diff(dayjs(), 'minute'), 'minute') - .humanize()} +
+ {entry.author} + · + + {dayjs + .duration(dayjs(entry.published_at).diff(dayjs(), 'minute'), 'minute') + .humanize()} +
diff --git a/src/renderer/src/components/entry-column/video-item.tsx b/src/renderer/src/components/entry-column/video-item.tsx new file mode 100644 index 000000000..e47682e93 --- /dev/null +++ b/src/renderer/src/components/entry-column/video-item.tsx @@ -0,0 +1,36 @@ +import dayjs from '@renderer/lib/dayjs' + +export function VideoItem({ + entry, +}: { + entry: any, +}) { + return ( +
+
+
+ {entry.images?.slice(0, 1).map((image) => ( + + ))} +
+
+
{entry.title}
+
+ {entry.author} + · + + {dayjs + .duration(dayjs(entry.published_at).diff(dayjs(), 'minute'), 'minute') + .humanize()} + +
+
+
+
+ ) +}