-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Mykhailo Pogorenyi <mpohorenyi@gmail.com>
- Loading branch information
1 parent
d76b77b
commit 7e5de88
Showing
7 changed files
with
278 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...s/ProductDetailsPage/components/ColorCapacityComponent/ColorCapacityComponent.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
@import '../../../../styles/utils/mixins/mixin-typography'; | ||
@import '../../../../styles/utils/variables/colors'; | ||
@import '../../../../styles/utils/mixins/mixin-media'; | ||
|
||
.colorCapacity{ | ||
padding-top: 2.5rem; | ||
padding-bottom: 2rem; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1.5rem; | ||
grid-column: span 4; | ||
|
||
&__DARK { | ||
background-color: $color__dark-theme__black; | ||
} | ||
} | ||
|
||
.content { | ||
display: flex; | ||
justify-content: space-between; | ||
color: $color__secondary; | ||
@include smallText-typography; | ||
|
||
&__DARK { | ||
color: $color__dark-theme__secondary; | ||
} | ||
} | ||
|
||
.contentContainer { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
padding-bottom: 1.5rem; | ||
border-bottom: 1px solid $color__elements; | ||
} | ||
|
||
.buttonContainer { | ||
display: flex; | ||
gap: 8px; | ||
} | ||
|
||
.colorButton { | ||
width: 32px; | ||
height: 32px; | ||
border: none; | ||
background-color: transparent; | ||
cursor: pointer; | ||
} | ||
|
||
.colorContent { | ||
opacity: 0; | ||
} | ||
|
||
.capacityButton { | ||
padding: 8px 7px 4px; | ||
background-color: transparent; | ||
border-radius: 4px; | ||
border: 1px solid $color__icons; | ||
text-align: center; | ||
color: $color__primary; | ||
cursor: pointer; | ||
@include bodyText-typography; | ||
|
||
&__DARK { | ||
border-color: $color__dark-theme__icons; | ||
color: $color__dark-theme__white; | ||
border-radius: 0; | ||
} | ||
|
||
&__ACTIVE { | ||
border: none; | ||
background-color: $color__primary; | ||
color: $color__white; | ||
|
||
&__DARK { | ||
background-color: $color__dark-theme__white; | ||
color: $color__dark-theme__black; | ||
} | ||
} | ||
} |
103 changes: 103 additions & 0 deletions
103
src/modules/ProductDetailsPage/components/ColorCapacityComponent/ColorCapacityComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import React from 'react'; | ||
import cn from 'classnames'; | ||
import styles from './ColorCapacityComponent.module.scss'; | ||
import { ReactComponent as Color } | ||
from '../../../../static/icons/color-icon.svg'; | ||
import { useAppSelector } from '../../../../store/hooks'; | ||
import { ProductDetail } from '../../../../types/Product'; | ||
|
||
type Props = { | ||
productDetail: ProductDetail; | ||
setColor: React.Dispatch<React.SetStateAction<string>>; | ||
setCapacity: React.Dispatch<React.SetStateAction<string>>; | ||
}; | ||
|
||
export const ColorCapacityComponent: React.FC<Props> = ({ | ||
productDetail, | ||
setColor, | ||
setCapacity, | ||
}) => { | ||
const { isDarkTheme } = useAppSelector((state) => state.theme); | ||
|
||
return ( | ||
<section | ||
className={cn(styles.colorCapacity, { | ||
[styles.colorCapacity__DARK]: isDarkTheme, | ||
})} | ||
> | ||
<div className={styles.contentContainer}> | ||
|
||
<p | ||
className={cn(styles.content, { | ||
[styles.content__DARK]: isDarkTheme, | ||
})} | ||
> | ||
Available colors | ||
</p> | ||
|
||
<div className={styles.buttonContainer}> | ||
{isDarkTheme | ||
? ( | ||
productDetail.colorsAvailable.map(color => ( | ||
<button | ||
type="button" | ||
key={color} | ||
className={styles.colorButton} | ||
onClick={(event) => setColor(event.currentTarget.innerText)} | ||
> | ||
<Color | ||
color={color} | ||
stroke={color === productDetail.color | ||
? '#f1f2f9' : '#3b3e4a'} | ||
/> | ||
<p className={styles.colorContent}>{color}</p> | ||
</button> | ||
)) | ||
) | ||
: ( | ||
productDetail.colorsAvailable.map(color => ( | ||
<button | ||
type="button" | ||
key={color} | ||
className={styles.colorButton} | ||
onClick={(event) => setColor(event.currentTarget.innerText)} | ||
> | ||
<Color | ||
color={color} | ||
stroke={color === productDetail.color | ||
? '#0f0f11' : '#e2e6e9'} | ||
/> | ||
<p className={styles.colorContent}>{color}</p> | ||
</button> | ||
)) | ||
)} | ||
</div> | ||
</div> | ||
|
||
<div className={styles.contentContainer}> | ||
<h5 className={styles.content}> | ||
Select capacity | ||
</h5> | ||
<div className={styles.buttonContainer}> | ||
{productDetail.capacityAvailable.map(capacity => ( | ||
<button | ||
type="button" | ||
key={capacity} | ||
className={cn(styles.capacityButton, { | ||
[styles.capacityButton__ACTIVE]: | ||
capacity === productDetail.capacity, | ||
[styles.capacityButton__DARK]: isDarkTheme, | ||
[styles.capacityButton__ACTIVE__DARK]: | ||
isDarkTheme && capacity === productDetail.capacity, | ||
|
||
})} | ||
onClick={(event) => setCapacity(event.currentTarget.innerText)} | ||
> | ||
<p>{capacity}</p> | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
</section> | ||
); | ||
}; |
1 change: 1 addition & 0 deletions
1
src/modules/ProductDetailsPage/components/ColorCapacityComponent/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './ColorCapacityComponent'; |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { ProductDetail } from './Product'; | ||
|
||
export interface Detail { | ||
current: ProductDetail; | ||
additional: ProductDetail[]; | ||
} |