diff --git a/src/components/CheckoutCard/checkoutCard.scss b/src/components/CheckoutCard/checkoutCard.scss index 102f464ae5..8da945f24d 100644 --- a/src/components/CheckoutCard/checkoutCard.scss +++ b/src/components/CheckoutCard/checkoutCard.scss @@ -54,7 +54,12 @@ } &__button { - @include button-arrows; + @include button-more-less; + + &_prev { + content: "+"; + + } } &__count { diff --git a/src/components/Footer/footer.scss b/src/components/Footer/footer.scss index 04b4e8a641..df66e95888 100644 --- a/src/components/Footer/footer.scss +++ b/src/components/Footer/footer.scss @@ -16,7 +16,7 @@ } &__logo { - background: center/contain no-repeat url("https://i.gstatvb.com/c389a77ca305ee5d9f0ee6f87f74fcfb1688922827.rng.png"); + background: center/contain no-repeat url($logo); height: 24px; width: 40px; margin: 0 64px 0 8px; diff --git a/src/components/Header/header.scss b/src/components/Header/header.scss index 7fee5df7f9..121510d525 100644 --- a/src/components/Header/header.scss +++ b/src/components/Header/header.scss @@ -17,7 +17,7 @@ } &__logo { - background: center/contain no-repeat url("https://i.gstatvb.com/c389a77ca305ee5d9f0ee6f87f74fcfb1688922827.rng.png"); + background: center/contain no-repeat url($logo); height: 24px; width: 40px; margin: 0 64px 0 26px; diff --git a/src/components/Pagination/Pagination.tsx b/src/components/Pagination/Pagination.tsx index 5360945639..ba7d1ef585 100644 --- a/src/components/Pagination/Pagination.tsx +++ b/src/components/Pagination/Pagination.tsx @@ -1,4 +1,4 @@ -import React, { useEffect } from 'react'; +import React, { useEffect, useState } from 'react'; import { Link, useSearchParams } from 'react-router-dom'; import classNames from 'classnames'; import { getSearchWith } from '../../helpers/searchHelper'; @@ -10,6 +10,8 @@ export type Props = { currentPage: number, }; +const DEFAULT_VISIBLE_PAGES = 4; + export const Pagination: React.FC = ({ total, itemsOnPage, @@ -17,8 +19,28 @@ export const Pagination: React.FC = ({ }) => { const [searchParams, setSearchParams] = useSearchParams(''); const lastPage = Math.ceil(total / itemsOnPage); - const numberOfPages = new Array(lastPage) - .fill(1).map((_, index) => (index + 1)); + const [visiblePages, setVisiblePages] = useState([]); + + useEffect(() => { + const adjacentPages = Math.round(DEFAULT_VISIBLE_PAGES / 2); + let startPage = Math.max(1, currentPage - adjacentPages); + let endPage = Math.min(lastPage, currentPage + adjacentPages); + + while (endPage - startPage < DEFAULT_VISIBLE_PAGES) { + if (startPage > 1) { + startPage -= 1; + } else if (endPage < lastPage) { + endPage += 1; + } else { + break; + } + } + + const numberOfPages = [...Array(endPage - startPage + 1)] + .map((_, index) => startPage + index); + + setVisiblePages(numberOfPages); + }, [currentPage, lastPage]); useEffect(() => { if (currentPage > lastPage) { @@ -46,7 +68,7 @@ export const Pagination: React.FC = ({ />
    - {numberOfPages.map(pageNumber => ( + {visiblePages.map(pageNumber => (
  • = ({ /> )} + {isPaginationBarShown && ( +
    + +
    + )} )} diff --git a/src/components/ProductList/productList.scss b/src/components/ProductList/productList.scss index a726135743..8f989f2611 100644 --- a/src/components/ProductList/productList.scss +++ b/src/components/ProductList/productList.scss @@ -28,6 +28,10 @@ &__pagination { margin-top: 24px; + + &_top { + display: none; + } } } @@ -39,6 +43,10 @@ flex-direction: column; } + &__container { + flex-direction: column; + } + &__dropdowns { flex-direction: column; margin: 0 auto; @@ -48,5 +56,9 @@ margin-top: 20px; } } + + &__pagination_top { + display: block; + } } } diff --git a/styles/utils/mixins.scss b/styles/utils/mixins.scss index 7a4435d465..10cfbf774b 100644 --- a/styles/utils/mixins.scss +++ b/styles/utils/mixins.scss @@ -83,6 +83,39 @@ } }; +@mixin button-more-less($width: 32px, $height: 32px) { + @include button-transparent; + height: 32px; + + &:before { + width: unset; + height: unset; + font-family: inherit; + font-size: 14px; + color: $main-gray-color; + } + + &.disabled::before { + color: $light-gray-color; + } + + &_prev { + margin-right: 16px; + + &::before { + content: "-"; + } + } + + &_next::before { + content: "+"; + } + + &.disabled { + pointer-events: none; + } +}; + @mixin button-header { height: 64px; width: 64px; diff --git a/styles/utils/variables.scss b/styles/utils/variables.scss index 4a317891b4..71afeef919 100644 --- a/styles/utils/variables.scss +++ b/styles/utils/variables.scss @@ -5,6 +5,7 @@ $borders-gray-color: #e2e6e9; $accent-green: #27ae60; $accent-red: #eb5757; +$logo: "https://i.gstatvb.com/c389a77ca305ee5d9f0ee6f87f74fcfb1688922827.rng.png"; $arrow-left: 'https://i.gstatvb.com/666bd175cdc8706e8a3f147f985a8ebe1689008383.rng.png'; $arrow-left-light: 'https://i.gstatvb.com/56257d53833d634b58ca1095b4d5ab0b1689364322.rng.png'; $arrow-right: 'https://i.gstatvb.com/8f63a520b73400d453500cf67939b8ab1689008556.rng.png';