-
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.
- Loading branch information
1 parent
1919a44
commit ef0e06a
Showing
12 changed files
with
150 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { Typography, styled } from '@mui/material'; | ||
|
||
const Indicator = styled(Typography)(({ theme }) => { | ||
|
||
const transformPos = Math.sqrt(2) / 2; | ||
|
||
return ({ | ||
position: 'absolute', | ||
backgroundColor: theme.palette.error.main, | ||
color: theme.palette.error.contrastText, | ||
borderRadius: '50%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
minHeight: theme.Sizes.icon.default.height, | ||
minWidth: theme.Sizes.icon.default.width, | ||
padding: theme.Spaces.xxs, | ||
aspectRatio: '1/1', | ||
fontSize: '0.6rem', | ||
alignSelf: 'flex-start', | ||
top: '0', | ||
right: '0', | ||
transform: `translate(40%, -40%)`, | ||
}) | ||
}); | ||
|
||
export default Indicator; |
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,45 @@ | ||
import React from 'react'; | ||
import Icon from '@icons/utility/CartIcon'; | ||
import { styled } from '@mui/system'; | ||
import IconButton from '@components/Button/IconButton'; | ||
import Indicator from './Indicator'; | ||
|
||
const CartIcon = styled(Icon)(({ theme }) => ({ | ||
|
||
...theme.Sizes.icon.small, | ||
'& path': { | ||
stroke: theme.palette.primary.contrastText, | ||
transition: theme.Transitions.createTransition({ | ||
property: 'stroke', | ||
duration: 'shorter', | ||
easing: 'easeInOut' | ||
}), | ||
}, | ||
})); | ||
|
||
const CartIconBtn = styled(IconButton)(({ theme }) => ({ | ||
margin: `0 ${theme?.Spaces.xs}`, | ||
})); | ||
|
||
const itemsInCart = 6; | ||
const getItemsInCart = () => itemsInCart > 5 ? '5+' : itemsInCart; | ||
|
||
const Cart = () => { | ||
return ( | ||
<CartIconBtn | ||
aria-label="cart" | ||
vocab='Cart' | ||
onClick={() => window.alert('cart button was clicked')} | ||
> | ||
<Indicator | ||
variant='h4' | ||
content='span' | ||
> | ||
{getItemsInCart()} | ||
</Indicator> | ||
<CartIcon /> | ||
</CartIconBtn> | ||
) | ||
}; | ||
|
||
export default Cart; |
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
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,26 @@ | ||
import React from 'react'; | ||
import { UtilityIconProps } from '@interfaces/SVGProps'; | ||
import svgCommonProps from '@utils/svgCommonProps'; | ||
import { styled } from '@mui/material'; | ||
|
||
export const CartIcon = ({ hovered, active, ...props }: UtilityIconProps) => { | ||
return ( | ||
<svg | ||
{...svgCommonProps} | ||
data-name='Cart Icon' | ||
width='50' | ||
height='50' | ||
viewBox='0 0 50 50' | ||
{...props} | ||
> | ||
<path d="M38.09174,16.58629,35.68542,6.94417a5.04823,5.04823,0,0,0-4.89679-3.81982H19.21137a5.04823,5.04823,0,0,0-4.89679,3.81982l-2.40632,9.64212H1.71084L8.324,43.05583a5.04823,5.04823,0,0,0,4.89678,3.81982H36.7792A5.04823,5.04823,0,0,0,41.676,43.05583l6.61318-26.46954ZM23.41921,33.31178v9.48475H19.98889L18.2026,33.31178ZM17.6177,30.1502l-1.78629-9.48475h7.5878V30.1502Zm8.96309,3.16158H31.7974l-1.78629,9.48475H26.58079Zm0-3.16158V20.66545h7.5878l-1.7863,9.48475Zm10.7968-9.48475h5.45374L40.46014,30.1502H35.5913ZM18.3027,7.76872a1.55209,1.55209,0,0,1,1.51866-1.27889h10.4484a1.55209,1.55209,0,0,1,1.51866,1.27889l1.89833,8.81757H16.31325ZM12.62241,20.66545,14.4087,30.1502H9.53986L7.16868,20.66545Zm-.26874,20.92968-2.02341-8.28335h4.74237l1.77049,9.48475H13.93446A1.58079,1.58079,0,0,1,12.35367,41.59513Zm25.19781,0a1.58079,1.58079,0,0,1-1.48594,1.2014H33.23592l1.77049-9.48475h4.74237Z" transform="translate(-1.71084 -3.12435)"/> | ||
</svg> | ||
) | ||
}; | ||
|
||
export default styled(CartIcon)(({ theme }) => ({ | ||
'& path': { | ||
strokeWidth: 0, | ||
fill: theme.palette.primary.contrastText, | ||
}, | ||
})); |
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