Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 174 additions & 21 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,193 @@
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
justify-content: flex-start;
min-height: 100vh;
padding: 2rem 1rem;
max-width: 1200px;
margin: 0 auto;
}

.App-logo {
height: 40vmin;
pointer-events: none;
.app-header {
text-align: center;
margin-bottom: 2rem;
width: 100%;
}

@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
.app-header h1 {
color: #ffffff;
font-size: 2.5rem;
font-weight: 700;
margin: 0 0 0.5rem 0;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
letter-spacing: -0.5px;
}

.App-header {
background-color: #282c34;
min-height: 100vh;
.app-header p {
color: #ffffff;
font-size: 1.2rem;
margin: 0;
opacity: 0.95;
font-weight: 300;
}

.cart-container {
background: #ffffff;
border-radius: 16px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
padding: 2rem;
width: 100%;
margin-bottom: 2rem;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.cart-container:hover {
transform: translateY(-2px);
box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2);
}

.shipping-container {
background: #ffffff;
border-radius: 16px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
padding: 2rem;
width: 100%;
margin-bottom: 2rem;
}

.purchase-button {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
border: none;
padding: 1rem 3rem;
font-size: 1.1rem;
font-weight: 600;
border-radius: 12px;
cursor: pointer;
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
transition: all 0.3s ease;
text-transform: uppercase;
letter-spacing: 1px;
width: 100%;
max-width: 400px;
margin: 0 auto;
display: block;
}

.purchase-button:hover {
transform: translateY(-2px);
box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.purchase-button:active {
transform: translateY(0);
box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.cart-items-list {
list-style-type: none;
padding: 0;
margin: 0;
display: flex;
flex-direction: column;
gap: 1rem;
}

.cart-summary {
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
border-radius: 12px;
padding: 1.5rem;
margin-top: 2rem;
border: 1px solid rgba(0, 0, 0, 0.05);
}

.cart-summary p {
margin: 0.75rem 0;
font-size: 1rem;
color: #333;
display: flex;
justify-content: space-between;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}

.App-link {
color: #61dafb;
.cart-summary hr {
border: none;
border-top: 2px solid rgba(102, 126, 234, 0.3);
margin: 1rem 0;
}

.cart-summary .order-total {
font-size: 1.5rem;
font-weight: 700;
color: #667eea;
margin-top: 1rem;
padding-top: 1rem;
border-top: 2px solid rgba(102, 126, 234, 0.3);
}

.cart-title {
color: #333;
font-size: 2rem;
font-weight: 700;
margin: 0 0 1.5rem 0;
padding-bottom: 1rem;
border-bottom: 3px solid #667eea;
}

.shipping-title {
color: #333;
font-size: 1.5rem;
font-weight: 600;
margin: 0 0 1.5rem 0;
}

.loading-text,
.error-text {
text-align: center;
padding: 2rem;
color: #333;
font-size: 1.2rem;
}

.error-text {
color: #e74c3c;
background: #ffeaea;
border-radius: 8px;
border-left: 4px solid #e74c3c;
}

@keyframes App-logo-spin {
from {
transform: rotate(0deg);
.shipping-option-label {
display: flex;
align-items: center;
padding: 1rem;
border-radius: 8px;
border: 2px solid #e0e0e0;
transition: all 0.3s ease;
cursor: pointer;
}

.shipping-option-label:hover {
border-color: #667eea;
background-color: #f8f9ff;
}

@media (max-width: 768px) {
.App {
padding: 1rem 0.5rem;
}
to {
transform: rotate(360deg);

.app-header h1 {
font-size: 2rem;
}

.cart-container,
.shipping-container {
padding: 1.5rem;
}

.purchase-button {
padding: 0.875rem 2rem;
font-size: 1rem;
}
}
18 changes: 14 additions & 4 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,26 @@ function App(props) {
return (
<>
<div className="App">
<div className="app-header">
<h1>🛍️ Shopping Cart</h1>
<p data-testid="thanks_id">Thank you for shopping with us!</p>
</div>
<div className="cart-container">
<CartView shippingCost={shippingCost} cartId={props.cartId} />
</div>
<div className="shipping-container">
<ShippingOptions onChangeValue={handleChangeValue} />
<button onClick={() => setMsgYNModal({
</div>
<button
className="purchase-button"
onClick={() => setMsgYNModal({
showMsgYNModal: true, message: "Do you agree with the purchase agreement?", methodOnClose: (decision) => {
setMsgYNModal({ msgYNModalState: { showMsgYNModal: false, message: "", methodOnClose: ()=>{} } })
}
})} >
Make Purchase
</button>
})}
>
Make Purchase
</button>
</div>
<MsgYNModal
style={{ width: '80%', maxHeight: 435 }}
Expand Down
46 changes: 39 additions & 7 deletions src/cartItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,50 @@ import Typography from '@material-ui/core/Typography';
const useStyles = makeStyles((theme) => ({
root: {
display: 'flex',
borderRadius: '12px',
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.1)',
transition: 'all 0.3s ease',
overflow: 'hidden',
marginBottom: '0.5rem',
'&:hover': {
transform: 'translateY(-2px)',
boxShadow: '0 6px 20px rgba(0, 0, 0, 0.15)',
},
},
details: {
display: 'flex',
flexDirection: 'column',
flex: '1 1 auto',
padding: '1rem',
},
content: {
flex: '1 0 auto',
padding: '0.5rem 1rem !important',
},
cover: {
height: 100,
width: '10%',
}
height: '120px',
width: '120px',
minWidth: '120px',
objectFit: 'cover',
background: 'linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%)',
},
title: {
fontWeight: 600,
color: '#333',
marginBottom: '0.5rem',
fontSize: '1.1rem',
},
description: {
color: '#666',
marginBottom: '0.5rem',
fontSize: '0.9rem',
},
price: {
color: '#667eea',
fontWeight: 700,
fontSize: '1.2rem',
marginTop: '0.5rem',
},
}));

export default function CartItem(props) {
Expand All @@ -29,14 +61,14 @@ export default function CartItem(props) {
<Card className={classes.root}>
<div className={classes.details}>
<CardContent className={classes.content}>
<Typography component="h5" variant="h5">
<Typography component="h5" variant="h5" className={classes.title}>
{props.item.title}
</Typography>
<Typography variant="subtitle1" color="textSecondary">
<Typography variant="subtitle1" className={classes.description}>
{props.item.description}
</Typography>
<Typography variant="subtitle1" color="textSecondary">
{(props.item.cost/100).toFixed(2)}
<Typography variant="subtitle1" className={classes.price}>
${(props.item.cost/100).toFixed(2)}
</Typography>
</CardContent>
</div>
Expand Down
30 changes: 21 additions & 9 deletions src/cartview.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ function CartView(props) {
}, [props.cartId]);

if (error) {
return (<h1 data-testid="error_heading_id">Failed to retrieve cart ({error.message})</h1>);
return (<h1 className="error-text" data-testid="error_heading_id">Failed to retrieve cart ({error.message})</h1>);
} else if (!cart) {
return (<h1>Loading shopping cart...</h1>);
return (<h1 className="loading-text">Loading shopping cart...</h1>);
} else {
const costs = cart.cartItems.map(a => a.cost);
const itemTotal = sum(...costs);
Expand All @@ -43,21 +43,33 @@ function CartView(props) {
return (
<>
<div>
<h1 data-testid="cart_heading_id">Shopping Cart</h1>
<ul style={{ listStyleType: 'none', padding: 0, margin: 0 }}>
<h1 className="cart-title" data-testid="cart_heading_id">Shopping Cart</h1>
<ul className="cart-items-list">
{cart.cartItems.map((cartItemData, idx) =>
<li key={idx}>
<CartItem item={cartItemData} />
</li>
)}
</ul>
</div>
<div>
<p data-testid="itemscost_id">Items: ${(itemTotal/100).toFixed(2)}</p>
<p>Shipping: ${(props.shippingCost/100).toFixed(2)}</p>
<p>Tax: ${(tax/100).toFixed(2)}</p>
<div className="cart-summary">
<p data-testid="itemscost_id">
<span>Items:</span>
<span>${(itemTotal/100).toFixed(2)}</span>
</p>
<p>
<span>Shipping:</span>
<span>${(props.shippingCost/100).toFixed(2)}</span>
</p>
<p>
<span>Tax:</span>
<span>${(tax/100).toFixed(2)}</span>
</p>
<hr></hr>
<p><b>Order Total: ${(total/100).toFixed(2)}</b></p>
<p className="order-total">
<span>Order Total:</span>
<span>${(total/100).toFixed(2)}</span>
</p>
</div>
</>
);
Expand Down
7 changes: 7 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
* {
box-sizing: border-box;
}

body {
margin: 0;
padding: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}

code {
Expand Down
Loading