Skip to content

Commit

Permalink
feat: new feed column
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Sep 20, 2024
1 parent 958d687 commit 47f7e47
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 17 deletions.
7 changes: 0 additions & 7 deletions apps/renderer/src/modules/feed-column/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { m } from "framer-motion"
import type { FC, PropsWithChildren } from "react"
import { memo, useCallback, useRef, useState } from "react"
import { useTranslation } from "react-i18next"
import { Link } from "react-router-dom"
import { toast } from "sonner"

import { setAppSearchOpen } from "~/atoms/app"
Expand Down Expand Up @@ -34,7 +33,6 @@ const useBackHome = (active: number) => {

export const FeedColumnHeader = memo(() => {
const [active] = useSidebarActiveView()
const { t } = useTranslation()
const navigateBackHome = useBackHome(active)
const normalStyle = !window.electron || window.electron.process.platform !== "darwin"
return (
Expand Down Expand Up @@ -62,11 +60,6 @@ export const FeedColumnHeader = memo(() => {
<div className="relative flex items-center gap-1" onClick={stopPropagation}>
<SearchActionButton />

<Link to="/discover" tabIndex={-1}>
<ActionButton shortcut="Meta+T" tooltip={t("words.add")}>
<i className="i-mgc-add-cute-re size-5 text-theme-vibrancyFg" />
</ActionButton>
</Link>
<ProfileButton method="modal" />
<LayoutActionButton />
</div>
Expand Down
6 changes: 3 additions & 3 deletions apps/renderer/src/modules/feed-column/item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ const FeedItemImpl = ({ view, feedId, className, showUnreadCount = true }: FeedI
<div
data-feed-id={feedId}
className={cn(
"flex w-full items-center justify-between rounded-md py-[2px] pr-2.5 text-sm font-medium leading-loose",
"flex w-full items-center justify-between rounded-md py-[2px] pr-2.5 text-sm font-normal leading-loose",
(isActive || isContextMenuOpen) && "bg-native-active",

feed.type === "feed" ? "py-[2px]" : "py-1.5",
className,
)}
onClick={handleNavigate}
Expand Down Expand Up @@ -112,7 +112,7 @@ const FeedItemImpl = ({ view, feedId, className, showUnreadCount = true }: FeedI
feed.type === "feed" && feed.errorAt && "text-red-900 dark:text-red-500",
)}
>
<FeedIcon fallback feed={feed} size={16} />
<FeedIcon fallback feed={feed} size={feed.type === "feed" ? 16 : 32} />
<div
className={cn(
"truncate",
Expand Down
34 changes: 27 additions & 7 deletions apps/renderer/src/modules/feed-column/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as HoverCard from "@radix-ui/react-hover-card"
import { AnimatePresence, m } from "framer-motion"
import { Fragment, memo, useMemo, useState } from "react"
import { useTranslation } from "react-i18next"
import { Link } from "react-router-dom"
import { Link, useLocation, useNavigate } from "react-router-dom"

import { useUISettingKey } from "~/atoms/settings/ui"
import { ScrollArea } from "~/components/ui/scroll-area"
Expand Down Expand Up @@ -100,10 +100,13 @@ function FeedListImpl({ className, view }: { className?: string; view: number })
const hasData = Object.keys(feedsData).length > 0 || Object.keys(listsData).length > 0

const feedId = useRouteFeedId()
const navigate = useNavigateEntry()
const navigateEntry = useNavigateEntry()

const { t } = useTranslation()

const location = useLocation()
const navigate = useNavigate()

return (
<div className={cn(className, "font-medium")}>
<div
Expand All @@ -115,7 +118,7 @@ function FeedListImpl({ className, view }: { className?: string; view: number })
onClick={(e) => {
e.stopPropagation()
if (view !== undefined) {
navigate({
navigateEntry({
entryId: null,
feedId: null,
view,
Expand All @@ -136,6 +139,19 @@ function FeedListImpl({ className, view }: { className?: string; view: number })
</div>
</div>
<ScrollArea.ScrollArea mask={false} flex viewportClassName="!px-3" rootClassName="h-full">
<div
className={cn(
"flex h-8 w-full shrink-0 items-center rounded-md px-2.5 font-semibold transition-colors",
location.pathname === "/discover" && "bg-native-active",
)}
onClick={(e) => {
e.stopPropagation()
navigate(`/discover`)
}}
>
<i className="i-mgc-compass-cute-fi mr-2 text-blue-500" />
{t("words.discover")}
</div>
<div
className={cn(
"flex h-8 w-full shrink-0 items-center rounded-md px-2.5 font-semibold transition-colors",
Expand All @@ -144,7 +160,7 @@ function FeedListImpl({ className, view }: { className?: string; view: number })
onClick={(e) => {
e.stopPropagation()
if (view !== undefined) {
navigate({
navigateEntry({
entryId: null,
feedId: FEED_COLLECTION_LIST,
view,
Expand All @@ -155,11 +171,15 @@ function FeedListImpl({ className, view }: { className?: string; view: number })
<i className="i-mgc-star-cute-fi mr-2 text-amber-500" />
{t("words.starred")}
</div>
<div className="mt-4 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold text-theme-vibrancyFg transition-colors">
{t("words.lists")}
</div>
{Object.keys(listsData).length > 0 && (
<div className="my-2">
<SortableList view={view} expansion={expansion} data={listsData} />
</div>
<SortableList view={view} expansion={expansion} data={listsData} />
)}
<div className="mt-4 flex h-6 w-full shrink-0 items-center rounded-md px-2.5 text-xs font-semibold text-theme-vibrancyFg transition-colors">
{t("words.feeds")}
</div>
{hasData ? (
<SortableList view={view} expansion={expansion} data={feedsData} />
) : (
Expand Down
1 change: 1 addition & 0 deletions icons/mgc/compass_cute_fi.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions locales/app/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,11 @@
"words.confirm": "Confirm",
"words.discover": "Discover",
"words.email": "Email",
"words.feeds": "Feeds",
"words.import": "Import",
"words.items": "Items",
"words.language": "Language",
"words.lists": "Lists",
"words.load_archived_entries": "Load archived entries",
"words.login": "Login",
"words.rss": "RSS",
Expand Down

0 comments on commit 47f7e47

Please sign in to comment.