-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Innei <tukon479@gmail.com>
- Loading branch information
Showing
3 changed files
with
118 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
apps/renderer/src/modules/entry-column/layouts/TimelineTabs.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { Tabs, TabsList, TabsTrigger } from "~/components/ui/tabs" | ||
import { useNavigateEntry } from "~/hooks/biz/useNavigateEntry" | ||
import { useRouteParams } from "~/hooks/biz/useRouteParams" | ||
import { InboxItem, ListItem } from "~/modules/feed-column/item" | ||
import { useSubscriptionStore } from "~/store/subscription" | ||
|
||
export const TimelineTabs = () => { | ||
const routerParams = useRouteParams() | ||
const { view, listId, inboxId } = routerParams | ||
|
||
const listsData = useSubscriptionStore((state) => | ||
state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "listId" in s), | ||
) | ||
const inboxData = useSubscriptionStore((state) => | ||
state.feedIdByView[view].map((id) => state.data[id]).filter((s) => "inboxId" in s), | ||
) | ||
const hasData = listsData.length > 0 || inboxData.length > 0 | ||
|
||
const timeline = listId || inboxId || "" | ||
|
||
const navigate = useNavigateEntry() | ||
if (!hasData) return null | ||
return ( | ||
<Tabs | ||
className="-ml-3 -mr-4 mt-1 overflow-x-auto scrollbar-none" | ||
value={timeline} | ||
onValueChange={(val) => { | ||
if (!val) { | ||
navigate({ | ||
feedId: null, | ||
entryId: null, | ||
view, | ||
}) | ||
} | ||
}} | ||
> | ||
<TabsList className="h-10 border-b-0"> | ||
<TabsTrigger variant={"rounded"} className="p-0" value=""> | ||
Yours | ||
</TabsTrigger> | ||
{listsData.map((s) => ( | ||
<TabsTrigger variant={"rounded"} className="p-0" key={s.listId} value={s.listId!}> | ||
<ListItem | ||
listId={s.listId!} | ||
view={view} | ||
iconSize={16} | ||
className="h-5 !bg-transparent p-0 leading-none" | ||
/> | ||
</TabsTrigger> | ||
))} | ||
{inboxData.map((s) => ( | ||
<TabsTrigger variant={"rounded"} key={s.inboxId} value={s.inboxId!}> | ||
<InboxItem | ||
inboxId={s.inboxId!} | ||
view={view} | ||
iconSize={16} | ||
className="h-5 !bg-transparent p-0 leading-none" | ||
/> | ||
</TabsTrigger> | ||
))} | ||
</TabsList> | ||
</Tabs> | ||
) | ||
} |