-
-
Notifications
You must be signed in to change notification settings - Fork 376
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: pagination overflowing #614
fix: pagination overflowing #614
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hey @HubbeDev, thanks for taking this on! I don't think we should change the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just update the demos to be responsive rather than the individual components. Those can remain as they are in the main
branch!
Actually what we could do is update the pagination next button and previous buttons to keep the existing API the same, but move it into a slot fallback, so something like this: <PaginationPrimitive.PrevButton asChild let:builder>
<Button
variant="ghost"
class={cn("gap-1 pl-2.5", className)}
builders={[builder]}
on:click
{...$$restProps}
>
<slot>
<ChevronLeft class="h-4 w-4" />
<span class="hidden sm:block">Previous</span>
</slot>
</Button>
</PaginationPrimitive.PrevButton> This way, in our updated <Pagination.Item>
<Pagination.PrevButton>
<ChevronLeft class="h-4 w-4" />
<span class="hidden sm:block">Previous</span>
</Pagination.PrevButton>
</Pagination.Item> And the same would go for the next button of course. If you want to update how many pages there are for smaller screens, you could do something like this in the <script lang="ts">
import * as Pagination from "@/registry/default/ui/pagination";
import { mediaQuery } from "svelte-legos";
const isDesktop = mediaQuery("(min-width: 768px)");
let count = 20;
$: perPage = $isDesktop ? 3 : 8
</script> or something like that! |
@huntabyte I have moved the logic outside the components now with a slot instead. |
Oh, this is actually a bug with |
Just pushed a commit that fixes this issue! Thanks a ton @HubbeDev, you're greatly appreciated! |
This pr attempts to fix #600. Im not 100% sure this is the right way to go.
Feel free to come with feedback if their is a better approach.
The fix includes
Hide every page item except current page item and ellipsis.
I also hide the "Previous" and "Next" labels on small screen to make it more tidy.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.pnpm format
andpnpm lint