@@ -6,27 +6,56 @@ class PaginationView extends View {
66 _parentElement = document . querySelector ( '.pagination' ) ;
77
88 _generateMarkup ( ) {
9+ const curPage = this . _data . page ;
910 // calculate how many pages we need
1011 const numPages = Math . ceil (
1112 this . _data . results . length / this . _data . resultsPerPage
1213 ) ;
1314 console . log ( numPages ) ;
1415
1516 // Page 1 and there are other pages
16- if ( this . _data . page === 1 && numPages > 1 ) {
17- return 'page 1' ;
17+ if ( curPage === 1 && numPages > 1 ) {
18+ return `
19+ <button class="btn--inline pagination__btn--next">
20+ <span>Page ${ curPage + 1 } </span>
21+ <svg class="search__icon">
22+ <use href="${ icons } #icon-arrow-right"></use>
23+ </svg>
24+ </button>
25+ ` ;
1826 }
27+
1928 // Last page
20- if ( this . _data . page === numPages && numPages > 1 ) {
21- return 'Last Page' ;
29+ if ( curPage === numPages && numPages > 1 ) {
30+ return `
31+ <button class="btn--inline pagination__btn--prev">
32+ <svg class="search__icon">
33+ <use href="${ icons } #icon-arrow-left"></use>
34+ </svg>
35+ <span>Page ${ curPage - 1 } </span>
36+ </button>
37+ ` ;
2238 }
2339 // Other page
24- if ( this . _data . page < numPages ) {
25- return 'other page' ;
40+ if ( curPage < numPages ) {
41+ return `
42+ <button class="btn--inline pagination__btn--prev">
43+ <svg class="search__icon">
44+ <use href="${ icons } #icon-arrow-left"></use>
45+ </svg>
46+ <span>Page ${ curPage - 1 } </span>
47+ </button>
48+ <button class="btn--inline pagination__btn--next">
49+ <span>Page ${ curPage + 1 } </span>
50+ <svg class="search__icon">
51+ <use href="${ icons } #icon-arrow-right"></use>
52+ </svg>
53+ </button>
54+ ` ;
2655 }
2756
2857 // page 1, and there are NO other pages
29- return 'only 1 page ' ;
58+ return '' ;
3059 }
3160}
3261
0 commit comments