From 5d2fe70b52a857c16ed7220fc36ecd5111f8cd4d Mon Sep 17 00:00:00 2001 From: Innei Date: Fri, 27 Dec 2024 23:52:15 +0800 Subject: [PATCH] feat: enhance SocialMediaItem component with dynamic title styling and action bar positioning - Added state management for action reference and title reference in SocialMediaItem. - Updated title rendering to dynamically adjust padding based on available space. - Integrated EllipsisHorizontalTextWithTooltip for improved title display in FeedTitle component. - Enhanced layout to ensure action bar is positioned correctly based on screen size. This update improves the user experience by ensuring that titles are displayed clearly and actions are accessible without overlap. Signed-off-by: Innei --- .../entry-column/Items/social-media-item.tsx | 24 +++++++++++++++---- apps/renderer/src/modules/feed/feed-title.tsx | 10 ++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/apps/renderer/src/modules/entry-column/Items/social-media-item.tsx b/apps/renderer/src/modules/entry-column/Items/social-media-item.tsx index bcee672f7d..f046ca8757 100644 --- a/apps/renderer/src/modules/entry-column/Items/social-media-item.tsx +++ b/apps/renderer/src/modules/entry-column/Items/social-media-item.tsx @@ -55,6 +55,8 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl }, []) const autoExpandLongSocialMedia = useGeneralSettingKey("autoExpandLongSocialMedia") + const [actionRef, setActionRef] = useState(null) + const titleRef = useRef(null) if (!entry || !feed) return null const content = entry.entries.content || entry.entries.description @@ -79,12 +81,26 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl
-
- +
+ acc + (node as HTMLElement).offsetWidth, + 0, + ) + + actionRef.offsetWidth > + ref.current.offsetWidth + ? actionRef.offsetWidth + : 0, + } + : undefined + } feed={feed} title={entry.entries.author || feed.title} - titleClassName="max-w-[calc(100vw-8rem)]" /> {parsed?.type === "x" && ( @@ -121,7 +137,7 @@ export const SocialMediaItem: EntryListItemFC = ({ entryId, entryPreview, transl
{showAction && !isMobile && ( -
+
)} diff --git a/apps/renderer/src/modules/feed/feed-title.tsx b/apps/renderer/src/modules/feed/feed-title.tsx index fb1479c005..3a9b068dd3 100644 --- a/apps/renderer/src/modules/feed/feed-title.tsx +++ b/apps/renderer/src/modules/feed/feed-title.tsx @@ -1,3 +1,4 @@ +import { EllipsisHorizontalTextWithTooltip } from "@follow/components/ui/typography/EllipsisWithTooltip.js" import type { FeedOrListRespModel } from "@follow/models/types" import { cn } from "@follow/utils/utils" @@ -11,19 +12,24 @@ export const FeedTitle = ({ className, titleClassName, title, + style, }: { feed: FeedOrListRespModel | null className?: string titleClassName?: string title?: string | null + style?: React.CSSProperties }) => { const hideExtraBadge = useUISettingKey("hideExtraBadge") if (!feed) return null return ( -
-
{getPreferredTitle(feed) || title}
+
+ + {getPreferredTitle(feed) || title} + {/* {title?.repeat(222)} */} + {!hideExtraBadge && ( <>