-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: pagination with changer, jump to, text links, total number text…
… and simple mode
- Loading branch information
1 parent
84cb4d0
commit 95f9767
Showing
33 changed files
with
715 additions
and
43 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
93 changes: 67 additions & 26 deletions
93
projects/design-angular-kit/src/lib/components/core/pagination/pagination.component.html
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 |
---|---|---|
@@ -1,42 +1,83 @@ | ||
<nav class="pagination-wrapper" | ||
[class.justify-content-center]="alignment==='center'" | ||
[class.justify-content-end]="alignment==='end'"> | ||
<ul class="pagination"> | ||
[class.justify-content-end]="alignment==='end'" | ||
[class.pagination-total]="totalNumberText.hasChildNodes()"> | ||
|
||
<ul *ngIf="pages.length" class="pagination"> | ||
<li class="page-item" [class.disabled]="currentPage < 1"> | ||
<a class="page-link" (click)="pageChange(currentPage)"> | ||
<it-icon name="chevron-left" color="primary"></it-icon> | ||
<span class="visually-hidden">{{'it.core.previous-page'|translate}}</span> | ||
<a class="page-link" [class.text]="isTextLinks" href="#" (click)="pageChange($event, currentPage)"> | ||
<it-icon *ngIf="!isTextLinks" name="chevron-left" color="primary"></it-icon> | ||
<span class="visually-hidden"> | ||
{{(isTextLinks ? 'it.core.page' : 'it.core.previous-page') | translate}} | ||
</span> | ||
<ng-container *ngIf="isTextLinks">{{'it.core.previous' | translate}}</ng-container> | ||
</a> | ||
</li> | ||
|
||
<ng-container *ngIf="pageNumbers > 5 && currentPage > 2"> | ||
<li class="page-item"><a class="page-link" (click)="pageChange(1)">1</a></li> | ||
<li class="page-item" *ngIf="currentPage > 3"> | ||
<span class="page-link">...</span> | ||
<ng-container *ngIf="isSimpleMode; else defaultView"> | ||
<li class="page-item"><span class="page-link" aria-current="page">{{currentPage + 1}}</span></li> | ||
<li class="page-item"><span class="page-link">/</span></li> | ||
<li class="page-item"><span class="page-link">{{pageNumbers}}</span></li> | ||
<li class="page-item visually-hidden"> | ||
<a class="page-link" href="#" aria-current="page"> | ||
{{'it.core.page-of-total'|translate : {page: (currentPage + 1), total: pageNumbers} }} | ||
</a> | ||
</li> | ||
</ng-container> | ||
<ng-template #defaultView> | ||
<ng-container *ngIf="pageNumbers > visiblePages && pages[0] >= 2"> | ||
<li class="page-item"> | ||
<a class="page-link" href="#" (click)="pageChange($event, 1)">1</a> | ||
</li> | ||
<li class="page-item" *ngIf="pages[0] >= 3"> | ||
<span class="page-link">...</span> | ||
</li> | ||
</ng-container> | ||
|
||
<li class="page-item" *ngFor="let page of pages"> | ||
<a class="page-link" aria-current="page" *ngIf="page === (currentPage + 1); else inactivePage"> | ||
<span class="d-inline-block d-sm-none">{{'it.core.page'|translate}}</span> {{page}} | ||
</a> | ||
<ng-template #inactivePage> | ||
<a class="page-link" (click)="pageChange(page)">{{page}}</a> | ||
</ng-template> | ||
</li> | ||
|
||
<ng-container *ngIf="pageNumbers > 5 && pageNumbers - currentPage > 3"> | ||
<li class="page-item"> | ||
<span class="page-link">...</span> | ||
<li class="page-item" *ngFor="let page of pages"> | ||
<a class="page-link" aria-current="page" *ngIf="page === (currentPage + 1); else inactivePage"> | ||
<span class="d-inline-block d-sm-none">{{'it.core.page'|translate}}</span> {{page}} | ||
</a> | ||
<ng-template #inactivePage> | ||
<a class="page-link" href="#" (click)="pageChange($event, page)">{{page}}</a> | ||
</ng-template> | ||
</li> | ||
<li class="page-item"><a class="page-link" (click)="pageChange(pageNumbers)">{{pageNumbers}}</a></li> | ||
</ng-container> | ||
|
||
<ng-container *ngIf="pageNumbers > visiblePages && pages[pages.length - 1] < pageNumbers"> | ||
<li class="page-item" *ngIf="pages[pages.length - 1] < (pageNumbers - 1)"> | ||
<span class="page-link">...</span> | ||
</li> | ||
<li class="page-item"> | ||
<a class="page-link" href="#" (click)="pageChange($event, pageNumbers)">{{pageNumbers}}</a> | ||
</li> | ||
</ng-container> | ||
</ng-template> | ||
|
||
<li class="page-item" [class.disabled]="currentPage >= pageNumbers - 1"> | ||
<a class="page-link" (click)="pageChange(currentPage + 2)"> | ||
<span class="visually-hidden">{{'it.core.next-page'|translate}}</span> | ||
<it-icon name="chevron-right" color="primary"></it-icon> | ||
<a class="page-link" [class.text]="isTextLinks" href="#" (click)="pageChange($event, currentPage + 2)"> | ||
<span class="visually-hidden"> | ||
{{(isTextLinks ? 'it.core.page' : 'it.core.next-page') | translate}} | ||
</span> | ||
<ng-container *ngIf="isTextLinks">{{'it.core.next' | translate}}</ng-container> | ||
<it-icon *ngIf="!isTextLinks" name="chevron-right" color="primary"></it-icon> | ||
</a> | ||
</li> | ||
</ul> | ||
|
||
<it-dropdown *ngIf="currentChanger !== undefined" id="pager-changer"> | ||
<span button>{{currentChanger}} / {{'it.core.page' | translate | lowercase}}</span> | ||
<ng-container list> | ||
<it-dropdown-item *ngFor="let value of changerValues" href="#" externalLink="true" | ||
(click)="changerChange($event, value)"> | ||
{{value}} / {{'it.core.page' | translate | lowercase}} | ||
</it-dropdown-item> | ||
</ng-container> | ||
</it-dropdown> | ||
|
||
<it-input *ngIf="isShowJumpToPage" id="jump-to-page" type="number" [min]="1" [max]="pageNumbers" | ||
[label]="('it.core.go-to' | translate) + '...'" [formControl]="jumpToPage"></it-input> | ||
|
||
<p [class.d-none]="!totalNumberText.hasChildNodes()" #totalNumberText> | ||
<ng-content></ng-content> | ||
</p> | ||
</nav> |
3 changes: 0 additions & 3 deletions
3
projects/design-angular-kit/src/lib/components/core/pagination/pagination.component.scss
This file was deleted.
Oops, something went wrong.
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
11 changes: 11 additions & 0 deletions
11
src/app/pagination/pagination-changer-example/pagination-changer-example.component.html
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,11 @@ | ||
<h3>Changer</h3> | ||
<p>La funzionalità di changer permette di scegliere da un dropdown la quantità di record da visualizzare in una pagina.</p> | ||
|
||
<div class="bd-example"> | ||
<it-pagination [currentPage]="currentPage" [pageNumbers]="50" | ||
[currentChanger]="changerValue" | ||
[changerValues]="changerValues" | ||
(pageEvent)="pageChange($event)" | ||
(changerEvent)="changerEvent($event)"></it-pagination> | ||
|
||
</div> |
23 changes: 23 additions & 0 deletions
23
src/app/pagination/pagination-changer-example/pagination-changer-example.component.spec.ts
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,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PaginationChangerExampleComponent } from './pagination-changer-example.component'; | ||
|
||
describe('PaginationChangerExampleComponent', () => { | ||
let component: PaginationChangerExampleComponent; | ||
let fixture: ComponentFixture<PaginationChangerExampleComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ PaginationChangerExampleComponent ] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PaginationChangerExampleComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
src/app/pagination/pagination-changer-example/pagination-changer-example.component.ts
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,24 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'it-pagination-changer-example', | ||
templateUrl: './pagination-changer-example.component.html' | ||
}) | ||
export class PaginationChangerExampleComponent { | ||
currentPage: number = 25; | ||
|
||
changerValue: number = 10; | ||
|
||
/** | ||
* By default, the values are [10, 25, 50, 100] | ||
*/ | ||
changerValues: Array<number> = [10, 25, 50, 100, 250]; | ||
|
||
pageChange(page: number): void { | ||
this.currentPage = page; | ||
} | ||
|
||
changerEvent(value: number): void { | ||
this.changerValue = value; | ||
} | ||
} |
Oops, something went wrong.
95f9767
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.
Successfully deployed to the following URLs:
design-angular-kit – ./
design-angular-kit-dip-trasformazione-digitale.vercel.app
design-angular-kit.vercel.app
design-angular-kit-git-main-dip-trasformazione-digitale.vercel.app