Skip to content

Commit

Permalink
cart fixed with more responsiveness, still need to adjust the width t…
Browse files Browse the repository at this point in the history
…o be responsive
  • Loading branch information
davidqing6432 committed Apr 3, 2024
1 parent 1999a01 commit feebd5f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 42 deletions.
20 changes: 9 additions & 11 deletions src/app/cart/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,14 @@ export default function Buttons(props: {
// used hyphen instead of dash for display

return (
<ButtonsWrapper>
<QuantityButton>
<PlusMinusButton type="button" onClick={decreaseQuantity}>
</PlusMinusButton>
<span>{count}</span>
<PlusMinusButton type="button" onClick={increaseQuantity}>
+
</PlusMinusButton>
</QuantityButton>
</ButtonsWrapper>
<QuantityButton>
<PlusMinusButton type="button" onClick={decreaseQuantity}>
</PlusMinusButton>
<span>{count}</span>
<PlusMinusButton type="button" onClick={increaseQuantity}>
+
</PlusMinusButton>
</QuantityButton>
);
}
46 changes: 24 additions & 22 deletions src/app/cart/cartItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import { useState } from 'react';
import { Body2, Body2Light, Heading4Bold } from '@/styles/fonts';
import { removeCartItem } from '../../api/supabase/queries/cart_queries';

import {
Expand All @@ -9,6 +10,7 @@ import {
TransparentButton,
Label,
LabelBox,
ImageBackground,
} from './styles';

import Buttons from './Buttons';
Expand Down Expand Up @@ -36,31 +38,31 @@ export default function CartItem(props: {
}

return (
<div>
<FavoriteDiv key={cartItemProduct.id}>
<FavoriteDiv key={cartItemProduct.id}>
<ImageBackground>
<img
src={cartItemProduct.photo}
alt={cartItemProduct.name}
style={{ width: '150px', height: '150px' }}
style={{ width: '150px', height: '150px', objectFit: 'cover' }}
/>
<LabelBox>
<Label>{cartItemProduct.name}</Label>
<p>Category: {cartItemProduct.category}</p>
</LabelBox>
<Buttons
productNumber={cartItemProduct.id}
quantity={cartItemProduct.quantity}
setNumberOfItems={setNumberOfItems}
numberOfItems={numberOfItems}
count={count}
setCount={setCount}
setCart={setCart}
cart={cart}
/>
<TransparentButton onClick={() => removeProduct()}>
<TrashIcon />
</TransparentButton>
</FavoriteDiv>
</div>
</ImageBackground>
<LabelBox>
<Heading4Bold>{cartItemProduct.name}</Heading4Bold>
<Body2>Category: {cartItemProduct.category}</Body2>
</LabelBox>
<Buttons
productNumber={cartItemProduct.id}
quantity={cartItemProduct.quantity}
setNumberOfItems={setNumberOfItems}
numberOfItems={numberOfItems}
count={count}
setCount={setCount}
setCart={setCart}
cart={cart}
/>
<TransparentButton onClick={() => removeProduct()}>
<TrashIcon />
</TransparentButton>
</FavoriteDiv>
);
}
25 changes: 16 additions & 9 deletions src/app/cart/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ import Footer from '../../components/FooterFolder/Footer';
export const FavoriteDiv = styled.div`
display: flex;
flex-direction: row;
align-items: start;
justify-content: space-around;
width: 1000px;
margin-bottom: 50px;
margin-top: 30px;
align-items: center;
justify-content: space-between;
max-width: 750px;
width: 100%;
`;

export const ImageBackground = styled.div`
width: 200px;
height: 200px;
background-color: ${COLORS.lightGrey};
display: flex;
justify-content: center;
align-items: center;
`;

export const CartItemsDiv = styled.div`
Expand All @@ -24,6 +32,7 @@ export const CartItemsDiv = styled.div`
border-radius: 10px;
width: 750px;
overflow: auto;
gap: 32px;
`;

export const BackDiv = styled.button`
Expand All @@ -50,8 +59,6 @@ export const TrashIcon = styled(Trash2)`
width: 30px;
height: 30px;
color: black;
margin-right: 30px;
margin-top: 28px;
`;

export const NavBarZeroIndex = styled(NavBar)`
Expand Down Expand Up @@ -79,7 +86,6 @@ export const ButtonsWrapper = styled.div`
align-items: center;
width: 200px;
height: 50px;
margin-top: 20px;
`;

export const QuantityButton = styled.div`
Expand All @@ -103,6 +109,7 @@ export const PlusMinusButton = styled.button`
border-color: transparent;
font-size: 20px;
color: ${COLORS.navy};
cursor: pointer;
`;

export const Label = styled.p`
Expand All @@ -111,7 +118,6 @@ export const Label = styled.p`

export const LabelBox = styled.div`
width: 150px;
height: 100%;
`;

export const PageDiv = styled.div`
Expand All @@ -120,6 +126,7 @@ export const PageDiv = styled.div`
flex-direction: column;
padding: 32px;
gap: 32px;
background-color: ${COLORS.offWhite};
`;

export const ContentDiv = styled.div`
Expand Down

0 comments on commit feebd5f

Please sign in to comment.