Skip to content

Commit 11a188e

Browse files
HubbeDevhuntabyte
andauthored
fix: pagination overflowing (#614)
Co-authored-by: Hunter Johnston <[email protected]>
1 parent 6336d5e commit 11a188e

File tree

15 files changed

+68
-38
lines changed

15 files changed

+68
-38
lines changed

apps/www/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"@internationalized/date": "^3.5.1",
7575
"@unovis/svelte": "^1.3.1",
7676
"@unovis/ts": "^1.3.1",
77-
"bits-ui": "0.13.3",
77+
"bits-ui": "0.13.4",
7878
"clsx": "^2.1.0",
7979
"cmdk-sv": "^0.0.12",
8080
"d3-scale": "^4.0.2",

apps/www/pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/www/src/content/components/pagination.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ npm install bits-ui
5252
<Pagination.Ellipsis />
5353
</Pagination.Item>
5454
{:else}
55-
<Pagination.Item>
55+
<Pagination.Item isVisible={currentPage == page.value}>
5656
<Pagination.Link {page} isActive={currentPage == page.value}>
5757
{page.value}
5858
</Pagination.Link>

apps/www/src/lib/registry/default/example/pagination-demo.svelte

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
<script lang="ts">
22
import * as Pagination from "@/registry/default/ui/pagination";
3+
import { ChevronLeft, ChevronRight } from "lucide-svelte";
4+
import { mediaQuery } from "svelte-legos";
35
4-
let count = 100;
5-
let perPage = 10;
6+
const isDesktop = mediaQuery("(min-width: 768px)");
7+
8+
let count = 20;
9+
$: perPage = $isDesktop ? 3 : 8;
10+
$: siblingCount = $isDesktop ? 1 : 0;
611
</script>
712

8-
<Pagination.Root {count} {perPage} let:pages let:currentPage>
13+
<Pagination.Root {count} {perPage} {siblingCount} let:pages let:currentPage>
914
<Pagination.Content>
1015
<Pagination.Item>
11-
<Pagination.PrevButton />
16+
<Pagination.PrevButton>
17+
<ChevronLeft class="h-4 w-4" />
18+
<span class="hidden sm:block">Previous</span>
19+
</Pagination.PrevButton>
1220
</Pagination.Item>
1321
{#each pages as page (page.key)}
1422
{#if page.type === "ellipsis"}
@@ -27,7 +35,10 @@
2735
{/if}
2836
{/each}
2937
<Pagination.Item>
30-
<Pagination.NextButton />
38+
<Pagination.NextButton>
39+
<span class="hidden sm:block">Next</span>
40+
<ChevronRight class="h-4 w-4" />
41+
</Pagination.NextButton>
3142
</Pagination.Item>
3243
</Pagination.Content>
3344
</Pagination.Root>

apps/www/src/lib/registry/default/ui/pagination/pagination-item.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import type { HTMLAttributes } from "svelte/elements";
44
55
type $$Props = HTMLAttributes<HTMLLIElement>;
6-
76
let className: $$Props["class"] = undefined;
7+
88
export { className as class };
99
</script>
1010

apps/www/src/lib/registry/default/ui/pagination/pagination-next-button.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
<PaginationPrimitive.NextButton asChild let:builder>
1515
<Button
1616
variant="ghost"
17-
class={cn("gap-1 pl-2.5", className)}
17+
class={cn("gap-1 pr-2.5", className)}
1818
builders={[builder]}
1919
on:click
2020
{...$$restProps}
2121
>
22-
<span>Next</span>
23-
<ChevronRight class="h-4 w-4" />
22+
<slot>
23+
<span>Next</span>
24+
<ChevronRight class="h-4 w-4" />
25+
</slot>
2426
</Button>
2527
</PaginationPrimitive.NextButton>

apps/www/src/lib/registry/default/ui/pagination/pagination-prev-button.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
on:click
2020
{...$$restProps}
2121
>
22-
<ChevronLeft class="h-4 w-4" />
23-
<span>Previous</span>
22+
<slot>
23+
<ChevronLeft class="h-4 w-4" />
24+
<span>Previous</span>
25+
</slot>
2426
</Button>
2527
</PaginationPrimitive.PrevButton>

apps/www/src/lib/registry/new-york/example/pagination-demo.svelte

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
<script lang="ts">
22
import * as Pagination from "@/registry/new-york/ui/pagination";
3+
import { ChevronLeft, ChevronRight } from "radix-icons-svelte";
4+
import { mediaQuery } from "svelte-legos";
5+
6+
const isDesktop = mediaQuery("(min-width: 768px)");
37
48
let count = 20;
5-
let perPage = 3;
9+
$: perPage = $isDesktop ? 3 : 8;
10+
$: siblingCount = $isDesktop ? 1 : 0;
611
</script>
712

8-
<Pagination.Root {count} {perPage} let:pages let:currentPage>
13+
<Pagination.Root {count} {perPage} {siblingCount} let:pages let:currentPage>
914
<Pagination.Content>
1015
<Pagination.Item>
11-
<Pagination.PrevButton />
16+
<Pagination.PrevButton>
17+
<ChevronLeft class="h-4 w-4" />
18+
<span class="hidden sm:block">Previous</span>
19+
</Pagination.PrevButton>
1220
</Pagination.Item>
1321
{#each pages as page (page.key)}
1422
{#if page.type === "ellipsis"}
@@ -27,7 +35,10 @@
2735
{/if}
2836
{/each}
2937
<Pagination.Item>
30-
<Pagination.NextButton />
38+
<Pagination.NextButton>
39+
<span class="hidden sm:block">Next</span>
40+
<ChevronRight class="h-4 w-4" />
41+
</Pagination.NextButton>
3142
</Pagination.Item>
3243
</Pagination.Content>
3344
</Pagination.Root>

apps/www/src/lib/registry/new-york/ui/pagination/pagination-item.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import type { HTMLAttributes } from "svelte/elements";
44
55
type $$Props = HTMLAttributes<HTMLLIElement>;
6-
76
let className: $$Props["class"] = undefined;
7+
88
export { className as class };
99
</script>
1010

apps/www/src/lib/registry/new-york/ui/pagination/pagination-next-button.svelte

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
<PaginationPrimitive.NextButton asChild let:builder>
1515
<Button
1616
variant="ghost"
17-
class={cn("gap-1 pl-2.5", className)}
17+
class={cn("gap-1 pr-2.5", className)}
1818
builders={[builder]}
1919
on:click
2020
{...$$restProps}
2121
>
22-
<span>Next</span>
23-
<ChevronRight class="h-4 w-4" />
22+
<slot>
23+
<span>Next</span>
24+
<ChevronRight class="h-4 w-4" />
25+
</slot>
2426
</Button>
2527
</PaginationPrimitive.NextButton>

0 commit comments

Comments
 (0)