From 23664e6ceb05db393bba84003cce2c6b82e81abb Mon Sep 17 00:00:00 2001 From: DIYgod Date: Sat, 23 Aug 2025 01:20:10 +0800 Subject: [PATCH] feat: smoother entry header animation - Removed unused imports and components from AIEntryLayout, simplifying the layout structure. - Updated EntryContent to adjust height dynamically and improved the scroll area with a new viewport class. - Enhanced EntryHeader to integrate a scroll-to-exit hint directly into the header, improving user guidance. - Refactored EntryHeaderRoot to support motion styles for smoother animations. These changes collectively improve code clarity and enhance the user experience by providing better navigation cues and layout responsiveness. --- .../modules/entry-column/AIEntryLayout.tsx | 37 +--------- .../entry-content/EntryContent.ai.tsx | 8 ++- .../components/entry-header/AIEntryHeader.tsx | 68 ++++++++++++++++--- .../internal/EntryHeaderReadHistory.tsx | 3 +- .../entry-header/internal/context.tsx | 17 ++++- 5 files changed, 81 insertions(+), 52 deletions(-) diff --git a/apps/desktop/layer/renderer/src/modules/entry-column/AIEntryLayout.tsx b/apps/desktop/layer/renderer/src/modules/entry-column/AIEntryLayout.tsx index 5f53bb0ba..c9ee586bf 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-column/AIEntryLayout.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-column/AIEntryLayout.tsx @@ -1,11 +1,9 @@ import { Spring } from "@follow/components/constants/spring.js" -import { Button } from "@follow/components/ui/button/index.js" import { PanelSplitter } from "@follow/components/ui/divider/index.js" import { defaultUISettings } from "@follow/shared/settings/defaults" import { cn } from "@follow/utils" import { AnimatePresence } from "motion/react" import { useCallback, useEffect, useMemo, useRef } from "react" -import { useTranslation } from "react-i18next" import { useResizable } from "react-resizable-layout" import { useParams } from "react-router" @@ -19,14 +17,11 @@ import { EntryContent } from "~/modules/entry-content/components/entry-content" import { AppLayoutGridContainerProvider } from "~/providers/app-grid-layout-container-provider" import { AIChatRoot } from "../ai-chat/components/layouts/AIChatRoot" -import { useEntryContentScrollToTop } from "../entry-content/atoms" import { setScrollToExitTutorialSeen } from "./atoms/tutorial" -import { ScrollToExitTutorial } from "./components/ScrollToExitTutorial" import { EntryColumn } from "./index" const AIEntryLayoutImpl = () => { const { entryId } = useParams() - const { t } = useTranslation() const navigate = useNavigateEntry() const panelStyle = useAIChatPanelStyle() @@ -120,8 +115,6 @@ const AIEntryLayoutImpl = () => { window.dispatchEvent(new Event("resize")) }, }) - const isAtTop = !!useEntryContentScrollToTop() - return (
@@ -141,35 +134,7 @@ const AIEntryLayoutImpl = () => { transition={Spring.presets.smooth} className="bg-theme-background absolute inset-0 z-10 border-l" > - - {/* Scroll hint indicator */} - {isAtTop && ( - - - - )} - - - {/* First-time user tutorial for scroll-to-exit */} - - - + )} diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.ai.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.ai.tsx index a49d8e9af..2f43f49ad 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.ai.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-content/EntryContent.ai.tsx @@ -112,7 +112,7 @@ const EntryContentImpl: Component = ({
@@ -129,7 +129,7 @@ const EntryContentImpl: Component = ({ /> {/* */} - + {/* Indicator for the entry */} {!isZenMode && isInHasTimelineView && ( <> @@ -211,7 +211,8 @@ export const EntryContent = memo(EntryContentImpl) const EntryScrollArea: Component<{ scrollerRef: React.RefObject -}> = ({ children, className, scrollerRef }) => { + viewportClassName?: string +}> = ({ children, className, scrollerRef, viewportClassName }) => { const isInPeekModal = useInPeekModal() if (isInPeekModal) { @@ -228,6 +229,7 @@ const EntryScrollArea: Component<{ )} scrollbarClassName="mr-[1.5px] print:hidden" ref={scrollerRef} + viewportClassName={viewportClassName} > {children} diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/AIEntryHeader.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/AIEntryHeader.tsx index 3019bb904..b91100862 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/AIEntryHeader.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/AIEntryHeader.tsx @@ -1,4 +1,12 @@ +import { Button } from "@follow/components/ui/button/index.js" +import { cn } from "@follow/utils" import { memo } from "react" +import { useTranslation } from "react-i18next" + +import { m } from "~/components/common/Motion" +import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry" +import { ScrollToExitTutorial } from "~/modules/entry-column/components/ScrollToExitTutorial" +import { useEntryContentScrollToTop } from "~/modules/entry-content/atoms" import { EntryHeaderRoot } from "./internal/context" import { EntryHeaderActionsContainer } from "./internal/EntryHeaderActionsContainer" @@ -7,17 +15,59 @@ import { EntryHeaderReadHistory } from "./internal/EntryHeaderReadHistory" import type { EntryHeaderProps } from "./types" function EntryHeaderImpl({ entryId, className, compact }: EntryHeaderProps) { + const { t } = useTranslation() + const navigate = useNavigateEntry() + const isAtTop = !!useEntryContentScrollToTop() + return ( - - -
+ - - -
-
+ {/* Scroll to exit hint - integrated into header to maintain consistent height */} + + + + +
+ +
+ + +
+
+ + {/* First-time user tutorial for scroll-to-exit */} + + + ) } diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderReadHistory.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderReadHistory.tsx index 3794fc880..232dddbe9 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderReadHistory.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/EntryHeaderReadHistory.tsx @@ -8,7 +8,7 @@ import { useEntryContentScrollToTop } from "../../../atoms" import { EntryReadHistory } from "../../entry-read-history" import { useEntryHeaderContext } from "./context" -function EntryHeaderReadHistoryImpl() { +function EntryHeaderReadHistoryImpl({ className }: { className?: string }) { const { entryId } = useEntryHeaderContext() const { view } = useRouteParams() const isAtTop = useEntryContentScrollToTop() @@ -21,6 +21,7 @@ function EntryHeaderReadHistoryImpl() { "zen-mode-macos:left-12 text-body absolute left-5 top-0 flex h-full items-center gap-2 leading-none", "visible z-[11]", isWide && "static", + className, )} > diff --git a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/context.tsx b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/context.tsx index 840fcf083..9b9b441a2 100644 --- a/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/context.tsx +++ b/apps/desktop/layer/renderer/src/modules/entry-content/components/entry-header/internal/context.tsx @@ -1,8 +1,11 @@ import { useHasEntry } from "@follow/store/entry/hooks" import { cn } from "@follow/utils/utils" +import type { MotionStyle } from "motion/react" import type { ReactNode } from "react" import { createContext, memo, use, useMemo } from "react" +import { m } from "~/components/common/Motion" + import { useEntryContentScrollToTop, useEntryTitleMeta } from "../../../atoms" import type { EntryHeaderProps } from "../types" @@ -21,9 +24,16 @@ export function useEntryHeaderContext() { export interface EntryHeaderRootProps extends EntryHeaderProps { children: ReactNode + style?: MotionStyle } -function EntryHeaderRootImpl({ entryId, className, compact, children }: EntryHeaderRootProps) { +function EntryHeaderRootImpl({ + entryId, + className, + compact, + children, + style, +}: EntryHeaderRootProps) { const hasEntry = useHasEntry(entryId) const entryTitleMeta = useEntryTitleMeta() const isAtTop = !!useEntryContentScrollToTop() @@ -35,16 +45,17 @@ function EntryHeaderRootImpl({ entryId, className, compact, children }: EntryHea return ( -
{children} -
+
) }