promo! before react

This commit is contained in:
Zakhar
2026-08-24 06:45:21 +03:00
parent 9baa29bd68
commit dec37e92c8
4 changed files with 196 additions and 21 deletions
+5 -3
View File
@@ -75,7 +75,7 @@
}
.loader:after,
.loader:before {
content: 'Собираем...';
content: 'Брок бегает по супермаркету...';
display: block;
position: absolute;
top: 0; bottom: 0; left: 0; right: 0;
@@ -166,6 +166,7 @@
#total-price { font-size: 20px; line-height: 24px; font-weight: 500; color: #0C3B2E; margin-top: 4px;visibility: hidden;}
.checkout-btn { background-color: #5EA12D;height: 54px; color: #ffffff; border: none; padding: 14px 32px; border-radius: 12px; font-size: 16px; font-weight: 370; line-height: 20px; cursor: pointer; transition: background 0.2s; }
.total-wrap { display: flex; flex-direction: column; align-items: flex-start; }
.total-wrap > div { display: flex; align-items: center; }
.checkout-btn:hover { background-color: #72B541; }
.checkout-btn:focus, .checkout-btn:focus-visible { background-color: #72B541;box-shadow: 0 4px 10px rgba(12, 59, 46, 0.1); }
.checkout-btn:active { background-color: #4A8D19;}
@@ -215,6 +216,7 @@
.day-btn { flex: 1; height: 52px;max-width:140px;border: 2px solid #e1e1e1; border-radius: 8px; background: #ffffff; font-size: 16px; line-height:19px;font-weight: 350; color: #0C3B2E; cursor: pointer; transition: 0.2s; }
.day-btn:hover { border-color: #6ba531; }
.day-btn.active { background: #E6F696; border-color: #5EA12D; }
.day-btn:focus { outline: none; }
/* Семья (Кто будет есть?) */
.family-list { display: flex; flex-direction: column; gap: 12px; }
@@ -647,7 +649,7 @@
<div>
<div class="summary-title">Ваша корзина на <span class="summary-days"> - </span></div>
<div class="relative">
<div><div class="loader hidden" id="summary-loader">Собираем...</div></div>
<div><div class="loader hidden" id="summary-loader">Брок бегает по супермаркету...</div></div>
<div class="summary-details" id="summary-details">
<span>84 товара</span>
<b>&bull;</b>
@@ -670,7 +672,7 @@
<div class="cart-footer">
<div class="total-wrap">
<div style="display: flex; align-items: center;">
<div>
<div class="icon-circle bg-green-light">
<svg width="44" height="44" viewBox="0 0 44 44" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect width="44" height="44" rx="22" fill="#E6F696"/>
+58 -16
View File
@@ -1897,18 +1897,63 @@ const cartPolicy = trustedTypes.createPolicy('cartPolicy', {
});
function renderProducts() {
cartList.innerHTML = cartPolicy.createHTML('');
const existingNodesByKey = new Map();
Array.from(cartList.children).forEach(node => {
existingNodesByKey.set(node.dataset.productKey, node);
});
visibleProducts.forEach((item, index) => {
let node = renderProduct(item, index)
node.getElementsByClassName('item-image')[0].addEventListener('click', () => openModal(
item.image.replace('65,fit', '335,fit'),
item.name,
item.n,
item.total_price,
() => {console.log('replace')},
() => {console.log('another')},
));
cartList.appendChild(node);
const key = item.name;
const signature = JSON.stringify({
name: item.name,
n: item.n,
price: item.price,
total_price: item.total_price,
currency: item.currency,
image: item.image,
unit: item.unit,
});
let node = existingNodesByKey.get(key);
if (!node || node.dataset.productSignature !== signature) {
const oldNode = node;
node = renderProduct(item, index);
node.dataset.productKey = key;
node.dataset.productSignature = signature;
node.getElementsByClassName('item-image')[0].addEventListener('click', () => openModal(
item.image.replace('65,fit', '335,fit'),
item.name,
item.n,
item.total_price,
() => { console.log('replace') },
() => { console.log('another') },
));
if (oldNode) {
oldNode.replaceWith(node);
}
} else {
const menuBtn = node.querySelector('.menu-btn');
if (menuBtn) {
menuBtn.dataset.index = index;
}
}
const currentNodeAtPosition = cartList.children[index];
if (currentNodeAtPosition !== node) {
cartList.insertBefore(node, currentNodeAtPosition || null);
}
existingNodesByKey.delete(key);
});
existingNodesByKey.forEach(node => {
node.remove();
});
const remaining = allProducts.length - visibleProducts.length;
@@ -1918,6 +1963,7 @@ function renderProducts() {
} else {
showMoreBtn.classList.add('hidden');
}
updateSummaryCount();
calculateListHeight();
}
@@ -2024,12 +2070,8 @@ function wholeRender(initialData) {
replaceProduct(allProducts[index].name).then(() => {
li.remove();
document.querySelectorAll('.menu-dropdown.active').forEach(el => el.classList.remove('active'));
visibleProducts.splice(index, 1);
allProducts.splice(index, 1);
if(visibleProducts.length < allProducts.length) {
visibleProducts.push(allProducts[visibleProducts.length]);
}
visibleProducts = allProducts.slice(0, visibleProducts ? visibleProducts.length : 5);
renderProducts();
calculateListHeight();
});