Skip to content

Commit

Permalink
feat: empty status for columns
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jun 3, 2024
1 parent 571d36e commit 546cc51
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 10 deletions.
23 changes: 23 additions & 0 deletions src/renderer/src/components/entry-column/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export function EntryColumn() {
const virtuosoOptions = {
components: {
List: ListContent,
EmptyPlaceholder: EmptyList,
},
overscan: window.innerHeight,
rangeChanged: handleRangeChange,
Expand Down Expand Up @@ -260,3 +261,25 @@ const ListContent = forwardRef<HTMLDivElement>((props, ref) => (
ref={ref}
/>
))

const EmptyList = (props, ref) => {
const unreadOnly = useAtomValue(unreadOnlyAtom)

return (
<m.div
initial={{ opacity: 0.01, y: 100 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0.01, y: -100 }}
className="-mt-10 flex h-full flex-col items-center justify-center gap-2 text-zinc-400"
{...props}
ref={ref}
>
{unreadOnly && (
<>
<i className="i-mingcute-celebrate-line text-4xl" />
Zero Unread
</>
)}
</m.div>
)
}
2 changes: 1 addition & 1 deletion src/renderer/src/components/feed-column/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function FeedColumn() {
key={item.name}
className="shrink-0 snap-center overflow-y-auto"
>
<FeedList className="mb-6 w-64 px-3" view={index} />
<FeedList className="flex min-h-full w-64 flex-col px-3 pb-6" view={index} />
</section>
))}
</m.div>
Expand Down
27 changes: 18 additions & 9 deletions src/renderer/src/components/feed-column/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { cn } from "@renderer/lib/utils"
import { Queries } from "@renderer/queries"
import { feedActions } from "@renderer/store"
import { useState } from "react"
import { Link } from "react-router-dom"

import { FeedCategory } from "./category"

Expand All @@ -19,7 +20,6 @@ export function FeedList({
const subscriptions = useBizQuery(Queries.subscription.byView(view))
const [expansion, setExpansion] = useState(false)
const { setActiveList } = feedActions
console.log(subscriptions.data)

return (
<div className={className}>
Expand Down Expand Up @@ -60,14 +60,23 @@ export function FeedList({
</div>
</div>
)}
{subscriptions.data?.list.map((category) => (
<FeedCategory
key={category.name}
data={category}
view={view}
expansion={expansion}
/>
))}
{subscriptions.data?.list?.length ?
subscriptions.data?.list.map((category) => (
<FeedCategory
key={category.name}
data={category}
view={view}
expansion={expansion}
/>
)) :
(
<div className="flex h-full flex-1 items-center text-zinc-500">
<Link to="/discover" className="-mt-36 flex h-full flex-1 flex-col items-center justify-center gap-2">
<i className="i-mingcute-add-line text-3xl " />
Add some feeds
</Link>
</div>
)}
</div>
)
}

0 comments on commit 546cc51

Please sign in to comment.