-
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.
Merge branch 'master' into productDetailsSlider
- Loading branch information
Showing
28 changed files
with
400 additions
and
225 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
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,48 @@ | ||
@import '../../../styles/utils/variables/colors'; | ||
|
||
.addToCart { | ||
display: flex; | ||
height: 40px; | ||
justify-content: center; | ||
align-items: center; | ||
flex: 1 0 0; | ||
|
||
border-radius: 8px; | ||
border: none; | ||
background: $color__accent; | ||
|
||
color: $color__white; | ||
text-align: center; | ||
font-size: 14px; | ||
font-weight: 700; | ||
line-height: 21px; | ||
transition: box-shadow 0.3s ease; | ||
|
||
&:hover { | ||
box-shadow: 0px 3px 13px 0px rgba(23, 32, 49, 0.4); | ||
} | ||
|
||
&__SELECTED { | ||
border-radius: 8px; | ||
border: 1px solid $color__elements; | ||
background: $color__white; | ||
color: $color__accent; | ||
} | ||
|
||
&__DARK { | ||
background: #905bff; | ||
border-radius: 0px; | ||
color: $color__dark-theme__white; | ||
border: none; | ||
transition: background-color 0.3s ease; | ||
|
||
&:hover { | ||
background-color: #a378ff; | ||
} | ||
|
||
&__SELECTED { | ||
background: $color__dark-theme__secondary; | ||
color: $color__dark-theme__white; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,46 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import { useNavigate } from 'react-router-dom'; | ||
import cn from 'classnames'; | ||
import styles from './AddToCart.module.scss'; | ||
import { useAppDispatch, useAppSelector } from '../../../store/hooks'; | ||
import { actions as cartActions } from '../../../store/reducers/cartSlice'; | ||
import { Phone } from '../../../types/Phone'; | ||
|
||
// import styles from './AddToCart.module.scss'; | ||
type Props = { | ||
productItem: Phone; | ||
}; | ||
|
||
export const AddToCart: React.FC<Props> = ({ productItem }) => { | ||
const { isDarkTheme } = useAppSelector((state) => state.theme); | ||
const navigate = useNavigate(); | ||
const { cart } = useAppSelector((state) => state.cart); | ||
const dispatch = useAppDispatch(); | ||
|
||
const [isSelected, setIsSelected] = useState<boolean>( | ||
!!cart.find(cartItem => cartItem.id === productItem.id), | ||
); | ||
|
||
const handleAddToCart = (product: Phone) => { | ||
if (!isSelected) { | ||
dispatch(cartActions.add(product)); | ||
setIsSelected(true); | ||
} else { | ||
navigate('../cart'); | ||
} | ||
}; | ||
|
||
export const AddToCart: React.FC = () => { | ||
return <div>Add to Cart Button</div>; | ||
return ( | ||
<button | ||
className={cn(styles.addToCart, { | ||
[styles.addToCart__DARK]: isDarkTheme, | ||
[styles.addToCart__SELECTED]: isSelected, | ||
[styles.addToCart__DARK__SELECTED]: | ||
isSelected && isDarkTheme, | ||
})} | ||
type="button" | ||
onClick={() => handleAddToCart(productItem)} | ||
> | ||
{isSelected ? 'Added' : 'Add to cart'} | ||
</button> | ||
); | ||
}; |
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,48 @@ | ||
@import '../../../styles/utils/variables/colors'; | ||
|
||
.addToFavourite { | ||
background-image: url('../../../static/buttons/fovourites-default_button.svg'); | ||
|
||
margin-left: 8px; | ||
width: 40px; | ||
height: 40px; | ||
flex-shrink: 0; | ||
background-repeat: no-repeat; | ||
background-position: center; | ||
background-color: $color__white; | ||
|
||
border-radius: 48px; | ||
border: 1px solid $color__icons; | ||
|
||
&:hover { | ||
transition: border 0.3s ease; | ||
border: 1px solid $color__primary; | ||
} | ||
|
||
&__SELECTED { | ||
background-image: url('../../../static/buttons/fovourites-selected_button.svg'); | ||
|
||
border: 1px solid $color__elements; | ||
} | ||
|
||
&__DARK { | ||
background-image: url('../../../static/buttons/fovourites-default_button_dark.svg'); | ||
|
||
background-color: $color__dark-theme__surface-2; | ||
border-radius: 0px; | ||
border: none; | ||
transition: background-color 0.3s ease; | ||
|
||
&:hover { | ||
background-color: $color__dark-theme__icons; | ||
} | ||
|
||
&__SELECTED { | ||
background-image: url('../../../static/buttons/fovourites-selected_button_dark.svg'); | ||
|
||
border: 1px solid $color__dark-theme__elements; | ||
border-radius: 0px; | ||
background-color: $color__dark-theme__black; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,7 +1,45 @@ | ||
import React from 'react'; | ||
import React, { useState } from 'react'; | ||
import cn from 'classnames'; | ||
import styles from './AddToFavourites.module.scss'; | ||
import { useAppDispatch, useAppSelector } from '../../../store/hooks'; | ||
import { actions as favouritiesActions } | ||
from '../../../store/reducers/favoritesSlice'; | ||
import { Phone } from '../../../types/Phone'; | ||
|
||
// import styles from './AddToFavourites.module.scss'; | ||
type Props = { | ||
productItem: Phone; | ||
}; | ||
|
||
export const AddToFavourites: React.FC<Props> = ({ productItem }) => { | ||
const { isDarkTheme } = useAppSelector((state) => state.theme); | ||
const { favorites } = useAppSelector((state) => state.favorites); | ||
const dispatch = useAppDispatch(); | ||
|
||
const [isSelected, setIsSelected] = useState<boolean>( | ||
!!favorites.find(favorite => favorite.id === productItem.id), | ||
); | ||
|
||
const handleFavouritiesButton = (product: Phone) => { | ||
if (isSelected) { | ||
dispatch(favouritiesActions.remove(product.id)); | ||
setIsSelected(false); | ||
} else { | ||
dispatch(favouritiesActions.add(product)); | ||
setIsSelected(true); | ||
} | ||
}; | ||
|
||
export const AddToFavourites: React.FC = () => { | ||
return <div>Add To Favourites Button</div>; | ||
return ( | ||
<button | ||
type="button" | ||
aria-label="Add to favourite" | ||
className={cn(styles.addToFavourite, { | ||
[styles.addToFavourite__DARK]: isDarkTheme, | ||
[styles.addToFavourite__SELECTED]: isSelected, | ||
[styles.addToFavourite__DARK__SELECTED]: | ||
isSelected && isDarkTheme, | ||
})} | ||
onClick={() => handleFavouritiesButton(productItem)} | ||
/> | ||
); | ||
}; |
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,20 @@ | ||
@import '../../../styles/utils/mixins/mixin-typography'; | ||
|
||
.backButtonContainer { | ||
display: flex; | ||
gap: 4px; | ||
align-items: flex-end; | ||
cursor: pointer; | ||
border: none; | ||
background-color: transparent; | ||
} | ||
|
||
.backButtonText { | ||
color: $color__secondary; | ||
@include smallText-typography; | ||
padding-right: 15px; | ||
|
||
&__DARK { | ||
color: $color__dark-theme__white; | ||
} | ||
} |
Oops, something went wrong.