Skip to content

Commit

Permalink
feat: enhance list feed item with active state and improved interaction
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
Innei committed Feb 10, 2025
1 parent 3ad053b commit 62bde1d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
6 changes: 3 additions & 3 deletions apps/renderer/src/modules/timeline-column/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ const FeedItemImpl = ({ view, feedId, className }: FeedItemProps) => {
}
className={cn(
feedColumnStyles.item,
isFeed ? "py-[2px]" : "py-1.5",
"justify-between py-[2px]",
isFeed ? "py-0.5" : "py-1.5",
"justify-between py-0.5",
className,
)}
onClick={handleClick}
Expand Down Expand Up @@ -354,7 +354,7 @@ const InboxItemImpl: Component<{
className={cn(
"flex w-full cursor-menu items-center justify-between rounded-md pr-2.5 text-base font-medium leading-loose lg:text-sm",
feedColumnStyles.item,
"py-[2px] pl-2.5",
"py-0.5 pl-2.5",
className,
)}
onClick={handleNavigate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const FeedListImpl = ({ className, view }: { className?: string; view: number })
feedId: null,
})
}}
className={cn(feedColumnStyles.item, "px-2.5 py-[2px]")}
className={cn(feedColumnStyles.item, "px-2.5 py-0.5")}
>
{views[view]!.icon}
<span className="ml-2">
Expand Down
24 changes: 19 additions & 5 deletions apps/renderer/src/modules/timeline-column/ListFeedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import {
} from "@follow/components/ui/tooltip/index.js"
import { cn } from "@follow/utils/utils"
import dayjs from "dayjs"
import type { FC } from "react"
import type { FC, MouseEventHandler } from "react"
import { useTranslation } from "react-i18next"

import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry"
import { useRouteParamsSelector } from "~/hooks/biz/useRouteParams"
import { useFeedById } from "~/store/feed"
import { useListById } from "~/store/list"

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

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

if (!list) return null
return (
<ScrollArea.ScrollArea flex viewportClassName="!px-3" rootClassName="h-full">
{list?.feedIds.map((feedId) => <FeedItem key={feedId} feedId={feedId} />)}
{list?.feedIds.map((feedId) => (
<FeedItem key={feedId} feedId={feedId} isActive={feedId === currentFeedId} />
))}
</ScrollArea.ScrollArea>
)
}

interface FeedItemProps {
feedId: string
isActive: boolean
}
const FeedItem = ({ feedId }: FeedItemProps) => {
const FeedItem = ({ feedId, isActive }: FeedItemProps) => {
const feed = useFeedById(feedId)
const { t } = useTranslation()
const navigate = useNavigateEntry()

if (!feed) return null

const handleClick = () => {
const handleClick: MouseEventHandler<HTMLDivElement> = (e) => {
e.stopPropagation()
navigate({ feedId })
}
return (
<div className={cn("my-px px-2.5 py-0.5", feedColumnStyles.item)} onClick={handleClick}>
<div
className={cn(
"my-px px-2.5 py-0.5",
feedColumnStyles.item,
isActive && "bg-theme-item-active",
)}
onClick={handleClick}
>
<div
className={cn(
"flex min-w-0 items-center",
Expand Down

0 comments on commit 62bde1d

Please sign in to comment.