feat(ecommerce): release Ari Shopping Frontend v2.1 real catalog
Build and Push Frontend / build (push) Successful in 1m21s
Build and Push Frontend / build (push) Successful in 1m21s
This commit is contained in:
@@ -1,132 +1 @@
|
||||
:root {
|
||||
--bg: #fcfafc;
|
||||
--surface: #ffffff;
|
||||
--surface-2: #f7f1f7;
|
||||
--line: #ece4ef;
|
||||
--text: #201726;
|
||||
--muted: #746a79;
|
||||
--pink: #ff4f98;
|
||||
--pink-dark: #ec2f80;
|
||||
--purple: #8e46e8;
|
||||
--shadow: 0 18px 48px rgba(39, 22, 49, 0.11);
|
||||
--shadow-soft: 0 10px 28px rgba(37, 20, 46, 0.07);
|
||||
--container: 1200px;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
html { scroll-behavior: smooth; }
|
||||
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
|
||||
a { color: inherit; text-decoration: none; }
|
||||
button, input, select { font: inherit; }
|
||||
button { cursor: pointer; color: inherit; }
|
||||
img { display: block; max-width: 100%; }
|
||||
[hidden] { display:none !important; }
|
||||
.container { width: min(calc(100% - 40px), var(--container)); margin: 0 auto; }
|
||||
.topbar { height:34px; display:flex; align-items:center; justify-content:center; padding:0 14px; color:#fff; font-size:12px; font-weight:700; background:linear-gradient(90deg,var(--pink),var(--purple)); }
|
||||
.site-header { position:sticky; top:0; z-index:50; background:rgba(252,250,252,.94); backdrop-filter:blur(16px); border-bottom:1px solid var(--line); }
|
||||
.header-grid { min-height:92px; display:grid; grid-template-columns:280px 1fr auto; align-items:center; gap:24px; }
|
||||
.brand { display:inline-flex; align-items:center; gap:16px; }
|
||||
.brand-logo { width:72px; height:72px; border-radius:50%; object-fit:cover; box-shadow:var(--shadow-soft); border:3px solid #fff; }
|
||||
.brand-copy strong { display:block; font-size:22px; line-height:1; }
|
||||
.brand-copy span { display:block; margin-top:6px; color:var(--muted); font-size:12px; }
|
||||
.main-nav { display:flex; justify-content:center; align-items:center; gap:14px; flex-wrap:wrap; }
|
||||
.main-nav button { border:0; background:transparent; padding:10px 0; color:var(--muted); font-size:14px; }
|
||||
.main-nav button:hover, .main-nav button.active { color:var(--pink-dark); }
|
||||
.header-actions { display:flex; align-items:center; gap:12px; }
|
||||
.ghost-btn,.pill-btn,.primary-btn,.white-btn,.link-btn,.primary-small { border:0; border-radius:999px; transition:transform .15s ease, background .2s ease, color .2s ease; }
|
||||
.ghost-btn { height:44px; padding:0 18px; background:#fff; border:1px solid var(--line); }
|
||||
.ghost-btn:hover { background:#faf7fb; }
|
||||
.pill-btn { display:inline-flex; align-items:center; gap:10px; height:46px; padding:0 18px; background:linear-gradient(90deg,var(--pink),var(--purple)); color:#fff; font-weight:700; box-shadow:var(--shadow-soft); }
|
||||
.pill-btn span { display:inline-grid; place-items:center; min-width:24px; height:24px; padding:0 6px; border-radius:999px; background:rgba(255,255,255,.22); font-size:12px; }
|
||||
.search-row { display:grid; grid-template-columns:1fr auto; gap:10px; padding:0 0 16px; }
|
||||
.search-row input { height:48px; border-radius:999px; border:1px solid var(--line); background:#fff; padding:0 16px; outline:none; }
|
||||
.search-row input:focus { border-color:var(--pink); box-shadow:0 0 0 4px rgba(255,79,152,.10); }
|
||||
.hero { display:grid; grid-template-columns:.95fr 1.05fr; gap:48px; align-items:center; padding:64px 0 84px; }
|
||||
.eyebrow { display:inline-block; color:var(--pink-dark); font-size:11px; font-weight:900; letter-spacing:.14em; text-transform:uppercase; }
|
||||
.eyebrow.light { color:#ffbad9; }
|
||||
.hero h1 { margin:14px 0 18px; font-size:clamp(52px,6vw,78px); line-height:.98; letter-spacing:-.055em; max-width:540px; }
|
||||
.hero h1 em { color:var(--pink); font-style:italic; font-family:Georgia,serif; font-weight:400; }
|
||||
.hero p { max-width:540px; color:var(--muted); font-size:17px; line-height:1.7; }
|
||||
.hero-actions { display:flex; align-items:center; gap:14px; margin-top:28px; }
|
||||
.primary-btn,.white-btn,.link-btn { display:inline-flex; align-items:center; justify-content:center; min-height:50px; padding:0 22px; font-weight:800; }
|
||||
.primary-btn,.primary-small { background:linear-gradient(90deg,var(--pink),var(--purple)); color:#fff; box-shadow:var(--shadow-soft); }
|
||||
.link-btn { background:transparent; color:var(--text); }
|
||||
.white-btn { background:#fff; color:var(--text); }
|
||||
.primary-btn:hover,.primary-small:hover,.pill-btn:hover,.white-btn:hover { transform:translateY(-1px); }
|
||||
.hero-card { padding:18px; border-radius:36px; background:linear-gradient(180deg,#f2e6f8,#f3eef7); box-shadow:var(--shadow); }
|
||||
.hero-card img { border-radius:28px; width:100%; }
|
||||
.hero-card small { display:block; margin-top:10px; color:var(--muted); font-size:12px; }
|
||||
.benefits { display:grid; grid-template-columns:repeat(3,1fr); gap:18px; padding-bottom:92px; }
|
||||
.benefits article { display:flex; align-items:center; gap:14px; padding:20px 0; border-top:1px solid var(--line); }
|
||||
.icon-dot { width:36px; height:36px; display:grid; place-items:center; border-radius:50%; background:#fff0f7; color:var(--pink); font-weight:900; }
|
||||
.benefits strong,.benefits span { display:block; }
|
||||
.benefits span { color:var(--muted); margin-top:4px; font-size:14px; }
|
||||
.categories,.catalog { padding-bottom:96px; }
|
||||
.section-head { display:flex; align-items:flex-end; justify-content:space-between; gap:24px; margin-bottom:28px; }
|
||||
.section-head h2 { margin:10px 0 8px; font-size:clamp(34px,4.4vw,54px); line-height:1; letter-spacing:-.05em; }
|
||||
.section-head p { margin:0; color:var(--muted); }
|
||||
.section-head a { color:var(--pink-dark); font-weight:800; }
|
||||
.category-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:18px; }
|
||||
.category-card { padding:0; border:0; background:var(--surface); border-radius:26px; overflow:hidden; box-shadow:var(--shadow-soft); text-align:left; }
|
||||
.category-card img { width:100%; aspect-ratio:4/5; object-fit:cover; }
|
||||
.category-card div { padding:16px 18px 18px; }
|
||||
.category-card strong { display:block; font-size:18px; }
|
||||
.category-card span { display:block; margin-top:6px; color:var(--muted); font-size:14px; }
|
||||
.catalog-head { margin-bottom:22px; }
|
||||
.toolbar { display:flex; align-items:center; justify-content:space-between; gap:20px; margin-bottom:24px; }
|
||||
.chips { display:flex; gap:8px; flex-wrap:wrap; }
|
||||
.chip { border:1px solid var(--line); background:#fff; border-radius:999px; padding:10px 14px; font-size:13px; font-weight:700; }
|
||||
.chip.active { background:var(--text); color:#fff; border-color:var(--text); }
|
||||
.toolbar select { height:44px; border-radius:14px; border:1px solid var(--line); background:#fff; padding:0 12px; }
|
||||
.product-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:18px; }
|
||||
.product-card { background:var(--surface); border:1px solid var(--line); border-radius:24px; overflow:hidden; box-shadow:var(--shadow-soft); display:flex; flex-direction:column; }
|
||||
.product-image { padding:0; border:0; background:#fff; overflow:hidden; }
|
||||
.product-image img { width:100%; aspect-ratio:1/1; object-fit:cover; }
|
||||
.product-content { display:flex; flex-direction:column; gap:12px; padding:18px; }
|
||||
.product-tags { display:flex; gap:8px; flex-wrap:wrap; }
|
||||
.tag { display:inline-flex; align-items:center; min-height:26px; padding:0 10px; border-radius:999px; background:#f7f1f7; color:var(--muted); font-size:12px; font-weight:700; }
|
||||
.product-title { border:0; background:transparent; padding:0; text-align:left; color:var(--text); font-size:20px; font-weight:800; line-height:1.15; }
|
||||
.product-description { margin:0; color:var(--muted); font-size:14px; line-height:1.6; display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
|
||||
.product-actions { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:auto; }
|
||||
.primary-small { min-height:42px; padding:0 16px; font-weight:800; }
|
||||
.empty-state { padding:36px; background:#fff; border:1px dashed var(--line); border-radius:24px; text-align:center; }
|
||||
.social-band { padding:72px 0; background:linear-gradient(135deg,#6a165f,#180f23); color:#fff; }
|
||||
.social-inner { display:flex; align-items:center; justify-content:space-between; gap:24px; }
|
||||
.social-band h2 { margin:10px 0 0; font-size:clamp(34px,4vw,52px); line-height:1; letter-spacing:-.04em; max-width:760px; }
|
||||
.site-footer { background:#171120; color:#fff; }
|
||||
.footer-grid { min-height:116px; display:flex; align-items:center; justify-content:space-between; gap:24px; }
|
||||
.footer-brand { display:inline-flex; align-items:center; gap:16px; }
|
||||
.footer-brand img { width:68px; height:68px; border-radius:50%; object-fit:cover; }
|
||||
.footer-brand strong,.footer-brand span { display:block; }
|
||||
.footer-brand span { color:#d8cfdd; font-size:13px; margin-top:6px; }
|
||||
.footer-meta { color:#d8cfdd; font-size:13px; }
|
||||
.backdrop { position:fixed; inset:0; z-index:90; background:rgba(24,12,28,.56); backdrop-filter:blur(4px); }
|
||||
.drawer { position:fixed; top:0; right:0; z-index:95; width:min(420px,100%); height:100dvh; display:grid; grid-template-rows:auto 1fr auto; background:#fff; box-shadow:-24px 0 60px rgba(20,10,25,.18); transform:translateX(105%); transition:transform .22s ease; }
|
||||
.drawer.open { transform:translateX(0); }
|
||||
.drawer-header,.drawer-footer { padding:22px; border-bottom:1px solid var(--line); }
|
||||
.drawer-header { display:flex; justify-content:space-between; align-items:center; }
|
||||
.drawer-header h3 { margin:8px 0 0; font-size:28px; }
|
||||
.drawer-body { padding:18px 22px; overflow:auto; }
|
||||
.drawer-footer { border-top:1px solid var(--line); border-bottom:0; display:grid; gap:12px; }
|
||||
.full { width:100%; }
|
||||
.cart-empty { border:1px dashed var(--line); border-radius:18px; padding:20px; text-align:center; color:var(--muted); }
|
||||
.cart-line { display:grid; grid-template-columns:76px 1fr auto; gap:12px; align-items:start; margin-bottom:14px; }
|
||||
.cart-line img { width:76px; height:76px; border-radius:16px; object-fit:cover; }
|
||||
.cart-line strong,.cart-line span,.cart-line small { display:block; }
|
||||
.cart-line small { color:var(--muted); margin-top:6px; }
|
||||
.qty { display:inline-flex; align-items:center; gap:8px; margin-top:10px; }
|
||||
.qty button { width:28px; height:28px; border-radius:50%; border:1px solid var(--line); background:#fff; }
|
||||
.remove-btn { border:0; background:transparent; color:var(--pink-dark); font-weight:800; padding:6px 0; }
|
||||
.product-dialog { width:min(920px,calc(100% - 24px)); border:0; border-radius:28px; padding:0; box-shadow:0 30px 90px rgba(20,10,25,.28); }
|
||||
.product-dialog::backdrop { background:rgba(20,10,25,.56); backdrop-filter:blur(4px); }
|
||||
.dialog-close { position:absolute; top:14px; right:14px; width:42px; height:42px; border:0; border-radius:50%; background:#fff; box-shadow:var(--shadow-soft); font-size:28px; line-height:1; }
|
||||
.dialog-layout { display:grid; grid-template-columns:1fr .95fr; }
|
||||
.dialog-layout img { width:100%; height:100%; min-height:520px; object-fit:cover; }
|
||||
.dialog-copy { padding:44px 34px 34px; }
|
||||
.dialog-copy h3 { margin:12px 0 14px; font-size:38px; line-height:1.04; letter-spacing:-.04em; }
|
||||
.dialog-copy p { color:var(--muted); line-height:1.7; }
|
||||
.dialog-details { display:grid; gap:12px; margin:20px 0 24px; }
|
||||
.dialog-details div { padding:14px 16px; border-radius:18px; background:#faf7fb; border:1px solid var(--line); }
|
||||
.dialog-details strong { display:block; font-size:12px; color:var(--pink-dark); text-transform:uppercase; letter-spacing:.1em; }
|
||||
.dialog-actions { display:flex; flex-wrap:wrap; gap:10px; }
|
||||
@media (max-width: 1100px) { .header-grid { grid-template-columns:1fr; padding:18px 0; } .main-nav { justify-content:flex-start; } .hero,.dialog-layout { grid-template-columns:1fr; } .benefits,.category-grid,.product-grid { grid-template-columns:repeat(2,1fr); } .social-inner,.footer-grid,.section-head,.toolbar { flex-direction:column; align-items:flex-start; } }
|
||||
@media (max-width: 640px) { .container { width:min(calc(100% - 24px), var(--container)); } .topbar { font-size:11px; text-align:center; } .brand-copy span { display:none; } .hero { padding-top:42px; } .hero h1 { font-size:46px; } .hero-actions { flex-direction:column; align-items:flex-start; } .benefits,.category-grid,.product-grid { grid-template-columns:1fr; } .product-title { font-size:18px; } .dialog-copy { padding:26px 20px 22px; } .dialog-copy h3 { font-size:30px; } }
|
||||
/* CSS integrado en index.html para evitar fallas de carga. */
|
||||
|
||||
@@ -1,25 +1 @@
|
||||
(() => {
|
||||
const state = { products: [], store: null, category: 'Todos', collection: '', query: '', sort: 'featured', cart: JSON.parse(localStorage.getItem('ari-shopping-cart-v2.2') || '{}') };
|
||||
const $ = (sel, root = document) => root.querySelector(sel);
|
||||
const $$ = (sel, root = document) => [...root.querySelectorAll(sel)];
|
||||
const els = { productGrid: $('#productGrid'), template: $('#productTemplate'), summary: $('#catalogSummary'), chips: $('#filterChips'), empty: $('#emptyState'), reset: $('#resetFilters'), sort: $('#sortSelect'), searchToggle: $('#searchToggle'), searchClose: $('#searchClose'), searchRow: $('#searchRow'), searchInput: $('#searchInput'), cartCount: $('#cartCount'), cartOpen: $('#cartOpen'), cartClose: $('#cartClose'), cartDrawer: $('#cartDrawer'), cartItems: $('#cartItems'), clearCart: $('#clearCart'), checkoutBtn: $('#checkoutBtn'), backdrop: $('#backdrop'), dialog: $('#productDialog'), dialogClose: $('#dialogClose'), dialogContent: $('#dialogContent') };
|
||||
const normalize = (v) => String(v || '').toLowerCase().normalize('NFD').replace(/[\u0300-\u036f]/g, '');
|
||||
const persist = () => localStorage.setItem('ari-shopping-cart-v2.2', JSON.stringify(state.cart));
|
||||
const productById = (id) => state.products.find((p) => p.id === id);
|
||||
async function loadData() { const [storeRes, productsRes] = await Promise.all([fetch('data/store.json', { cache: 'no-store' }), fetch('data/products.json', { cache: 'no-store' })]); state.store = await storeRes.json(); const catalog = await productsRes.json(); state.products = catalog.products || []; buildChips(); render(); }
|
||||
function buildChips() { const cats = ['Todos', ...new Set(state.products.map((p) => p.category))]; els.chips.innerHTML = cats.map((cat) => `<button class="chip ${state.category === cat && !state.collection ? 'active' : ''}" data-chip-cat="${cat}">${cat}</button>`).join(''); }
|
||||
function filtered() { const query = normalize(state.query); return state.products.filter((p) => { if (state.category !== 'Todos' && p.category !== state.category) return false; if (state.collection && p.collection !== state.collection) return false; if (!query) return true; return normalize(`${p.name} ${p.category} ${p.collection} ${p.description}`).includes(query); }).sort((a, b) => { if (state.sort === 'name') return a.name.localeCompare(b.name, 'es'); if (state.sort === 'new') return Number(Boolean(b.new)) - Number(Boolean(a.new)); return Number(Boolean(b.featured)) - Number(Boolean(a.featured)) || a.name.localeCompare(b.name, 'es'); }); }
|
||||
function renderProducts() { const list = filtered(); els.summary.textContent = `${list.length} productos disponibles para consultar.`; els.empty.hidden = list.length > 0; els.productGrid.innerHTML = ''; list.forEach((product) => { const frag = els.template.content.cloneNode(true); $('.product-card', frag).dataset.id = product.id; $('img', frag).src = product.image; $('img', frag).alt = product.name; $('.category', frag).textContent = product.category; $('.collection', frag).textContent = product.collection; $('.product-title', frag).textContent = product.name; $('.product-description', frag).textContent = product.description; $$('.product-open', frag).forEach((btn) => btn.addEventListener('click', () => openDialog(product.id))); $('.add-product', frag).addEventListener('click', () => addToCart(product.id)); els.productGrid.appendChild(frag); }); }
|
||||
function renderCart() { const entries = Object.entries(state.cart).map(([id, qty]) => ({ product: productById(id), qty: Number(qty) })).filter((item) => item.product && item.qty > 0); els.cartCount.textContent = String(entries.reduce((sum, item) => sum + item.qty, 0)); if (!entries.length) { els.cartItems.innerHTML = '<div class="cart-empty"><strong>Tu pedido está vacío</strong><p>Agrega productos para consultarlos por WhatsApp.</p></div>'; return; } els.cartItems.innerHTML = entries.map(({ product, qty }) => `<article class="cart-line" data-id="${product.id}"><img src="${product.image}" alt="${product.name}"><div><strong>${product.name}</strong><small>${product.collection} · Consultar disponibilidad</small><div class="qty"><button type="button" data-minus>−</button><span>${qty}</span><button type="button" data-plus>+</button></div></div><button class="remove-btn" type="button" data-remove>Quitar</button></article>`).join(''); $$('[data-minus]', els.cartItems).forEach((btn) => btn.addEventListener('click', () => changeQty(btn.closest('[data-id]').dataset.id, -1))); $$('[data-plus]', els.cartItems).forEach((btn) => btn.addEventListener('click', () => changeQty(btn.closest('[data-id]').dataset.id, 1))); $$('[data-remove]', els.cartItems).forEach((btn) => btn.addEventListener('click', () => removeFromCart(btn.closest('[data-id]').dataset.id))); }
|
||||
function render() { buildChips(); renderProducts(); renderCart(); }
|
||||
function addToCart(id) { state.cart[id] = Number(state.cart[id] || 0) + 1; persist(); renderCart(); openCart(); }
|
||||
function changeQty(id, delta) { const next = Number(state.cart[id] || 0) + delta; if (next <= 0) delete state.cart[id]; else state.cart[id] = next; persist(); renderCart(); }
|
||||
function removeFromCart(id) { delete state.cart[id]; persist(); renderCart(); }
|
||||
function openCart() { els.cartDrawer.classList.add('open'); els.cartDrawer.setAttribute('aria-hidden', 'false'); els.backdrop.hidden = false; }
|
||||
function closeCart() { els.cartDrawer.classList.remove('open'); els.cartDrawer.setAttribute('aria-hidden', 'true'); els.backdrop.hidden = true; }
|
||||
function openDialog(id) { const p = productById(id); if (!p) return; els.dialogContent.innerHTML = `<div class="dialog-layout"><img src="${p.image}" alt="${p.name}"><div class="dialog-copy"><span class="eyebrow">${p.category} · ${p.collection}</span><h3>${p.name}</h3><p>${p.description}</p><div class="dialog-details"><div><strong>Precio</strong><span>Consultar disponibilidad</span></div><div><strong>Entrega</strong><span>Coordinar con Ari Shopping</span></div>${p.dimensions ? `<div><strong>Medidas</strong><span>${p.dimensions}</span></div>` : ''}</div><div class="dialog-actions"><button id="dialogAdd" class="primary-btn" type="button">Agregar al pedido</button><a class="ghost-btn" target="_blank" rel="noopener" href="${state.store.whatsappUrl}">Consultar por WhatsApp</a></div></div></div>`; $('#dialogAdd', els.dialogContent).addEventListener('click', () => { addToCart(id); els.dialog.close(); }); els.dialog.showModal(); }
|
||||
function buildWhatsAppMessage() { const entries = Object.entries(state.cart).map(([id, qty]) => ({ product: productById(id), qty: Number(qty) })).filter((item) => item.product && item.qty > 0); if (!entries.length) return 'Hola Ari Shopping 👋'; return ['Hola Ari Shopping 👋', 'Quiero consultar disponibilidad para los siguientes productos:', '', ...entries.map((item) => `• ${item.qty} x ${item.product.name}`), '', 'Nombre:', 'Ciudad:', 'Forma de entrega:'].join('\n'); }
|
||||
function checkout() { const text = encodeURIComponent(buildWhatsAppMessage()); window.open(`${state.store.whatsappUrl}?text=${text}`, '_blank', 'noopener'); }
|
||||
function bind() { document.addEventListener('click', (event) => { const nav = event.target.closest('[data-nav]'); if (nav) { state.category = nav.dataset.nav; state.collection = ''; render(); } const col = event.target.closest('[data-col]'); if (col) { state.category = 'Todos'; state.collection = col.dataset.col; render(); } const cat = event.target.closest('[data-cat]'); if (cat) { state.category = cat.dataset.cat; state.collection = ''; render(); } const chip = event.target.closest('[data-chip-cat]'); if (chip) { state.category = chip.dataset.chipCat; state.collection = ''; render(); } }); els.sort.addEventListener('change', () => { state.sort = els.sort.value; renderProducts(); }); els.searchToggle.addEventListener('click', () => { els.searchRow.hidden = false; els.searchInput.focus(); }); els.searchClose.addEventListener('click', () => { els.searchRow.hidden = true; state.query = ''; els.searchInput.value = ''; renderProducts(); }); els.searchInput.addEventListener('input', () => { state.query = els.searchInput.value; renderProducts(); }); els.cartOpen.addEventListener('click', openCart); els.cartClose.addEventListener('click', closeCart); els.backdrop.addEventListener('click', closeCart); els.clearCart.addEventListener('click', () => { state.cart = {}; persist(); renderCart(); }); els.checkoutBtn.addEventListener('click', checkout); els.reset.addEventListener('click', () => { state.category = 'Todos'; state.collection = ''; state.query = ''; render(); }); els.dialogClose.addEventListener('click', () => els.dialog.close()); }
|
||||
bind(); loadData().catch((err) => { console.error(err); els.summary.textContent = 'No se pudo cargar el catálogo.'; els.empty.hidden = false; });
|
||||
})();
|
||||
// JavaScript integrado en index.html para evitar fallas de carga.
|
||||
|
||||
Reference in New Issue
Block a user