gatsby-core-theme 29.0.9 → 30.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/gatsby-config.js +0 -6
  3. package/package.json +1 -1
  4. package/src/components/atoms/author-box/index.js +11 -7
  5. package/src/components/atoms/module-title/index.js +1 -1
  6. package/src/components/atoms/open-graph/index.js +2 -2
  7. package/src/components/atoms/search/autocomplete/article.js +1 -1
  8. package/src/components/atoms/sitemap/index.js +5 -1
  9. package/src/components/molecules/bonus/template-one/index.js +1 -1
  10. package/src/components/molecules/bonus/template-two/index.js +2 -1
  11. package/src/components/molecules/bonus-box/template-three/index.js +16 -2
  12. package/src/components/molecules/bonus-box/template-two/index.js +7 -2
  13. package/src/components/molecules/pagination/index.js +218 -76
  14. package/src/components/molecules/pagination/pagination.module.scss +54 -10
  15. package/src/components/molecules/pagination/pagination.stories.js +118 -27
  16. package/src/components/molecules/pagination/pagination.test.js +155 -27
  17. package/src/components/molecules/pagination/with-midpoints.js +4 -4
  18. package/src/components/molecules/search/index.js +5 -1
  19. package/src/components/organisms/archive/archive.stories.js +1 -16
  20. package/src/components/organisms/archive/index.js +2 -9
  21. package/src/components/organisms/form/index.js +5 -1
  22. package/src/components/organisms/search/index.js +1 -1
  23. package/src/images/logo.svg +1 -1
  24. package/src/images/verify.svg +3 -0
  25. package/src/styles/utils/variables/_main.scss +19 -1
  26. package/static/images/bell.svg +3 -0
  27. package/static/images/logo.svg +1 -1
  28. package/static/images/notification-bubble.svg +1 -0
  29. package/src/components/molecules/pagination/pagination-with-midpoints.module.scss +0 -58
  30. package/src/components/molecules/pagination/with-midpoint.stories.js +0 -116
  31. package/src/components/molecules/pagination/with-midpoints.test.js +0 -59
package/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
1
+ # [30.0.0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v29.0.10...v30.0.0) (2023-09-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * add the possibility of changing the button through props ([de2c231](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/de2c231650bdfe9192b923ef3dec84f645e6a562))
7
+ * added svg title ([d99b168](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/d99b168c038e97fa9d825c2e3ac6cc027ee4ca7e))
8
+ * conflict ([3680b70](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/3680b70fc795ccbc085fa9e5cad3600c415fbc28))
9
+
10
+
11
+ ### Code Refactoring
12
+
13
+ * add defaults for pagination ([4810b6d](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/4810b6d7edf67150a0fe0241d54499f6043bbbbb))
14
+ * add optional border for current page ([966c857](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/966c85740896594cac81945376a01ae99d85d145))
15
+ * added font sizes ([ba60e5b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ba60e5b6e8753239b99fd1d76a9d45f70693994a))
16
+ * change to default ([f106115](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f106115db9e31962eda650bb6c1027c50c9340a8))
17
+ * changes to pagination ([110e114](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/110e1149faf69266afda1d06dc4b65a24ee1904e))
18
+ * correction to font weight ([39dcf25](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/39dcf259ea34b4f7498ef5d932040ca52c6faff1))
19
+ * minor change to pagination logic ([7cbcead](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/7cbceadea332bdbacbfcd6bfc8c9415096845b4e))
20
+ * minor changes ([2cf4ccf](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/2cf4ccfbf611b750a6e6a17bc8c63d0423b9af02))
21
+ * new paginationation ([468812b](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/468812b080c067c15fe054016c3c3034c4d6e584))
22
+ * pagination changes ([0240cc1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0240cc174d2a8987bef13201541b3aacf128c961))
23
+ * remove old pagination ([90f33da](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/90f33da6afcb4d54047c81e3dec951e0321ac1c5))
24
+ * revert temp ([550fb30](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/550fb3031203ddc95fc23d419d3dc9a8dd3251ad))
25
+ * temp ([ccc3a91](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/ccc3a9140a9a0e59103e76897599dfa3892f3cc7))
26
+
27
+
28
+ * Merge branch 'tm-3676-svg-title' into 'master' ([0ec9bf1](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/0ec9bf16dc6592e8a1a8f2a62865f30ee0665afe))
29
+ * Merge branch 'tm-3388-pagination' into 'master' ([e251ec0](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/e251ec010f3a1cd1d6d3ec821cf9292350d723c5))
30
+ * Merge branch 'tm-3630-headers' into 'master' ([220e2dd](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/220e2ddf5ed8bd6ea4150e63bb03472bad8b84c5))
31
+ * Merge branch 'master' into tm-3388-pagination ([017e1d3](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/017e1d38e6c96326832193bb43467b5453185924))
32
+ * Merge branch 'master' into tm-3388-pagination ([9d15721](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/9d15721c2ebced769fc9a162a0ec87afc83633de))
33
+ * Merge branch 'master' into tm-3388-pagination ([fb31785](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/fb31785bd78384cf7985298d97996bb369d98c19))
34
+
35
+ ## [29.0.10](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v29.0.9...v29.0.10) (2023-09-21)
36
+
37
+
38
+ ### Bug Fixes
39
+
40
+ * removed minify class names in core theme ([f721d7a](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/commit/f721d7a43147a056d968ec49df9a6f253938f179))
41
+
1
42
  ## [29.0.9](https://git.ilcd.rocks/team-floyd/themes/gatsby-themes/compare/v29.0.8...v29.0.9) (2023-09-20)
2
43
 
3
44
 
package/gatsby-config.js CHANGED
@@ -44,11 +44,5 @@ module.exports = {
44
44
  },
45
45
  },
46
46
  `gatsby-plugin-image`,
47
- {
48
- resolve: 'gatsby-plugin-minify-classnames',
49
- options: {
50
- /* gatsby-plugin-minify-classnames options here */
51
- },
52
- },
53
47
  ],
54
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gatsby-core-theme",
3
- "version": "29.0.9",
3
+ "version": "30.0.0",
4
4
  "description": "Gatsby Theme NPM Package",
5
5
  "author": "",
6
6
  "license": "ISC",
@@ -30,16 +30,20 @@ export default function AuthorBox({
30
30
  verifiedIconWidth = 20,
31
31
  verifiedIconHeight = 20,
32
32
  showReadMore = true,
33
- readTimeIcon = <FaClock />,
34
- contReadIcon = <FaArrowRight />,
33
+ readTimeIcon = <FaClock title="Clock Icon" />,
34
+ contReadIcon = <FaArrowRight title="Right-pointing Arrow Icon" />,
35
35
  }) {
36
36
  const { translations } = useContext(Context) || {};
37
37
  const socialLinks = [
38
- { id: 'fb', link: author?.facebook_profile, icon: <FaFacebookSquare /> },
39
- { id: 'ig', link: author?.instagram_profile, icon: <FaInstagram /> },
40
- { id: 'li', link: author?.linkedin_profile, icon: <FaLinkedin /> },
41
- { id: 'tw', link: author?.twitter_profile, icon: <FaTwitter /> },
42
- { id: 'tt', link: author?.tik_tok, icon: <IoLogoTiktok /> },
38
+ {
39
+ id: 'fb',
40
+ link: author?.facebook_profile,
41
+ icon: <FaFacebookSquare title="Facebook Icon" />,
42
+ },
43
+ { id: 'ig', link: author?.instagram_profile, icon: <FaInstagram title="Instagra Icon" /> },
44
+ { id: 'li', link: author?.linkedin_profile, icon: <FaLinkedin title="Linkedin Icon" /> },
45
+ { id: 'tw', link: author?.twitter_profile, icon: <FaTwitter title="Twitter Icon" /> },
46
+ { id: 'tt', link: author?.tik_tok, icon: <IoLogoTiktok title="Tiktok Icon" /> },
43
47
  ];
44
48
  const biographyRef = useRef(null);
45
49
  const [isReadMore, setIsReadMore] = useState(showReadMore);
@@ -7,7 +7,7 @@ import styles from './module-title.module.scss';
7
7
 
8
8
  const ModuleTitle = ({
9
9
  module,
10
- viewMoreIcon = <FaAngleRight />,
10
+ viewMoreIcon = <FaAngleRight title="Right-pointing Arrow Icon" />,
11
11
  pageContext = null,
12
12
  anchorLabel = null,
13
13
  }) => {
@@ -34,7 +34,7 @@ const OpenGraph = ({ page, text = 'Share: ' }) => {
34
34
  onClick={(e) => share(e, 555, 602)}
35
35
  aria-label="Facebook Link"
36
36
  >
37
- <FaFacebookF />
37
+ <FaFacebookF title="Facebook Icon" />
38
38
  </a>
39
39
  <a
40
40
  target="_blank"
@@ -45,7 +45,7 @@ const OpenGraph = ({ page, text = 'Share: ' }) => {
45
45
  onClick={(e) => share(e, 555, 255)}
46
46
  aria-label="Twitter Link"
47
47
  >
48
- <FaTwitter />
48
+ <FaTwitter title="Twitter Icon" />
49
49
  </a>
50
50
  </div>
51
51
  );
@@ -7,7 +7,7 @@ import styles from './article.module.scss';
7
7
  const Article = ({ item = {} }) => (
8
8
  <div className={styles.row || ''}>
9
9
  <h3>{item.title}</h3>
10
- <IoMdArrowRoundForward />
10
+ <IoMdArrowRoundForward title="Right-pointing Arrow Icon" />
11
11
  </div>
12
12
  );
13
13
 
@@ -11,7 +11,11 @@ import { translate } from '~helpers/getters';
11
11
  import styles from './sitemap.module.scss';
12
12
  import Link from '~hooks/link';
13
13
 
14
- const Sitemap = ({ pageContext, templateIcon = <BiSitemap />, linkIcon = <IoMdLink /> }) => {
14
+ const Sitemap = ({
15
+ pageContext,
16
+ templateIcon = <BiSitemap title="Sitemap Icon" />,
17
+ linkIcon = <IoMdLink title="Link Icon" />,
18
+ }) => {
15
19
  const { templates, sitemapData } = pageContext;
16
20
  const { translations } = useContext(Context) || {};
17
21
 
@@ -66,7 +66,7 @@ export default function Bonus({
66
66
  operator={operator}
67
67
  pageTemplate={pageTemplate}
68
68
  tracker={module?.tracking_link_name || 'main'}
69
- icon={<FaArrowRight fontSize={20} />}
69
+ icon={<FaArrowRight fontSize={20} title="Right-pointing Arrow Icon" />}
70
70
  />
71
71
  {showTncFixed && <Tnc hasCollapse={false} operator={operator} />}
72
72
  </div>
@@ -106,7 +106,7 @@ export default function TemplateOne({
106
106
  operator={operator}
107
107
  pageTemplate={pageTemplate}
108
108
  tracker={module?.tracking_link_name || 'main'}
109
- icon={<FaArrowRight fontSize={20} />}
109
+ icon={<FaArrowRight fontSize={20} title="Right-pointing Arrow Icon" />}
110
110
  translationsObj={translationsObj}
111
111
  />
112
112
  {showTncFixed && <Tnc hasCollapse={false} operator={operator} />}
@@ -116,6 +116,7 @@ export default function TemplateOne({
116
116
  onClick={clickHandler}
117
117
  fontSize={16}
118
118
  color="#ffffff"
119
+ title="Close Icon"
119
120
  />
120
121
  </div>
121
122
  )
@@ -16,6 +16,7 @@ export default function BonusBox({
16
16
  showVariablesComponent = true,
17
17
  splitBy = '+',
18
18
  feSeparator = '+',
19
+ buttonType = 'primary',
19
20
  }) {
20
21
  const { translations } = useContext(Context) || {};
21
22
  const welcomeBonusTranslation = translate(translations, 'welcome_bonus', 'Welcome Bonus');
@@ -46,12 +47,24 @@ export default function BonusBox({
46
47
  {!showVariablesComponent ? (
47
48
  <>
48
49
  {content()}
49
- {ctaBtn && <CtaButton operator={item} icon={<FaArrowRight />} />}
50
+ {ctaBtn && (
51
+ <CtaButton
52
+ operator={item}
53
+ icon={<FaArrowRight title="Right-pointing Arrow Icon" />}
54
+ buttonType={buttonType}
55
+ />
56
+ )}
50
57
  </>
51
58
  ) : (
52
59
  <div>
53
60
  {content()}
54
- {ctaBtn && <CtaButton operator={item} icon={<FaArrowRight />} />}
61
+ {ctaBtn && (
62
+ <CtaButton
63
+ operator={item}
64
+ icon={<FaArrowRight title="Right-pointing Arrow Icon" />}
65
+ buttonType={buttonType}
66
+ />
67
+ )}
55
68
  </div>
56
69
  )}
57
70
 
@@ -69,4 +82,5 @@ BonusBox.propTypes = {
69
82
  showVariablesComponent: PropTypes.bool,
70
83
  splitBy: PropTypes.string,
71
84
  feSeparator: PropTypes.string,
85
+ buttonType: PropTypes.string,
72
86
  };
@@ -11,6 +11,7 @@ export default function BonusBox({
11
11
  pageTemplate = null,
12
12
  splitBy = '+',
13
13
  feSeparator = '+',
14
+ buttonType = 'primary',
14
15
  }) {
15
16
  const prettyLink = prettyTracker(item, tracker, false, pageTemplate);
16
17
  const data = getBonusData(item, tracker, splitBy);
@@ -28,8 +29,11 @@ export default function BonusBox({
28
29
  <span className={styles.secondPart}>{`${feSeparator}${data.secondLine}`}</span>
29
30
  )}
30
31
  </a>
31
-
32
- <CtaButton operator={item} icon={<FaArrowRight />} />
32
+ <CtaButton
33
+ operator={item}
34
+ icon={<FaArrowRight title="Right-pointing Arrow Icon" />}
35
+ buttonType={buttonType}
36
+ />
33
37
  </div>
34
38
  );
35
39
  }
@@ -40,4 +44,5 @@ BonusBox.propTypes = {
40
44
  pageTemplate: PropTypes.string,
41
45
  splitBy: PropTypes.string,
42
46
  feSeparator: PropTypes.string,
47
+ buttonType: PropTypes.string,
43
48
  };
@@ -1,23 +1,35 @@
1
1
  import React, { useEffect, useContext } from 'react';
2
- import PropTypes from 'prop-types';
2
+ import PropTypes, { number } from 'prop-types';
3
+ import { MdLastPage } from '@react-icons/all-files/md/MdLastPage';
4
+ import { MdFirstPage } from '@react-icons/all-files/md/MdFirstPage';
5
+ import { MdChevronRight } from '@react-icons/all-files/md/MdChevronRight';
6
+ import { MdChevronLeft } from '@react-icons/all-files/md/MdChevronLeft';
7
+
8
+ import keygen from '~helpers/keygen';
3
9
  import { translate } from '~helpers/getters';
4
10
  import Link from '~hooks/link';
5
- import styles from './pagination.module.scss';
6
- import keygen from '~helpers/keygen';
7
11
  import { Context } from '~context/MainProvider';
12
+ import styles from './pagination.module.scss';
8
13
 
9
14
  const Pagination = ({
10
15
  currentPage = 1,
11
16
  pagePath = '#',
12
17
  totalPages = 5,
13
- pageList = undefined,
14
- previousText = 'Previous',
15
- nextText = 'Next',
16
- numOfItems = 5,
18
+ previousComp = <MdChevronLeft />,
19
+ nextComp = <MdChevronRight />,
20
+ firstComp = <MdFirstPage />,
21
+ lastComp = <MdLastPage />,
17
22
  anchorLabel,
23
+ pageNeighbours = 1,
24
+ showFirstLast = false,
25
+ showPrevNext = true,
26
+ showOf = false,
27
+ hidePrevious = false,
28
+ hideNext = false,
18
29
  }) => {
19
- const numOfItemsEachSide = Math.ceil(numOfItems / 2);
20
30
  const { translations } = useContext(Context) || {};
31
+ const current = Number(currentPage);
32
+ const total = Number(totalPages);
21
33
  function getPagePath(index) {
22
34
  return (
23
35
  (index === 1
@@ -27,80 +39,204 @@ const Pagination = ({
27
39
  );
28
40
  }
29
41
 
30
- function generatePaginationList() {
31
- const pages = [];
32
- // Generate list of page numbers before and after
33
- for (
34
- let i = currentPage - (numOfItemsEachSide - 2);
35
- i < currentPage + (numOfItemsEachSide - 1);
36
- i += 1
37
- )
38
- if (i > 0) {
39
- if (i <= totalPages) {
40
- pages.push(
41
- <li key={keygen()}>
42
- <Link
43
- className={`${i === currentPage ? styles.active : ''} pagination-gtm`}
44
- to={getPagePath(i)}
45
- >
46
- {i}
47
- </Link>
48
- </li>
49
- );
50
- }
51
- }
52
- return pages;
53
- }
42
+ const midPoints = 'MID';
54
43
 
55
44
  useEffect(() => {
56
45
  const hash = window?.location?.hash?.replace('#', '');
57
46
  document?.getElementById(hash)?.scrollIntoView();
58
47
  });
59
48
 
49
+ const range = (from, to, step = 1) => {
50
+ let i = from;
51
+ const rangeArr = [];
52
+
53
+ while (i <= to) {
54
+ rangeArr.push(i);
55
+ i += step;
56
+ }
57
+
58
+ return rangeArr;
59
+ };
60
+
61
+ const fetchPageNumbers = () => {
62
+ const totalNumbers = pageNeighbours * 2 + 2;
63
+ const totalBlocks = totalNumbers + 2;
64
+
65
+ if (total > totalBlocks - 1) {
66
+ let pages = [];
67
+
68
+ const leftBound = current - pageNeighbours;
69
+ const rightBound = current + pageNeighbours;
70
+ const beforeLastPage = total - 1;
71
+
72
+ const startPage = leftBound > 2 ? leftBound : 2;
73
+ const endPage = rightBound < beforeLastPage ? rightBound : beforeLastPage;
74
+
75
+ pages = range(startPage, endPage);
76
+
77
+ const pagesCount = pages.length;
78
+ const singleSpillOffset = totalNumbers - pagesCount - 1;
79
+
80
+ const leftSpill = startPage > 2;
81
+ const rightSpill = endPage < beforeLastPage;
82
+
83
+ if (leftSpill && !rightSpill) {
84
+ const extraPages = range(startPage - singleSpillOffset, startPage - 1);
85
+ pages = [midPoints, ...extraPages, ...pages];
86
+ } else if (!leftSpill && rightSpill) {
87
+ const extraPages = range(endPage + 1, endPage + singleSpillOffset);
88
+ pages = [...pages, ...extraPages, midPoints];
89
+ } else if (leftSpill && rightSpill) {
90
+ pages = [midPoints, ...pages, midPoints];
91
+ }
92
+
93
+ return [1, ...pages, total];
94
+ }
95
+
96
+ return range(1, total);
97
+ };
98
+
60
99
  return (
61
100
  <ul className={styles.pagination || ''}>
62
- {/* previous button */}
63
- {currentPage !== 1 && (
64
- <li>
65
- <Link
66
- to={getPagePath(currentPage - 1)}
67
- className="pagination-gtm"
68
- aria-label={translate(translations, 'archive_previous_button', previousText)}
69
- >
70
- {translate(translations, 'archive_previous_button', previousText)}
71
- </Link>
101
+ {/* got to first page */}
102
+ {showFirstLast && (
103
+ <li className={styles.goToFirst || ''}>
104
+ {current > 1 ? (
105
+ <Link
106
+ to={getPagePath(1)}
107
+ className={`${styles.button || ''} ${styles.isActive || ''} pagination-gtm`}
108
+ aria-label={translate(translations, 'archive_go_to_first_page', 'Go to first page')}
109
+ >
110
+ {firstComp}
111
+ </Link>
112
+ ) : (
113
+ <span className={styles.button || ''}>{firstComp}</span>
114
+ )}
72
115
  </li>
73
116
  )}
74
- {/* first page link */}
75
- {currentPage >= numOfItemsEachSide && (
76
- <li>
77
- <Link to={getPagePath(1)} className="pagination-gtm">
78
- 1
79
- </Link>
80
- {currentPage !== numOfItemsEachSide && <span>...</span>}
117
+ {/* go to previous page */}
118
+ {showPrevNext && (
119
+ <li className={styles.goToPrevious || ''}>
120
+ {current > 1 ? (
121
+ <Link
122
+ to={getPagePath(current - 1)}
123
+ className={`${styles.button || ''} ${styles.isActive || ''} pagination-gtm`}
124
+ aria-label={translate(translations, 'archive_previous_button', 'Previous Button')}
125
+ >
126
+ {previousComp}
127
+ </Link>
128
+ ) : (
129
+ <span className={styles.button || ''}>{previousComp}</span>
130
+ )}
81
131
  </li>
82
132
  )}
83
- {/* pages links */}
84
- {pageList === undefined ? generatePaginationList() : pageList}
85
- {/* last page link */}
86
- {totalPages - currentPage >= numOfItemsEachSide - 1 && (
87
- <li>
88
- {totalPages - currentPage !== numOfItemsEachSide - 1 && <span>...</span>}
89
- <Link to={getPagePath(totalPages)} className="pagination-gtm">
90
- {totalPages}
91
- </Link>
133
+
134
+ {/* start pages */}
135
+ <li>
136
+ <ul className={styles.pages || ''}>
137
+ {/* show [current page] of [total pages] */}
138
+ {showOf ? (
139
+ <>
140
+ <li className={styles.showOfCurrent || ''}>
141
+ <span>{current}</span>
142
+ of
143
+ <span>{total}</span>
144
+ </li>
145
+ </>
146
+ ) : (
147
+ fetchPageNumbers().map((page) => {
148
+ /* show mid points */
149
+ if (page === midPoints) {
150
+ return (
151
+ <li key={keygen()} className={`${styles.page || ''} ${styles.midPoints || ''}`}>
152
+ <span>...</span>
153
+ </li>
154
+ );
155
+ }
156
+
157
+ /* previous page */
158
+ if (page === current - 1) {
159
+ return (
160
+ !hidePrevious && (
161
+ <li key={keygen()} className={`${styles.previousPage || ''} `}>
162
+ {current === page ? (
163
+ <span>{page}</span>
164
+ ) : (
165
+ <Link to={getPagePath(page)} className="pagination-gtm">
166
+ {page}
167
+ </Link>
168
+ )}
169
+ </li>
170
+ )
171
+ );
172
+ }
173
+
174
+ /* next page */
175
+ if (page === current + 1) {
176
+ return (
177
+ !hideNext && (
178
+ <li key={keygen()} className={`${styles.nextPage || ''} `}>
179
+ {current === page ? (
180
+ <span>{page}</span>
181
+ ) : (
182
+ <Link to={getPagePath(page)} className="pagination-gtm">
183
+ {page}
184
+ </Link>
185
+ )}
186
+ </li>
187
+ )
188
+ );
189
+ }
190
+
191
+ /* first and last pages, current page & extra pages */
192
+ return (
193
+ <li
194
+ key={keygen()}
195
+ className={`${styles.page || ''} ${current === page ? styles.active || '' : ''} ${
196
+ page === 1 ? styles.firstPage || '' : ''
197
+ } ${page === total ? styles.lastPage || '' : ''} `}
198
+ >
199
+ <Link to={getPagePath(page)} className="pagination-gtm">
200
+ {page}
201
+ </Link>
202
+ </li>
203
+ );
204
+ })
205
+ )}
206
+ </ul>
207
+ </li>
208
+ {/* end pages */}
209
+
210
+ {/* next button */}
211
+ {showPrevNext && (
212
+ <li className={styles.goToNext || ''}>
213
+ {current < total ? (
214
+ <Link
215
+ to={getPagePath(current + 1)}
216
+ className={`${styles.button || ''} ${styles.isActive || ''} pagination-gtm`}
217
+ aria-label={translate(translations, 'archive_next_button', 'Next Button')}
218
+ >
219
+ {nextComp}
220
+ </Link>
221
+ ) : (
222
+ <span className={styles.button || ''}>{nextComp}</span>
223
+ )}
92
224
  </li>
93
225
  )}
94
- {/* next button */}
95
- {currentPage < totalPages && (
96
- <li>
97
- <Link
98
- to={getPagePath(currentPage + 1)}
99
- className="pagination-gtm"
100
- aria-label={translate(translations, 'archive_next_button', nextText)}
101
- >
102
- {translate(translations, 'archive_next_button', nextText)}
103
- </Link>
226
+ {/* got to last page */}
227
+ {showFirstLast && (
228
+ <li className={styles.goToLast || ''}>
229
+ {current !== total ? (
230
+ <Link
231
+ to={getPagePath(total)}
232
+ className={`${styles.button || ''} ${styles.isActive || ''} pagination-gtm`}
233
+ aria-label={translate(translations, 'archive_go_to_last_page', 'Go to Last')}
234
+ >
235
+ {lastComp}
236
+ </Link>
237
+ ) : (
238
+ <span className={styles.button || ''}>{lastComp}</span>
239
+ )}
104
240
  </li>
105
241
  )}
106
242
  </ul>
@@ -108,14 +244,20 @@ const Pagination = ({
108
244
  };
109
245
 
110
246
  Pagination.propTypes = {
111
- currentPage: PropTypes.number,
112
- pagePath: PropTypes.string,
113
- totalPages: PropTypes.number,
114
- // eslint-disable-next-line react/forbid-prop-types
115
- pageList: PropTypes.arrayOf(PropTypes.any),
116
- nextText: PropTypes.string,
117
- previousText: PropTypes.string,
118
- numOfItems: PropTypes.number,
247
+ currentPage: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
248
+ pagePath: PropTypes.string.isRequired,
249
+ totalPages: PropTypes.oneOfType([PropTypes.number, PropTypes.string]).isRequired,
250
+ nextComp: PropTypes.oneOfType([PropTypes.element, PropTypes.any]),
251
+ previousComp: PropTypes.oneOfType([PropTypes.element, PropTypes.any]),
252
+ firstComp: PropTypes.oneOfType([PropTypes.element, PropTypes.any]),
253
+ lastComp: PropTypes.oneOfType([PropTypes.element, PropTypes.any]),
254
+ anchorLabel: PropTypes.string,
255
+ pageNeighbours: PropTypes.number,
256
+ showFirstLast: PropTypes.bool,
257
+ showPrevNext: PropTypes.bool,
258
+ showOf: PropTypes.bool,
259
+ hidePrevious: PropTypes.bool,
260
+ hideNext: PropTypes.bool,
119
261
  };
120
262
 
121
263
  export default Pagination;
@@ -1,19 +1,63 @@
1
+ .padd {
2
+ @include flex-align(center, center);
3
+ border-radius: var(--pagination-border-radius, 100px);
4
+ border: var(--pagination-border, none);
5
+ font-size: calc(var(--pagination-font-size, 1.6rem) - 2px);
6
+ line-height: calc(var(--pagination-line-height, 4.8rem) - 2px);
7
+ font-weight: var(--pagination-font-weight, 500);
8
+ width: calc(var(--pagination-width, 4rem) - 1rem);
9
+ height: calc(var(--pagination-height, 4rem) - 1rem);
10
+ background-color: var(--pagination-background-color, #eeebe5);
11
+
12
+ @include min(mobile-m) {
13
+ width: var(--pagination-width, 4rem);
14
+ height: var(--pagination-height, 4rem);
15
+ font-size: var(--pagination-font-size, 1.6rem);
16
+ line-height: var(--pagination-line-height, 4.8rem);
17
+ }
18
+ }
19
+
1
20
  .pagination {
21
+ padding: 1.6rem 0 !important;
2
22
  @include flex-align(center, center);
23
+ gap: var(--pagination-gap, 0.8rem);
24
+
25
+ ul {
26
+ @include flex-align(center, center);
27
+ gap: var(--pagination-midpoints-gap, 0);
28
+ background-color: var(--pagination-midpoints-background-color, #eeebe5);
29
+ border-radius: var(--pagination-midpoints-border-radius, 100px);
30
+
31
+ > li {
32
+ @include flex-align(center, center)
33
+ }
34
+ }
3
35
 
4
36
  a,
5
37
  span {
6
- color: var(--color-10);
7
- display: inline-block;
8
- font-size: 1.8rem;
9
- line-height: 4.8rem;
10
- height: 4.8rem;
11
- }
12
- a {
13
- padding: 0 0.4rem;
38
+ color: var(--pagination-active-color, #2e3337);
39
+ @extend .padd;
14
40
  }
15
41
 
16
- .active {
17
- color: var(--secondary-color);
42
+ .button {
43
+ cursor: not-allowed;
44
+ color: var(--pagination-inactive-color, #ffffff);
45
+ @extend .padd;
46
+
47
+ &.isActive {
48
+ color: var(--pagination-active-color, #2e3337);
49
+ cursor: pointer;
50
+ }
18
51
  }
19
52
  }
53
+
54
+ .active a {
55
+ color: var(--pagination-current-page-color, #ffffff);
56
+ background-color: var(--pagination-current-page-background-color, #2e3337);
57
+ border: var(--pagination-current-page-border, var(--pagination-border, none));
58
+ font-weight: var(--pagination-active-font-weight, 700);
59
+ }
60
+
61
+ .showOfCurrent {
62
+ gap: var(--pagination-gap, 0.8rem);
63
+ }