souksultan / components /checkout-cart.js
Tarik32's picture
تصرّف كمطوّر مواقع محترف وخبير UX/UI ومتخصص في التجارة الإلكترونية.
8609464 verified
class CheckoutCart extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
.checkout-container {
background: white;
border-radius: 0.5rem;
padding: 1.5rem;
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}
.cart-item {
display: flex;
padding: 1rem 0;
border-bottom: 1px solid #E5E7EB;
}
.cart-item:last-child {
border-bottom: none;
}
.item-image {
width: 80px;
height: 80px;
object-fit: contain;
margin-left: 1rem;
}
.item-details {
flex: 1;
}
.item-title {
font-weight: 600;
margin-bottom: 0.25rem;
}
.item-price {
color: #4F46E5;
font-weight: 600;
}
.quantity-control {
display: flex;
align-items: center;
margin-top: 0.5rem;
}
.quantity-btn {
width: 28px;
height: 28px;
border: 1px solid #D1D5DB;
background: white;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.quantity-input {
width: 40px;
height: 28px;
text-align: center;
border-top: 1px solid #D1D5DB;
border-bottom: 1px solid #D1D5DB;
border-left: none;
border-right: none;
}
.remove-btn {
color: #EF4444;
background: none;
border: none;
cursor: pointer;
margin-top: 0.5rem;
display: flex;
align-items: center;
}
.summary {
margin-top: 1.5rem;
border-top: 1px solid #E5E7EB;
padding-top: 1.5rem;
}
.summary-row {
display: flex;
justify-content: space-between;
margin-bottom: 0.75rem;
}
.total {
font-weight: 600;
font-size: 1.125rem;
}
.checkout-btn {
width: 100%;
padding: 0.75rem;
background: #4F46E5;
color: white;
border: none;
border-radius: 0.375rem;
font-weight: 500;
cursor: pointer;
transition: all 0.2s;
margin-top: 1rem;
}
.checkout-btn:hover {
background: #4338CA;
}
</style>
<div class="checkout-container">
<h2 class="text-xl font-bold mb-4">سلة التسوق</h2>
<div class="cart-item">
<img src="http://static.photos/electronics/200x200/1" alt="هاتف ذكي" class="item-image">
<div class="item-details">
<div class="item-title">هاتف ذكي XZ Pro</div>
<div class="item-price">1,899 ج.م</div>
<div class="quantity-control">
<button class="quantity-btn">-</button>
<input type="number" value="1" class="quantity-input">
<button class="quantity-btn">+</button>
</div>
<button class="remove-btn">
<i data-feather="trash-2" width="16" height="16"></i>
<span class="mr-1">إزالة</span>
</button>
</div>
</div>
<div class="summary">
<div class="summary-row">
<span>المجموع الفرعي</span>
<span>1,899 ج.م</span>
</div>
<div class="summary-row">
<span>الشحن</span>
<span>50 ج.م</span>
</div>
<div class="summary-row total">
<span>الإجمالي</span>
<span>1,949 ج.م</span>
</div>
</div>
<button class="checkout-btn">إتمام الشراء</button>
</div>
`;
}
}
customElements.define('checkout-cart', CheckoutCart);