Skip to content

Commit 62bde1d

Browse files
committed
feat: enhance list feed item with active state and improved interaction
- Add active state highlighting for selected feed items - Implement event propagation prevention in feed item click handler - Update ListFeedList component to pass current feed ID for active state - Refine padding and styling for feed list items Signed-off-by: Innei <tukon479@gmail.com>
1 parent 3ad053b commit 62bde1d

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

apps/renderer/src/modules/timeline-column/FeedItem.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,8 @@ const FeedItemImpl = ({ view, feedId, className }: FeedItemProps) => {
171171
}
172172
className={cn(
173173
feedColumnStyles.item,
174-
isFeed ? "py-[2px]" : "py-1.5",
175-
"justify-between py-[2px]",
174+
isFeed ? "py-0.5" : "py-1.5",
175+
"justify-between py-0.5",
176176
className,
177177
)}
178178
onClick={handleClick}
@@ -354,7 +354,7 @@ const InboxItemImpl: Component<{
354354
className={cn(
355355
"flex w-full cursor-menu items-center justify-between rounded-md pr-2.5 text-base font-medium leading-loose lg:text-sm",
356356
feedColumnStyles.item,
357-
"py-[2px] pl-2.5",
357+
"py-0.5 pl-2.5",
358358
className,
359359
)}
360360
onClick={handleNavigate}

apps/renderer/src/modules/timeline-column/FeedList.mobile.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const FeedListImpl = ({ className, view }: { className?: string; view: number })
9292
feedId: null,
9393
})
9494
}}
95-
className={cn(feedColumnStyles.item, "px-2.5 py-[2px]")}
95+
className={cn(feedColumnStyles.item, "px-2.5 py-0.5")}
9696
>
9797
{views[view]!.icon}
9898
<span className="ml-2">

apps/renderer/src/modules/timeline-column/ListFeedList.tsx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ import {
77
} from "@follow/components/ui/tooltip/index.js"
88
import { cn } from "@follow/utils/utils"
99
import dayjs from "dayjs"
10-
import type { FC } from "react"
10+
import type { FC, MouseEventHandler } from "react"
1111
import { useTranslation } from "react-i18next"
1212

1313
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
14+
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
1415
import { useFeedById } from "~/store/feed"
1516
import { useListById } from "~/store/list"
1617

@@ -20,29 +21,42 @@ import { feedColumnStyles } from "./styles"
2021

2122
export const ListFeedList: FC<{ listId: string }> = ({ listId }) => {
2223
const list = useListById(listId)
24+
const currentFeedId = useRouteParamsSelector((s) => s.feedId)
2325

2426
if (!list) return null
2527
return (
2628
<ScrollArea.ScrollArea flex viewportClassName="!px-3" rootClassName="h-full">
27-
{list?.feedIds.map((feedId) => <FeedItem key={feedId} feedId={feedId} />)}
29+
{list?.feedIds.map((feedId) => (
30+
<FeedItem key={feedId} feedId={feedId} isActive={feedId === currentFeedId} />
31+
))}
2832
</ScrollArea.ScrollArea>
2933
)
3034
}
3135

3236
interface FeedItemProps {
3337
feedId: string
38+
isActive: boolean
3439
}
35-
const FeedItem = ({ feedId }: FeedItemProps) => {
40+
const FeedItem = ({ feedId, isActive }: FeedItemProps) => {
3641
const feed = useFeedById(feedId)
3742
const { t } = useTranslation()
3843
const navigate = useNavigateEntry()
44+
3945
if (!feed) return null
4046

41-
const handleClick = () => {
47+
const handleClick: MouseEventHandler<HTMLDivElement> = (e) => {
48+
e.stopPropagation()
4249
navigate({ feedId })
4350
}
4451
return (
45-
<div className={cn("my-px px-2.5 py-0.5", feedColumnStyles.item)} onClick={handleClick}>
52+
<div
53+
className={cn(
54+
"my-px px-2.5 py-0.5",
55+
feedColumnStyles.item,
56+
isActive && "bg-theme-item-active",
57+
)}
58+
onClick={handleClick}
59+
>
4660
<div
4761
className={cn(
4862
"flex min-w-0 items-center",

0 commit comments

Comments
 (0)