728x90

Cart ํด๋ ์์ฑ ํ CartPage.jsx ์ css ํ์ผ์ ์์ฑํ๋ค.
import "./CartPage.css";
import remove from "../../assets/remove.png";
import user from "../../assets/user.webp";
import Table from "../Common/Table";
import QuantityInput from "../SingleProduct/QuantityInput";
const CartPage = () => {
return (
<section className="align_center cart_page">
<div className="align_center user_info">
<img src={user} alt="user profile" />
<div>
<p className="user_name">Dooly</p>
<p className="user_email">dooly@naver.com</p>
</div>
</div>
<Table headings={["์ํ", "๊ฐ๊ฒฉ", "๊ตฌ๋งค์๋", "์ด ๊ธ์ก", "์ํ์ญ์ "]}>
<tbody>
<tr>
<td>iPhone 14</td>
<td>1,200,000 ์</td>
<td className="align_center table_quantity_input">
<QuantityInput />
</td>
<td>1,200,000 ์</td>
<td>
<img
src={remove}
alt="remove icon"
className="cart_remove_icon"
/>
</td>
</tr>
</tbody>
</Table>
</section>
);
};
export default CartPage;
CartPage.css
.cart_page {
flex-direction: column;
justify-content: center;
width: 60%;
margin: 0 auto;
padding: 32px 48px;
}
.user_info {
gap: 16px;
margin-bottom: 32px;
}
.user_info img {
width: 80px;
height: 80px;
object-fit: cover;
border-radius: 100%;
}
.user_name {
font-size: 21px;
font-weight: 600;
}
.cart_remove_icon {
width: 35px;
height: 35px;
cursor: pointer;
}
์ฅ๋ฐ๊ตฌ๋์๋ ์ฌ๋ฌ ์ํ์ด ๋ค์ด๊ฐ๊ธฐ ๋๋ฌธ์
์ฌ๊ธฐ Table ์ ๋ด์ฉ์ ์ปดํฌ๋ํธ๋ก ๋ง๋ค์ด์ ์ฌ์ฌ์ฉ ๊ฐ๋ฅํ๊ฒ ๋ง๋ค์ด์ค๋ค.

App.jsx์ CartPage ์ปดํฌ๋ํธ ์ ์ฉ
<main>
{/* <HomePage /> */}
{/* <ProductsPage /> */}
{/* <SingleProductPage /> */}
<CartPage />
</main>

Table.jsx
import "./Table.css";
const Table = ({ headings, children }) => {
return (
<table className="common_table">
<thead>
<tr>
{headings.map((item, index) => (
<th key={index}>{item}</th>
))}
</tr>
</thead>
{children}
</table>
);
};
export default Table;
Table.css
.common_table {
width: 100%;
margin-bottom: 16px;
border-collapse: collapse;
background-color: #fff;
box-shadow: 0px 3px 8px rgba(0, 0, 0, 0.24);
}
.common_table thead th {
height: 50px;
background-color: #36304a;
color: #fff;
text-transform: uppercase;
}
.common_table tbody tr {
height: 50px;
text-align: center;
}
.common_table tbody tr:nth-child(even) {
background-color: #f5f5f5;
}

CartPage.jsx
import "./CartPage.css";
import remove from "../../assets/remove.png";
import user from "../../assets/user.webp";
import Table from "../Common/Table";
import QuantityInput from "../SingleProduct/QuantityInput";
const CartPage = () => {
return (
<section className="align_center cart_page">
<div className="align_center user_info">
<img src={user} alt="user profile" />
<div>
<p className="user_name">Dooly</p>
<p className="user_email">dooly@naver.com</p>
</div>
</div>
<Table headings={["์ํ", "๊ฐ๊ฒฉ", "๊ตฌ๋งค์๋", "์ด ๊ธ์ก", "์ํ์ญ์ "]}>
<tbody>
<tr>
<td>iPhone 14</td>
<td>1,200,000 ์</td>
<td className="align_center table_quantity_input">
<QuantityInput />
</td>
<td>1,200,000 ์</td>
<td>
<img
src={remove}
alt="remove icon"
className="cart_remove_icon"
/>
</td>
</tr>
</tbody>
</Table>
<table className="cart_bill">
<tbody>
<tr>
<td>์ด ๊ธ์ก</td>
<td>1,200,000 ์</td>
</tr>
<tr>
<td>๋ฐฐ์ก๋น</td>
<td>5,000 ์</td>
</tr>
<tr className="cart_bill_final">
<td>๊ฒฐ์ฌ๊ธ์ก</td>
<td>1,205,000 ์</td>
</tr>
</tbody>
</table>
<button className="search_button checkout_button">๊ฒฐ์ ํ๊ธฐ</button>
</section>
);
};
export default CartPage;
CartPage.css
.cart_bill {
align-self: flex-end;
width: 400px;
border-collapse: collapse;
font-size: 16px;
margin-top: 16px;
background-color: #fff;
}
.cart_bill td {
padding: 12px 20px;
border: 3px solid #e5e5e5;
}
.cart_bill td:last-child {
text-align: end;
width: 250px;
}
.cart_bill_final {
font-size: 20px;
font-weight: 700;
}
.checkout_button {
align-self: flex-end;
height: 38px !important;
margin: 16px 0;
padding: 0 16px !important;
}
.table_quantity_input {
height: 50px;
justify-content: center;
}

'FRONTEND > React' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| CORS ์๋ฌ ํด๊ฒฐ ํ๊ธฐ- ์๋ผ๋API/ ๋ณด์ ์ฌํญ (0) | 2023.12.19 |
|---|---|
| [myCart] ์ฃผ๋ฌธ ๋ด์ญ ํ์ด์ง (0) | 2023.12.19 |
| [myCart] ์ํ ์์ธ๋ณด๊ธฐ( SingleProductPage ) ์์ฑ (0) | 2023.12.19 |
| [myCart] ์ํํ์ด์ง ์์ฑ (์ฌ์ด๋ ๋ฐ/ ์ํ ๋ชฉ๋ก) (2) | 2023.12.19 |
| [myCart] FeaturedProducts ์ปดํฌ๋ํธ ๋ฐ ProductCard ์ปดํฌ๋ํธ ์ฌ์ฌ์ฉ (0) | 2023.12.19 |