From 87d37f9f68a0bbb79479ea9a636ffbd7dd9d92b1 Mon Sep 17 00:00:00 2001 From: Innei Date: Tue, 8 Apr 2025 20:21:40 +0800 Subject: [PATCH] feat(discover): enhance DiscoverForm and SearchCard components with improved layout and functionality - Added number formatting for subscription counts. - Updated SearchCard layout for better responsiveness and visual appeal. - Enhanced button styles for improved user interaction. - Integrated UrlBuilder for sharing feed links. - Refactored FeedCardMediaThumbnail for better media display and fallback handling. These changes improve the overall user experience and visual consistency in the Discover section. Signed-off-by: Innei --- .../renderer/src/modules/discover/form.tsx | 165 ++++++++++++------ 1 file changed, 114 insertions(+), 51 deletions(-) diff --git a/apps/desktop/src/renderer/src/modules/discover/form.tsx b/apps/desktop/src/renderer/src/modules/discover/form.tsx index 4ad8b18fb..1c7f6240c 100644 --- a/apps/desktop/src/renderer/src/modules/discover/form.tsx +++ b/apps/desktop/src/renderer/src/modules/discover/form.tsx @@ -29,6 +29,7 @@ import { useModalStack } from "~/components/ui/modal/stacked/hooks" import { useFollow } from "~/hooks/biz/useFollow" import { getRouteParams } from "~/hooks/biz/useRouteParams" import { apiClient } from "~/lib/api-fetch" +import { UrlBuilder } from "~/lib/url-builder" import { FollowSummary } from "../feed/feed-summary" import { FeedForm } from "./feed-form" @@ -38,6 +39,8 @@ const formSchema = z.object({ target: z.enum(["feeds", "lists"]), }) +const numberFormatter = new Intl.NumberFormat("en-US", {}) + const info: Record< string, { @@ -259,7 +262,7 @@ export function DiscoverForm({ type = "search" }: { type?: string }) { {mutation.isSuccess && (
-
+
{t("discover.search.results", { count: mutation.data?.length || 0 })}
@@ -287,21 +290,26 @@ const SearchCard: FC<{ const { t } = useTranslation() return ( - - + + {item.docs ? ( - + - + ) : ( <> {!!item.entries?.length && ( -
+
{item.entries .filter((e) => !!e) .map((entry) => { @@ -311,12 +319,25 @@ const SearchCard: FC<{ key={assertEntry.id} href={assertEntry.url || void 0} target="_blank" - className="flex min-w-0 flex-1 flex-col items-center gap-1" + className="group relative flex flex-col overflow-hidden rounded-lg bg-zinc-50/50 shadow-zinc-100 transition-all duration-200 hover:-translate-y-px hover:shadow-md dark:bg-zinc-800/50 dark:shadow-neutral-700/50" rel="noreferrer" > - -
- {assertEntry.title} +
+ +
+
+ {assertEntry.title ? ( +
+ {assertEntry.title} +
+ ) : ( +
+ + + {assertEntry.url || "Untitled"} + +
+ )}
) @@ -324,31 +345,53 @@ const SearchCard: FC<{
)} - - -
- - {item.subscriptionCount ?? 0} - {" "} - {t("feed.follower", { count: item.subscriptionCount })} + +
+
+ + + + {numberFormatter.format(item.subscriptionCount ?? 0)}{" "} + {t("feed.follower", { count: item.subscriptionCount ?? 0 })} + +
+
+ +
+ +
@@ -360,22 +403,42 @@ const SearchCard: FC<{ const FeedCardMediaThumbnail: FC<{ entry: NonUndefined[number] }> = ({ entry }) => { - const [, , , bgAccent, bgAccentLight, bgAccentUltraLight] = getBackgroundGradient(entry.title) - return entry.media?.[0] ? ( - - ) : ( -
-
{entry.title}
+ const [, , , bgAccent, bgAccentLight] = getBackgroundGradient( + entry.title || entry.url || "Untitled", + ) + + if (entry.media?.[0]) { + return ( +
+ +
+
+ ) + } + + return ( +
+
+
+ {entry.title ? ( +
+ {entry.title.slice(0, 1).toUpperCase()} +
+ ) : ( + + )} +
+
) }