Skip to content

Commit

Permalink
paginations styles on mobile was fixed and icons in checkout cards we…
Browse files Browse the repository at this point in the history
…re improved
  • Loading branch information
Anastasiya145 committed Jul 27, 2023
1 parent 0bd3a62 commit fa049b5
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/components/CheckoutCard/checkoutCard.scss
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,12 @@
}

&__button {
@include button-arrows;
@include button-more-less;

&_prev {
content: "+";

}
}

&__count {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Footer/footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/components/Header/header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
30 changes: 26 additions & 4 deletions src/components/Pagination/Pagination.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -10,15 +10,37 @@ export type Props = {
currentPage: number,
};

const DEFAULT_VISIBLE_PAGES = 4;

export const Pagination: React.FC<Props> = ({
total,
itemsOnPage,
currentPage,
}) => {
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<number[]>([]);

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) {
Expand Down Expand Up @@ -46,7 +68,7 @@ export const Pagination: React.FC<Props> = ({
/>

<ul className="pagination__list">
{numberOfPages.map(pageNumber => (
{visiblePages.map(pageNumber => (
<li key={pageNumber} className="pagination__item">
<Link
to={{
Expand Down
6 changes: 6 additions & 0 deletions src/components/Pagination/pagination.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
grid-gap: 16px;
gap: 16px;

// &__container {
// max-width: 200px;
// overflow-x: hidden;
// transition: transform 0.3s ease;
// }

&__list {
display: flex;
grid-gap: 8px;
Expand Down
14 changes: 14 additions & 0 deletions src/components/ProductList/ProductList.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useMemo, useState } from 'react';
import { useSearchParams } from 'react-router-dom';
import classNames from 'classnames';
import { Product } from '../../types/Product';
import { sortProducts } from '../../helpers/sortHelper';
import { Dropdown } from '../Dropdown/Dropdown';
Expand Down Expand Up @@ -99,6 +100,19 @@ export const ProductList: React.FC<Props> = ({
/>
</div>
)}
{isPaginationBarShown && (
<div className={classNames(
'product-list__pagination',
'product-list__pagination_top',
)}
>
<Pagination
total={sortedProducts.length}
itemsOnPage={itemsOnPage}
currentPage={page}
/>
</div>
)}
</div>
)}

Expand Down
12 changes: 12 additions & 0 deletions src/components/ProductList/productList.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@

&__pagination {
margin-top: 24px;

&_top {
display: none;
}
}
}

Expand All @@ -39,6 +43,10 @@
flex-direction: column;
}

&__container {
flex-direction: column;
}

&__dropdowns {
flex-direction: column;
margin: 0 auto;
Expand All @@ -48,5 +56,9 @@
margin-top: 20px;
}
}

&__pagination_top {
display: block;
}
}
}
33 changes: 33 additions & 0 deletions styles/utils/mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions styles/utils/variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down

0 comments on commit fa049b5

Please sign in to comment.