Skip to content

Commit 6b31188

Browse files
authored
Merge pull request #344 from youda97/skeleton-pagination
feat(pagination): Add skeleton state
2 parents adba9b3 + b4b20de commit 6b31188

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

src/pagination/pagination.component.ts

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,19 @@ import { BehaviorSubject } from "rxjs";
3636
@Component({
3737
selector: "ibm-pagination",
3838
template: `
39-
<div class="bx--pagination">
40-
<div class="bx--pagination__left">
39+
<div
40+
class="bx--pagination"
41+
[ngClass]="{
42+
'bx--skeleton' : skeleton
43+
}">
44+
45+
<div *ngIf="skeleton" class="bx--pagination__left">
46+
<p class="bx--skeleton__text" style="width: 70px"></p>
47+
<p class="bx--skeleton__text" style="width: 35px"></p>
48+
<p class="bx--skeleton__text" style="width: 105px"></p>
49+
</div>
50+
51+
<div *ngIf="!skeleton" class="bx--pagination__left">
4152
<span class="bx--pagination__text">{{itemsPerPageText | async}}</span>
4253
<div class="bx--form-item">
4354
<div class="bx--select bx--select--inline">
@@ -76,7 +87,12 @@ import { BehaviorSubject } from "rxjs";
7687
{{totalItemsText | i18nReplace:{start: startItemIndex, end: endItemIndex, total: model.totalDataLength } | async}}
7788
</span>
7889
</div>
79-
<div class="bx--pagination__right bx--pagination--inline">
90+
91+
<div *ngIf="skeleton" class="bx--pagination__right bx--pagination--inline">
92+
<p class="bx--skeleton__text" style="width: 70px"></p>
93+
</div>
94+
95+
<div *ngIf="!skeleton" class="bx--pagination__right bx--pagination--inline">
8096
<span class="bx--pagination__text">{{totalPagesText | i18nReplace:{current: currentPage, last: lastPage} | async}}</span>
8197
<button
8298
class="bx--pagination__button bx--pagination__button--backward"
@@ -139,6 +155,10 @@ import { BehaviorSubject } from "rxjs";
139155
export class Pagination {
140156
static paginationCounter = 0;
141157

158+
/**
159+
* Set to `true` for a loading pagination component.
160+
*/
161+
@Input() skeleton = false;
142162
/**
143163
* `PaginationModel` with the information about pages you're controlling.
144164
*

src/pagination/pagination.stories.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ import { PaginationModel } from "./pagination-model.class";
1818
template: `
1919
<ibm-pagination
2020
[model]="model"
21+
[skeleton]="skeleton"
2122
(selectPage)="selectPage($event)">
2223
</ibm-pagination>
2324
`
2425
})
2526
class PaginationStory implements OnInit {
2627
@Input() model = new PaginationModel();
28+
@Input() skeleton = false;
2729

2830
@Input() get totalDataLength() {
2931
return this.model.totalDataLength;
@@ -63,5 +65,13 @@ storiesOf("Pagination", module).addDecorator(
6365
props: {
6466
totalDataLength: number("totalDataLength", 105)
6567
}
68+
}))
69+
.add("Skeleton", () => ({
70+
template: `
71+
<app-pagination [totalDataLength]="totalDataLength" [skeleton]="true"></app-pagination>
72+
`,
73+
props: {
74+
totalDataLength: number("totalDataLength", 105)
75+
}
6676
}));
6777

0 commit comments

Comments
 (0)