-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #302 from Southclaws/thread-feed-pagination
implement infinite-scroll-paginated thread feed
- Loading branch information
Showing
14 changed files
with
532 additions
and
120 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
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
55 changes: 55 additions & 0 deletions
55
web/src/components/site/PaginationBubble/PaginationBubble.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,55 @@ | ||
import { parseAsInteger, useQueryState } from "nuqs"; | ||
|
||
import { Box, CardBox } from "@/styled-system/jsx"; | ||
|
||
import { PaginationControls } from "../PaginationControls/PaginationControls"; | ||
|
||
type Props = { | ||
path: string; | ||
totalPages: number; | ||
pageSize: number; | ||
onPageChange: (page: number) => void; | ||
}; | ||
|
||
export function PaginationBubble({ | ||
path, | ||
totalPages, | ||
pageSize, | ||
onPageChange, | ||
}: Props) { | ||
const [page, setPage] = useQueryState("page", { | ||
...parseAsInteger, | ||
defaultValue: 1, | ||
clearOnDefault: true, | ||
}); | ||
|
||
function handlePage(page: number) { | ||
setPage(page); | ||
onPageChange(page); | ||
} | ||
|
||
const isFirst = page === 1; | ||
|
||
return ( | ||
<Box | ||
style={{ | ||
display: isFirst ? "none" : "block", | ||
}} | ||
position="fixed" | ||
bottom={{ | ||
base: "24", | ||
md: "8", | ||
}} | ||
> | ||
<CardBox borderRadius="lg" p="1"> | ||
<PaginationControls | ||
path={path} | ||
currentPage={page} | ||
pageSize={pageSize} | ||
totalPages={totalPages} | ||
onClick={handlePage} | ||
/> | ||
</CardBox> | ||
</Box> | ||
); | ||
} |
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
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
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
Oops, something went wrong.