-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
477 additions
and
12 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
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,80 @@ | ||
--- | ||
title: Pagination | ||
description: Pagination with page navigation, next and previous links. | ||
--- | ||
|
||
<ComponentPreview | ||
name="pagination-demo" | ||
description="A pagination with previous and next links." | ||
/> | ||
|
||
## Installation | ||
|
||
<Tabs defaultValue="cli"> | ||
|
||
<TabsList> | ||
<TabsTrigger value="cli">CLI</TabsTrigger> | ||
<TabsTrigger value="manual">Manual</TabsTrigger> | ||
</TabsList> | ||
<TabsContent value="cli"> | ||
|
||
```bash | ||
npx shadcn-ng@latest add pagination | ||
``` | ||
|
||
</TabsContent> | ||
|
||
<TabsContent value="manual"> | ||
|
||
<Steps> | ||
|
||
<Step>Copy and paste the following code into your project.</Step> | ||
|
||
<ComponentSource name="pagination" /> | ||
|
||
<Step>Update the import paths to match your project setup.</Step> | ||
|
||
</Steps> | ||
|
||
</TabsContent> | ||
|
||
</Tabs> | ||
|
||
## Usage | ||
|
||
```tsx | ||
import { | ||
UbPaginationContentDirective, | ||
UbPaginationDirective, | ||
UbPaginationEllipsisComponent, | ||
UbPaginationItemDirective, | ||
UbPaginationLinkDirective, | ||
UbPaginationNextDirective, | ||
UbPaginationPreviousDirective, | ||
} from "@/components/ui/pagination" | ||
``` | ||
|
||
```html | ||
<nav ubPagination> | ||
<ul ubPaginationContent> | ||
<li ubPaginationItem> | ||
<a href="#" ubPaginationPrevious></a> | ||
</li> | ||
<li ubPaginationItem> | ||
<a ubPaginationLink href="#">1</a> | ||
</li> | ||
<li ubPaginationItem> | ||
<a ubPaginationLink href="#" isActive>2</a> | ||
</li> | ||
<li ubPaginationItem> | ||
<a ubPaginationLink href="#">3</a> | ||
</li> | ||
<li ubPaginationItem> | ||
<ub-pagination-ellipsis /> | ||
</li> | ||
<li ubPaginationItem> | ||
<a href="#" ubPaginationNext></a> | ||
</li> | ||
</ul> | ||
</nav> | ||
``` |
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,50 @@ | ||
import { | ||
UbPaginationContentDirective, | ||
UbPaginationDirective, | ||
UbPaginationEllipsisComponent, | ||
UbPaginationItemDirective, | ||
UbPaginationLinkDirective, | ||
UbPaginationNextDirective, | ||
UbPaginationPreviousDirective, | ||
} from '@/registry/default/ui/pagination' | ||
|
||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[pagination-demo-default]', | ||
imports: [ | ||
UbPaginationContentDirective, | ||
UbPaginationDirective, | ||
UbPaginationEllipsisComponent, | ||
UbPaginationItemDirective, | ||
UbPaginationLinkDirective, | ||
UbPaginationNextDirective, | ||
UbPaginationPreviousDirective, | ||
], | ||
template: ` | ||
<nav ubPagination> | ||
<ul ubPaginationContent> | ||
<li ubPaginationItem> | ||
<a href="#" ubPaginationPrevious></a> | ||
</li> | ||
<li ubPaginationItem> | ||
<a ubPaginationLink href="#">1</a> | ||
</li> | ||
<li ubPaginationItem> | ||
<a ubPaginationLink href="#" isActive>2</a> | ||
</li> | ||
<li ubPaginationItem> | ||
<a ubPaginationLink href="#">3</a> | ||
</li> | ||
<li ubPaginationItem> | ||
<ub-pagination-ellipsis /> | ||
</li> | ||
<li ubPaginationItem> | ||
<a href="#" ubPaginationNext></a> | ||
</li> | ||
</ul> | ||
</nav> | ||
`, | ||
}) | ||
export default class PaginationDemoDefault { } |
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,136 @@ | ||
import { cn } from '@/lib/utils' | ||
import { buttonVariants, type UbButtonSize } from '@/registry/default/ui/button' | ||
import { booleanAttribute, Component, computed, Directive, effect, inject, input } from '@angular/core' | ||
import { NgIcon, provideIcons } from '@ng-icons/core' | ||
import { lucideChevronLeft, lucideChevronRight, lucideEllipsis } from '@ng-icons/lucide' | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: 'nav[ubPagination]', | ||
host: { | ||
'role': 'navigation', | ||
'aria-label': 'pagination', | ||
'[class]': 'computedClass()', | ||
}, | ||
}) | ||
export class UbPaginationDirective { | ||
class = input<string>() | ||
computedClass = computed(() => cn('mx-auto flex w-full justify-center', this.class())) | ||
} | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: 'ul[ubPaginationContent]', | ||
host: { | ||
'[class]': 'computedClass()', | ||
}, | ||
}) | ||
export class UbPaginationContentDirective { | ||
class = input<string>() | ||
computedClass = computed(() => cn('flex flex-row items-center gap-1', this.class())) | ||
} | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: 'li[ubPaginationItem]', | ||
host: { | ||
'[class]': 'computedClass()', | ||
}, | ||
}) | ||
export class UbPaginationItemDirective { | ||
class = input<string>() | ||
computedClass = computed(() => cn('', this.class())) | ||
} | ||
|
||
@Directive({ | ||
standalone: true, | ||
selector: '[ubPaginationLink]', | ||
host: { | ||
'[aria-current]': 'isActive() ? "page" : undefined', | ||
'[class]': 'computedClass()', | ||
}, | ||
}) | ||
export class UbPaginationLinkDirective { | ||
class = input<string>() | ||
isActive = input(false, { transform: booleanAttribute }) | ||
size = input<UbButtonSize>('icon') | ||
computedClass = computed(() => cn( | ||
buttonVariants({ | ||
variant: this.isActive() ? 'outline' : 'ghost', | ||
size: this.size(), | ||
}), | ||
this.class(), | ||
)) | ||
} | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[ubPaginationPrevious]', | ||
imports: [NgIcon], | ||
hostDirectives: [UbPaginationLinkDirective], | ||
host: { | ||
'[class]': 'computedClass()', | ||
'aria-label': 'Go to previous page', | ||
}, | ||
providers: [provideIcons({ lucideChevronLeft })], | ||
template: ` | ||
<ng-icon name="lucideChevronLeft" class="w-4 h-4"></ng-icon> | ||
<span>Previous</span> | ||
`, | ||
}) | ||
export class UbPaginationPreviousDirective { | ||
class = input<string>() | ||
computedClass = computed(() => cn('gap-1 pl-2.5', this.class())) | ||
protected size = input<UbButtonSize>('default') | ||
private ubPaginationLinkDirective = inject(UbPaginationLinkDirective, { host: true }) | ||
|
||
setConfig = effect(() => { | ||
this.ubPaginationLinkDirective.size = this.size | ||
}) | ||
} | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[ubPaginationNext]', | ||
imports: [NgIcon], | ||
providers: [provideIcons({ lucideChevronRight })], | ||
hostDirectives: [UbPaginationLinkDirective], | ||
host: { | ||
'[class]': 'computedClass()', | ||
'aria-label': 'Go to next page', | ||
}, | ||
template: ` | ||
<span>Next</span> | ||
<ng-icon name="lucideChevronRight" class="w-4 h-4"></ng-icon> | ||
`, | ||
}) | ||
export class UbPaginationNextDirective { | ||
class = input<string>() | ||
computedClass = computed(() => cn('gap-1 pr-2.5', this.class())) | ||
protected size = input<UbButtonSize>('default') | ||
private ubPaginationLinkDirective = inject(UbPaginationLinkDirective, { host: true }) | ||
|
||
setConfig = effect(() => { | ||
this.ubPaginationLinkDirective.size = this.size | ||
}) | ||
} | ||
|
||
@Component({ | ||
standalone: true, | ||
imports: [NgIcon], | ||
providers: [provideIcons({ lucideEllipsis })], | ||
selector: 'ub-pagination-ellipsis', | ||
template: ` | ||
<span | ||
aria-hidden="true" | ||
[class]="computedClass()" | ||
> | ||
<ng-icon name="lucideEllipsis" class="w-4 h-4"></ng-icon> | ||
<span class="sr-only">More pages</span> | ||
</span> | ||
`, | ||
}) | ||
export class UbPaginationEllipsisComponent { | ||
class = input<string>() | ||
computedClass = computed(() => cn('flex h-9 w-9 items-center justify-center', this.class())) | ||
} |
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,50 @@ | ||
import { | ||
UbPaginationContentDirective, | ||
UbPaginationDirective, | ||
UbPaginationEllipsisComponent, | ||
UbPaginationItemDirective, | ||
UbPaginationLinkDirective, | ||
UbPaginationNextDirective, | ||
UbPaginationPreviousDirective, | ||
} from '@/registry/new-york/ui/pagination' | ||
|
||
import { Component } from '@angular/core' | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: '[pagination-demo-new-york]', | ||
imports: [ | ||
UbPaginationContentDirective, | ||
UbPaginationDirective, | ||
UbPaginationEllipsisComponent, | ||
UbPaginationItemDirective, | ||
UbPaginationLinkDirective, | ||
UbPaginationNextDirective, | ||
UbPaginationPreviousDirective, | ||
], | ||
template: ` | ||
<nav ubPagination> | ||
<ul ubPaginationContent> | ||
<li ubPaginationItem> | ||
<a href="#" ubPaginationPrevious></a> | ||
</li> | ||
<li ubPaginationItem> | ||
<a ubPaginationLink href="#">1</a> | ||
</li> | ||
<li ubPaginationItem> | ||
<a ubPaginationLink href="#" isActive>2</a> | ||
</li> | ||
<li ubPaginationItem> | ||
<a ubPaginationLink href="#">3</a> | ||
</li> | ||
<li ubPaginationItem> | ||
<ub-pagination-ellipsis /> | ||
</li> | ||
<li ubPaginationItem> | ||
<a href="#" ubPaginationNext></a> | ||
</li> | ||
</ul> | ||
</nav> | ||
`, | ||
}) | ||
export default class PaginationDemoNewYork { } |
Oops, something went wrong.