瀏覽代碼

feat: fixed responsiveness

response-fixes
Lazar Kostic 3 年之前
父節點
當前提交
11854d4fa3

+ 72
- 57
components/cards/cart-card/CartCard.jsx 查看文件

justifyContent: { xs: 'center' }, justifyContent: { xs: 'center' },
}} }}
> >
<Box sx={{ display: { xs: 'none', md: 'flex', width: '20%' } }}>
<Box
sx={{
display: 'flex',
justifyContent: 'center',
mb: { xs: 2, md: 0 },
}}
>
<Image <Image
src="/images/coffee-mug.svg" src="/images/coffee-mug.svg"
alt="profile" alt="profile"
width={500}
height={300}
width={200}
height={200}
/> />
</Box> </Box>
<Box <Box
<Typography <Typography
align="center" align="center"
sx={{ sx={{
mb: { xs: 10, sm: 5, md: 0 },
mb: { xs: 5, sm: 5, md: 0 },
mr: { md: 5 }, mr: { md: 5 },
width: '100%', width: '100%',
fontWeight: 600, fontWeight: 600,
fontSize: { xs: 16, sm: 20 },
fontSize: { xs: 20, sm: 20 },
}} }}
> >
{product?.name} {product?.name}
<Box <Box
sx={{ sx={{
display: 'flex', display: 'flex',
flexDirection: 'column',
flexDirection: { xs: 'row', md: 'column' },
justifyContent: 'center', justifyContent: 'center',
alignItems: 'center',
mb: { xs: 10, sm: 5, md: 0 },
alignItems: { xs: 'flex-end', md: 'center' },
mb: { xs: 5, sm: 5, md: 0 },
mr: { md: 5 }, mr: { md: 5 },
}} }}
> >
<Typography
<Box
sx={{ sx={{
width: '100%',
textAlign: 'center',
height: 16,
fontSize: 14,
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-end',
mr: { xs: 2, md: 0 },
}} }}
> >
Quantity
</Typography>
<ButtonGroup
size="small"
aria-label="small outlined button group"
sx={{
height: 35,
mt: 1,
backgroundColor: 'primary.main',
color: 'white',
border: 0,
}}
>
<Button
sx={{
color: 'white',
fontSize: 17,
width: 25,
}}
onClick={() => {
if (quantity > 0) {
updateQuantity(product?.customID, quantity - 1);
setQuantity((prevState) => prevState - 1);
}
}}
>
-
</Button>
<Button
<Typography
sx={{ sx={{
color: 'white',
fontSize: 15,
width: 25,
width: '100%',
textAlign: 'center',
height: 16,
fontSize: 14,
}} }}
> >
{quantity}
</Button>
<Button
Quantity
</Typography>
<ButtonGroup
size="small"
aria-label="small outlined button group"
sx={{ sx={{
height: 35,
mt: 1,
backgroundColor: 'primary.main',
color: 'white', color: 'white',
fontSize: 17,
width: 25,
}}
onClick={() => {
updateQuantity(product?.customID, quantity + 1);
setQuantity((prevState) => prevState + 1);
border: 0,
}} }}
> >
+
</Button>
</ButtonGroup>
<Button
sx={{
color: 'white',
fontSize: 17,
width: 25,
}}
onClick={() => {
if (quantity > 0) {
updateQuantity(product?.customID, quantity - 1);
setQuantity((prevState) => prevState - 1);
}
}}
>
-
</Button>
<Button
sx={{
color: 'white',
fontSize: 15,
width: 25,
}}
>
{quantity}
</Button>
<Button
sx={{
color: 'white',
fontSize: 17,
width: 25,
}}
onClick={() => {
updateQuantity(product?.customID, quantity + 1);
setQuantity((prevState) => prevState + 1);
}}
>
+
</Button>
</ButtonGroup>
</Box>
<Button <Button
disableRipple disableRipple
sx={{ sx={{

+ 11
- 0
components/cards/order-summary-card/OrderSummaryCard.jsx 查看文件

<Divider /> <Divider />
<Box sx={{ textAlign: 'center', mt: 4, width: '100%' }}> <Box sx={{ textAlign: 'center', mt: 4, width: '100%' }}>
<Button <Button
disableRipple
sx={{ sx={{
'&.Mui-disabled': {
backgroundColor: '#0066ff',
color: '#fff',
opacity: '0.6',
},
'&:hover': {
backgroundColor: '#0066ff',
color: 'white',
boxShadow: 'none',
},
backgroundColor: '#0066ff', backgroundColor: '#0066ff',
color: 'white', color: 'white',
textTransform: 'none', textTransform: 'none',

+ 5
- 5
components/cart-content/CartContent.jsx 查看文件

return ( return (
<Typography <Typography
sx={{ sx={{
mr: { sm: 10, lg: 1 },
pl: 12,
mr: { lg: 1 },
mt: 6, mt: 6,
height: '100%', height: '100%',
textAlign: 'center', textAlign: 'center',
fontSize: 45,
fontSize: { xs: 36, md: 45 },
mb: { md: 5 },
}} }}
> >
Your cart is currently empty Your cart is currently empty
<Box <Box
sx={{ sx={{
display: 'flex', display: 'flex',
flexDirection: { xs: 'column', lg: 'row' },
flexDirection: { xs: 'column', md: 'row' },
mr: { xs: 2, md: 12 }, mr: { xs: 2, md: 12 },
ml: { xs: 2, md: 12 }, ml: { xs: 2, md: 12 },
}} }}
> >
<Box sx={{ mt: 2, mr: { lg: 2, minWidth: '65%' } }}>
<Box sx={{ mt: 2, mr: { md: 2, minWidth: '65%' }, mb: { xs: 6 } }}>
{mapProductsToDom()} {mapProductsToDom()}
</Box> </Box>



+ 18
- 11
components/features/Features.jsx 查看文件

import { Container, Typography } from '@mui/material';
import { Container, Divider, Typography } from '@mui/material';
import { Box } from '@mui/system'; import { Box } from '@mui/system';
import Image from 'next/image'; import Image from 'next/image';
import FeatureItem from './FeatureItem'; import FeatureItem from './FeatureItem';
<Container <Container
sx={{ sx={{
width: '100%', width: '100%',
height: 140,
}} }}
> >
<Typography <Typography
sx={{ sx={{
width: '100%', width: '100%',
textAlign: 'center', textAlign: 'center',
height: 60,
}} }}
> >
<Image src="/images/line.svg" alt="profile" width={150} height={50} />
<Image
src="/images/coffee-beans-icon.svg"
alt="profile"
width={100}
height={50}
/>
<Image src="/images/line.svg" alt="profile" width={150} height={50} />
<Box
sx={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Divider sx={{ width: { xs: '100px', sm: '200px' }, mr: 4 }} />

<Image
src="/images/coffee-beans-icon.svg"
alt="profile"
width={50}
height={50}
/>
<Divider sx={{ width: { xs: '100px', sm: '200px' }, ml: 4 }} />
</Box>
</Container> </Container>
<Box <Box
sx={{ sx={{

+ 1
- 0
components/layout/navbar/MainNav.jsx 查看文件



{/* The outside of the drawer */} {/* The outside of the drawer */}
<MobileNav <MobileNav
totalQuantity={totalQuantity}
session={session} session={session}
signOutHandler={signOutHandler} signOutHandler={signOutHandler}
toggleDrawer={toggleDrawer} toggleDrawer={toggleDrawer}

+ 11
- 4
components/layout/navbar/MobileNav.jsx 查看文件

import { NavItemMobile } from './NavItem'; import { NavItemMobile } from './NavItem';
import { items } from './navItems'; import { items } from './navItems';


const MobileNav = ({ toggleDrawer, session, signOutHandler, open }) => {
const MobileNav = ({
toggleDrawer,
session,
signOutHandler,
open,
totalQuantity,
}) => {
return ( return (
<Drawer <Drawer
PaperProps={{ PaperProps={{
sx: { width: '40%' },
sx: { width: { xs: '60%', sm: '50%' } },
}} }}
anchor="left" anchor="left"
open={open} open={open}
<> <>
<Box display="flex" flexDirection="column" sx={{ ml: 1 }}> <Box display="flex" flexDirection="column" sx={{ ml: 1 }}>
<NavItemMobile <NavItemMobile
icon={<AccountCircleIcon />}
icon={<AccountCircleIcon sx={{ color: '#664c47' }} />}
toggleDrawer={toggleDrawer} toggleDrawer={toggleDrawer}
name="Profile" name="Profile"
url={PROFILE_PAGE} url={PROFILE_PAGE}


<Divider sx={{}} /> <Divider sx={{}} />
<NavItemMobile <NavItemMobile
icon={<ShoppingCartIcon />}
totalQuantity={totalQuantity}
icon={<ShoppingCartIcon sx={{ color: '#664c47' }} />}
toggleDrawer={toggleDrawer} toggleDrawer={toggleDrawer}
name="Cart" name="Cart"
url={CART_PAGE} url={CART_PAGE}

+ 26
- 2
components/layout/navbar/NavItem.jsx 查看文件

import { Box, ListItemButton, ListItemText, Typography } from '@mui/material'; import { Box, ListItemButton, ListItemText, Typography } from '@mui/material';
import Link from 'next/link'; import Link from 'next/link';


export const NavItemMobile = ({ toggleDrawer, icon, name, url }) => {
export const NavItemMobile = ({
toggleDrawer,
icon,
name,
url,
totalQuantity,
}) => {
return ( return (
<ListItemButton> <ListItemButton>
<Link href={url}> <Link href={url}>
onClick={toggleDrawer(false)} onClick={toggleDrawer(false)}
primary={ primary={
<Box sx={{ display: 'flex' }}> <Box sx={{ display: 'flex' }}>
<Box sx={{ mt: 0.4, mr: 2 }}>{icon}</Box>
<Box sx={{ mt: 0.4, mr: 4 }}>{icon}</Box>
<Typography <Typography
sx={{ fontSize: '22px' }} sx={{ fontSize: '22px' }}
style={{ color: 'primary.main' }} style={{ color: 'primary.main' }}
> >
{name} {name}
</Typography> </Typography>
{name === 'Cart' && totalQuantity !== 0 && (
<Box
sx={{
color: 'white',
width: 20,
height: 20,
borderRadius: 20,
textAlign: 'center',
ml: 2.6,
mt: '-7px',
fontSize: 15,
position: 'absolute',
backgroundColor: 'primary.main',
}}
>
{totalQuantity}
</Box>
)}
</Box> </Box>
} }
/> />

+ 3
- 3
components/layout/navbar/navItems.js 查看文件

id: 1, id: 1,
name: 'Home', name: 'Home',
url: BASE_PAGE, url: BASE_PAGE,
icon: <HomeIcon></HomeIcon>,
icon: <HomeIcon sx={{ color: '#664c47' }}></HomeIcon>,
}, },
{ {
id: 2, id: 2,
name: 'Store', name: 'Store',
url: PRODUCTS_PAGE, url: PRODUCTS_PAGE,
icon: <LocalMallIcon></LocalMallIcon>,
icon: <LocalMallIcon sx={{ color: '#664c47' }}></LocalMallIcon>,
}, },
{ {
id: 3, id: 3,
name: 'Contact', name: 'Contact',
url: CONTACT_PAGE, url: CONTACT_PAGE,
icon: <ContactSupportIcon></ContactSupportIcon>,
icon: <ContactSupportIcon sx={{ color: '#664c47' }}></ContactSupportIcon>,
}, },
]; ];

+ 1
- 1
components/product-card/ProductCard.jsx 查看文件

{product.name} {product.name}
</Typography> </Typography>
<Typography <Typography
sx={{ height: '200px' }}
sx={{ height: { xs: '200px', sm: '250px', md: '200px' } }}
align="center" align="center"
fontSize="18px" fontSize="18px"
m={2} m={2}

+ 14
- 5
components/products/featured-product/ProductInfo.jsx 查看文件

sx={{ sx={{
width: '100%', width: '100%',
display: 'flex', display: 'flex',
mt: 4,
flexDirection: { xs: 'column', md: 'row' },
mt: 6,
flexDirection: { md: 'row' },
alignItems: { xs: 'center' }, alignItems: { xs: 'center' },
justifyContent: { md: 'flex-start' },
justifyContent: { xs: 'center', md: 'flex-start' },
}} }}
> >
<ButtonGroup <ButtonGroup
<Button <Button
disableRipple disableRipple
sx={{ sx={{
'&.Mui-disabled': {
color: 'rgba(255, 255, 255, 0.6)',
},
color: 'white', color: 'white',
fontSize: 20, fontSize: 20,
width: 50, width: 50,
<Button <Button
disableRipple disableRipple
sx={{ sx={{
'&.Mui-disabled': {
color: 'rgba(255, 255, 255, 0.6)',
},
color: 'white', color: 'white',
fontSize: 17, fontSize: 17,
width: 50, width: 50,
<Button <Button
disableRipple disableRipple
sx={{ sx={{
'&.Mui-disabled': {
color: 'rgba(255, 255, 255, 0.6)',
},
color: 'white', color: 'white',
fontSize: 20, fontSize: 20,
width: 50, width: 50,
<Button <Button
disableRipple disableRipple
sx={{ sx={{
mt: { xs: 2, md: 0 },
ml: { md: 2 },
mt: { md: 0 },
ml: { xs: 2 },
backgroundColor: '#CBA213', backgroundColor: '#CBA213',
height: 50, height: 50,
width: 150, width: 150,

+ 2
- 0
components/review-content/ReviewContent.jsx 查看文件

const ReviewContent = () => { const ReviewContent = () => {
const { parseCheckoutValue, clearCheckout } = useCheckoutDataUpdate(); const { parseCheckoutValue, clearCheckout } = useCheckoutDataUpdate();
const { clearCart } = useStoreUpdate(); const { clearCart } = useStoreUpdate();
// eslint-disable-next-line no-unused-vars
const [orderData, setOrderData] = useState(parseCheckoutValue()); const [orderData, setOrderData] = useState(parseCheckoutValue());


const router = useRouter(); const router = useRouter();
}); });
}; };
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
return ( return (
<Box sx={{ py: 10, height: '100%', width: '100%' }}> <Box sx={{ py: 10, height: '100%', width: '100%' }}>

+ 6
- 1
hooks/useFetchProductData.js 查看文件

export const useFetchSingleProduct = (customID) => { export const useFetchSingleProduct = (customID) => {
return useQuery( return useQuery(
['product', customID], ['product', customID],
async () => await getProductData(customID)
async () => await getProductData(customID),
{
refetchOnWindowFocus: false,
staleTime: 60000,
cacheTime: 300000,
}
); );
}; };

+ 3
- 0
hooks/useInfiniteQuery.js 查看文件

return pages.length + 1; return pages.length + 1;
} }
}, },
refetchOnWindowFocus: false,
staleTime: 60000,
cacheTime: 300000,
} }
); );
}; };

Loading…
取消
儲存