Skip to content

Commit

Permalink
slider, capsity colors fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor-Yaremchuk committed Oct 17, 2024
1 parent 6a30195 commit 74c0233
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 10 deletions.
27 changes: 25 additions & 2 deletions src/components/Filter/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,33 @@ export const Filter: React.FC<Props> = React.memo(({ product, products }) => {
const { t } = useTranslation();
const navigate = useNavigate();
const { pathname } = useLocation();
const path = pathname.split('-');

let path = pathname.split('-');

const replaceColor = (newColor: string) => {
path[path.length - 1] = newColor;
if (
path.some(item => {
switch (item) {
case 'space':
return true;

case 'rose':
return true;

case 'sky':
return true;

default:
return false;
}
})
) {
path = path.slice(0, -2);
path.push(newColor);
} else {
path = path.slice(0, -1);
path.push(newColor.replace(' ', '-'));
}

const newPath = path.join('-');

Expand Down
33 changes: 32 additions & 1 deletion src/components/FilterCapacity/FilterCapacity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,38 @@ export const FilterCapacity: React.FC<Props> = React.memo(({ product }) => {
const replaceCapacity = (newCapacity: string) => {
const path = pathname.split('-');

path[path.length - 2] = newCapacity.toLowerCase();
if (
path.some(item => {
switch (item) {
case '38mm':
return true;

case '40mm':
return true;

case '42mm':
return true;

case '44mm':
return true;

default:
return false;
}
})
) {
const indexCapacity = path.findIndex(
item =>
item.includes('38mm') ||
item.includes('42mm') ||
item.includes('40mm') ||
item.includes('44mm'),
);

path[indexCapacity] = newCapacity.toLowerCase();
} else {
path[path.length - 2] = newCapacity.toLowerCase();
}

const newPath = path.join('-');

Expand Down
7 changes: 1 addition & 6 deletions src/components/ProductCard/ProductCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,7 @@ export const ProductCard: React.FC<Props> = React.memo(
className="productCard__link"
>
{slash ? (
<img
src={`/${image}`}
// src={image}
alt={name}
className="productCard__link_img"
/>
<img src={image} alt={name} className="productCard__link_img" />
) : (
<img src={image} alt={name} className="productCard__link_img" />
)}
Expand Down
1 change: 1 addition & 0 deletions src/constants/Colors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ColorPalette } from '../types/ColorPalet';
export const Colors: ColorPalette = {
'space gray': '#6E6E73',
spacegray: '#6E6E73',
'space-gray': '#6E6E73',
silver: '#C0C0C0',
gold: '#D4AF37',
blue: '#0071E3',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/CartPage/CartPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const CartPage: React.FC = () => {

useEffect(() => {
window.scrollTo({ top: 0 });
}, []);
}, [productsOfCart]);

return (
<section className="cart">
Expand Down

0 comments on commit 74c0233

Please sign in to comment.