Skip to content

Commit b4454d1

Browse files
[UXP-34] rework carousel pagination
1 parent 8663c1f commit b4454d1

3 files changed

Lines changed: 155 additions & 90 deletions

File tree

Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<ngb-carousel #carousel [interval]="2000" (slide)="onSlide($event)" class="ds-carousel">
2-
<ng-template ngbSlide *ngFor="let item of currentPageItems(); let i = index; let last = last">
1+
<ngb-carousel #carousel [interval]="2000" (slide)="onSlide($event)" class="ds-carousel" *ngIf="!(isLoading$ | async)">
2+
<ng-template ngbSlide *ngFor="let item of (currentPageItems$ | async); let i = index; let last = last">
33
<ng-container *ngIf="getItemLink(item.indexableObject); let currentLink; else carouselContent">
44
<a *ngIf="internalLinkService.isLinkInternal(currentLink)" [routerLink]="internalLinkService.getRelativePath(currentLink)">
55
<ng-container *ngTemplateOutlet="carouselContent"></ng-container>
@@ -33,28 +33,6 @@
3333
</ng-template>
3434
</ng-template>
3535
</ngb-carousel>
36-
<div class="text-center play-pause-button">
37-
<button type="button" class="btn btn-sm toggle-paused" (click)="togglePaused()">
38-
<i class="fas fa-play" *ngIf="paused"></i>
39-
<i class="fas fa-pause" *ngIf="!paused"></i>
40-
</button>
41-
</div>
42-
<div class="mt-4 w-100 d-flex justify-content-center align-items-center" *ngIf="totalPages > 1">
43-
<button (click)="previousPage()" [disabled]="currentPage === 1" class="prev border-0 bg-transparent">
44-
<i class="fa fa-arrow-left"></i>
45-
</button>
46-
<button
47-
*ngFor="let page of pages()"
48-
class="number"
49-
(click)="changePage(page)"
50-
style="border: none; background: none; margin: 0 5px"
51-
[style.color]="page === currentPage ? '#000000' : '#7c7c7c'">
52-
{{ page < 10 ? '0' + page : page }}
53-
</button>
54-
<button (click)="nextPage()" [disabled]="currentPage === pages().length" class="next border-0 bg-transparent">
55-
<i class="fa fa-arrow-right"></i>
56-
</button>
57-
</div>
5836

5937
<div
6038
class="carousel-content-wrapper"
@@ -64,13 +42,52 @@
6442
}"
6543
*ngIf="(isLoading$ | async)"
6644
>
67-
<a
68-
href="#"
69-
target="_blank"
70-
class="img-container-el">
45+
<div class="h-100 img-container-el">
7146
<div class="picsum-img-wrapper flex-column">
7247
<img class="img-fluid" src="assets/images/replacement_image.svg">
7348
{{'loading.default' | translate}}
7449
</div>
75-
</a>
50+
</div>
51+
</div>
52+
53+
<div class="text-center play-pause-button">
54+
<button [disabled]="isLoading$ | async" type="button" class="btn btn-sm toggle-paused" (click)="togglePaused()">
55+
<i class="fas fa-play" *ngIf="paused"></i>
56+
<i class="fas fa-pause" *ngIf="!paused"></i>
57+
</button>
7658
</div>
59+
<div class="mt-4 w-100 d-flex justify-content-center align-items-center" *ngIf="totalPages > 1">
60+
<div
61+
class="page-item"
62+
[class.disabled]="currentPage === 1 || (isLoading$ | async)"
63+
>
64+
<button (click)="previousPage()" [disabled]="currentPage === 1 || (isLoading$ | async)" class="page-link prev">
65+
«
66+
</button>
67+
</div>
68+
69+
<div
70+
*ngFor="let page of (currentlyVisiblePages$ | async)"
71+
class="page-item"
72+
[class.active]="page === currentPage"
73+
>
74+
<button
75+
class="page-link"
76+
(click)="changePage(page)"
77+
[disabled]="isLoading$ | async"
78+
>
79+
{{ page < 10 ? '0' + page : page }}
80+
</button>
81+
</div>
82+
83+
<div
84+
class="page-item"
85+
[class.disabled]="currentPage === totalPages || (isLoading$ | async)"
86+
>
87+
<button (click)="nextPage()" [disabled]="currentPage === totalPages || (isLoading$ | async)" class="page-link next">
88+
»
89+
</button>
90+
</div>
91+
</div>
92+
93+

src/app/shared/carousel/carousel.component.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,14 @@
9191
box-shadow: none !important
9292
}
9393

94+
.next {
95+
border-top-right-radius: 0.25rem;
96+
border-bottom-right-radius: 0.25rem;
97+
}
98+
99+
.prev {
100+
border-top-left-radius: 0.25rem;
101+
border-bottom-left-radius: 0.25rem;
102+
}
103+
94104
}

0 commit comments

Comments
 (0)