feat: lighter unread number

This commit is contained in:
DIYgod
2024-08-04 20:00:08 +08:00
parent b0e86b08d5
commit e7dba4f18e
4 changed files with 24 additions and 12 deletions
@@ -26,6 +26,7 @@ import { useModalStack } from "../../components/ui/modal/stacked/hooks"
import { CategoryRemoveDialogContent } from "./category-remove-dialog"
import { CategoryRenameContent } from "./category-rename-dialog"
import { FeedItem } from "./item"
import { UnreadNumber } from "./unread-number"
type FeedId = string
interface FeedCategoryProps {
@@ -218,11 +219,7 @@ function FeedCategoryImpl({
{folderName}
</span>
</div>
{!!unread && showUnreadCount && (
<div className="ml-2 text-xs tabular-nums text-zinc-500 dark:text-neutral-400">
{unread}
</div>
)}
<UnreadNumber unread={unread} className="ml-2" />
</div>
)}
<AnimatePresence>
@@ -23,6 +23,8 @@ import { WEB_URL } from "@shared/constants"
import dayjs from "dayjs"
import { memo, useCallback } from "react"
import { UnreadNumber } from "./unread-number"
interface FeedItemProps {
feedId: string
view?: number
@@ -181,12 +183,7 @@ const FeedItemImpl = ({
)}
</div>
{showUnreadCount && !!feedUnread && (
<div className="ml-2 text-xs text-zinc-500 dark:text-neutral-400">
{feedUnread}
</div>
)}
<UnreadNumber unread={feedUnread} className="ml-2" />
</div>
</TooltipProvider>
)
@@ -14,6 +14,7 @@ import { useMemo, useState } from "react"
import { Link } from "react-router-dom"
import { FeedCategory } from "./category"
import { UnreadNumber } from "./unread-number"
const useGroupedData = (view: FeedViewType) => {
const { data: remoteData } = useAuthQuery(Queries.subscription.byView(view))
@@ -143,7 +144,7 @@ export function FeedList({
onClick={() => setExpansion(true)}
/>
)}
<span>{totalUnread}</span>
<UnreadNumber unread={totalUnread} className="text-xs" />
</div>
</div>
<ScrollArea.ScrollArea
@@ -0,0 +1,17 @@
import { useUISettingKey } from "@renderer/atoms/settings/ui"
import { cn } from "@renderer/lib/utils"
export const UnreadNumber = ({
unread,
className,
}: {
unread: number
className?: string
}) => {
const showUnreadCount = useUISettingKey("sidebarShowUnreadCount")
return !!showUnreadCount && !!unread && (
<div className={cn("text-[0.65rem] tabular-nums text-zinc-400 dark:text-neutral-500", className)}>
{unread}
</div>
)
}