From c0683eee6def2b835e79dab9eea37cb4567f02b7 Mon Sep 17 00:00:00 2001 From: Innei Date: Wed, 31 Jul 2024 15:44:04 +0800 Subject: [PATCH] fix: profile header transform when scroll up/down Signed-off-by: Innei --- .../modules/discover/content-components.tsx | 2 +- src/renderer/src/modules/discover/form.tsx | 4 +- .../modules/profile/user-profile-modal.tsx | 59 ++++++++++++------- 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/renderer/src/modules/discover/content-components.tsx b/src/renderer/src/modules/discover/content-components.tsx index 6baa4d3c7..ba6307164 100644 --- a/src/renderer/src/modules/discover/content-components.tsx +++ b/src/renderer/src/modules/discover/content-components.tsx @@ -149,7 +149,7 @@ export const DiscoverFeedForm = ({ const defaultView = getViewFromRoute(route) || getSidebarActiveView() as FeedViewType present({ - title: "Add follow", + title: "Add Feed", content: () => ( ( { present({ - title: "Add follow", + title: "Add Feed", content: ({ dismiss }) => ( { + + const initialHeaderHeight = 136 + $ref.onscroll = throttle(() => { const currentH = $ref.scrollTop - setHeaderSimple(currentH > 300) - } + setHeaderSimple((current) => { + if (!current) { + return currentH > initialHeaderHeight + } else { + if (currentH === 0) return false + } + return current + }) + }, 16) return () => { $ref.onscroll = null } @@ -94,7 +104,7 @@ export const UserProfileModalContent: FC<{ }} exit="exit" layout="size" - className="shadow-perfect perfect-sm relative flex h-[80vh] flex-col items-center overflow-hidden rounded-xl border bg-theme-background p-8 lg:max-h-[calc(100vh-20rem)]" + className="shadow-perfect perfect-sm relative flex h-[80vh] flex-col items-center overflow-hidden rounded-xl border bg-theme-background p-8 lg:max-h-[calc(100vh-10rem)]" >
) : ( subscriptions.data && - Object.keys(subscriptions.data).map((category) => ( -
-
-

{category}

+ Object.keys(subscriptions.data) + .map((category) => ( +
+
+

{category}

+
+
+ {subscriptions.data?.[category].map((subscription) => ( + + ))} +
-
- {subscriptions.data?.[category].map((subscription) => ( - - ))} -
-
- )) + )) )} @@ -191,7 +202,7 @@ export const UserProfileModalContent: FC<{ {!user.data && ( )} @@ -244,8 +255,14 @@ const SubscriptionItem: FC<{ }) }} > - - {isFollowed ? "Edit" : APP_NAME} + {isFollowed ? ( + "Edit" + ) : ( + <> + + {APP_NAME} + + )}