Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Product details slider #44

Merged
merged 5 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/modules/ProductDetailsPage/ProductDetailsPage.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@import '../../styles/blocks/container';

.container {
@extend .container;
}
19 changes: 14 additions & 5 deletions src/modules/ProductDetailsPage/ProductDetailsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,35 @@
import React from 'react';
import React, { useEffect, useState } from 'react';

// import styles from './ProductDetailsPage.module.scss';
import styles from './ProductDetailsPage.module.scss';

import { Breadcrumbs } from '../shared/Breadcrumbs';
import { BackButton } from '../shared/BackButton';
import { ProductDetailsSlider } from './components/ProductDetailsSlider';
import { PhoneDetail } from '../../types/PhoneDetail';
import { getPhoneDetail } from '../../api/service';
// import { ProductSlider } from '../shared/ProductSlider';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dont forget to remove it if you don't need it)


export const ProductDetailsPage: React.FC = () => {
const [phoneDetails, setPhoneDetails] = useState<PhoneDetail | null>(null);

useEffect(() => {
getPhoneDetail('apple-iphone-7-32gb-black')
.then(setPhoneDetails);
}, []);

return (
<>
<div className={styles.container}>
<Breadcrumbs />

<BackButton />

<h2>Name of Product</h2>

<article>
<ProductDetailsSlider />
<ProductDetailsSlider images={phoneDetails?.images} />
</article>

{/* <ProductSlider /> */}
</>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react';
import styles from './ProductDetailsSlider.module.scss';

export const NextArrow: React.FC = () => {
return (
<>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need in a fragment component if you have only one child inside

<div
className={styles['slick-next-phone']}
/>
</>
);
};

export const PrevArrow: React.FC = () => {
return (
<>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same story, fragment component is redundant

<div
className={styles['slick-prev-phone']}
/>
</>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import styles from './ProductDetailsSlider.module.scss';

export const getBorderColor = (
i: number, currentSlide: number, isDarkTheme: boolean,
) => {
let borderColor;

switch (true) {
case currentSlide === i && isDarkTheme:
borderColor = styles['dots-border-dark-cur'];
break;

case currentSlide !== i && isDarkTheme:
borderColor = styles['dots-border-dark'];
break;

case currentSlide === i && !isDarkTheme:
borderColor = styles['dots-border-light-cur'];
break;

case currentSlide !== i && !isDarkTheme:
borderColor = styles['dots-border-light'];
break;

default:
break;
}

return borderColor;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
@import '../../../../styles/utils/mixins/mixin-media';

.slick-prev-phone,
.slick-next-phone {
display: none;
visibility: hidden;
}

#phoneImagesSlider {
.slick-track {
display: flex;
height: 464px !important;
}
}

.phonePhoto {
@include onMobile {
width: 288px;
height: 288px;
object-fit: contain;
margin-inline: auto;
}

@include onTablet {
width: 288px;
height: 288px;
object-fit: contain;
}

@include onDesktop {
width: 464px;
height: 464px;
object-fit: contain;
}
};

.slick-dots,
.slick-thumb {
cursor: pointer;
width: auto !important;

@include onMobile {
height: 40px;
width: 51px;
object-fit: contain;
padding-block: 4px;
}

@include onTablet {
height: 28px;
width: 28px;
object-fit: contain;
padding-block: 4px;
}

@include onDesktop {
height: 67px;
width: 67px;
object-fit: contain;
padding: 4px;
}
}

#phone-photo {
width: auto !important;
height: 464px !important;
img {
width: auto !important;
}
}

.vertical-dots {
ul {
display: flex !important;
flex-direction: column;
margin-right: 16px;
width: auto !important;
margin-top: 0 !important;

@include onMobile {
flex-direction: row;
margin-right: 0px;
justify-content: center;
margin-top: 16px !important;
}

@include onTablet {
:last-child {
margin-bottom: 0px;
}
}

@include onDesktop {
:last-child {
margin-bottom: 0px;
}
}

li {
width: 79px;
height: 79px;
display: flex;
justify-content: center;
align-items: center;

@include onTablet {
width: 34px;
height: 34px;
}

@include onDesktop {
width: 79px;
height: 79px;
display: flex;
justify-content: center;
align-items: center;
}

@include onMobile {
width: 48px;
height: 48px;
display: flex;
justify-content: center;
align-items: center;
}

a {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
}
}

li {

@include onMobile {
width: 51px !important;
margin-right: 8px;
}

@include onTablet {
margin-bottom: 8px;
}

@include onDesktop {
margin-bottom: 16px;
}
}

@include onTablet {
display: flex;
flex-direction: row-reverse;
margin-right: 16px;
cursor: pointer;
}

@include onDesktop {
display: flex;
flex-direction: row-reverse;
cursor: pointer;
margin-right: 16px;
}
}

.dots-container {
display: flex;
flex-direction: column;
}

.dots-border-light-cur {
border: 1px solid #0F0F11;
border-radius: 4px;
}

.dots-border-light {
border: 1px solid #E2E6E9;
border-radius: 4px;
}

.dots-border-dark {
border: 1px solid #3b3e4a;
border-radius: 4px;
}

.dots-border-dark-cur {
border: 1px solid #f1f2f9;
border-radius: 4px;
}
Loading