From 53bff8d618e04ef20e722f8cebe807c66b8734d3 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 6 Oct 2026 11:08:10 -0600 Subject: [PATCH] feat(ui): sustituir emojis por iconografia vectorial SVG minimalista y elegante para alimentos y bebidas --- public/index.html | 24 ++-- public/js/app.js | 49 ++++++-- public/js/food-icons.js | 241 ++++++++++++++++++++++++++++++++++++++++ public/js/pos.js | 38 ++++--- public/pos.html | 21 ++-- 5 files changed, 325 insertions(+), 48 deletions(-) create mode 100644 public/js/food-icons.js diff --git a/public/index.html b/public/index.html index 080c077..37ad5a7 100644 --- a/public/index.html +++ b/public/index.html @@ -1677,22 +1677,13 @@ -
-
- - -
-
- -
- - - - - - - - +
+ + +
+
+
+
@@ -2297,6 +2288,7 @@ + diff --git a/public/js/app.js b/public/js/app.js index 504aa26..f281f3c 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -739,9 +739,12 @@ function renderCategories() { `; for (const cat of categories) { + const iconBadge = window.SiboPayIcons + ? window.SiboPayIcons.getFoodIconBadge(cat.icono, cat.nombre, 'inline') + : `${cat.icono || '🍽️'}`; html += ` - `; } @@ -786,9 +789,15 @@ function renderProducts() { ? 'AGOTADO' : ''; + const iconHtml = window.SiboPayIcons + ? window.SiboPayIcons.getFoodIconBadge(prod.icono, prod.nombre, 'card') + : `
${prod.icono || '🥪'}
`; + return `
-
${prod.icono || '🥪'}
+
+ ${iconHtml} +
${prod.cumple_mep ? 'MEP Saludable' : ''} @@ -889,11 +898,17 @@ function renderCartModalItems() { list.innerHTML = cart.map((item, idx) => { const subtotal = item.product.precio_colones * item.cantidad; total += subtotal; + const itemBadge = window.SiboPayIcons + ? window.SiboPayIcons.getFoodIconBadge(item.product.icono, item.product.nombre, 'badge') + : ''; return `
-
- ${item.product.icono ? `${item.product.icono} ` : ''}${item.product.nombre} -
₡${item.product.precio_colones.toLocaleString('es-CR')} c/u
+
+ ${itemBadge} +
+ ${item.product.nombre} +
₡${item.product.precio_colones.toLocaleString('es-CR')} c/u
+
@@ -3246,11 +3261,17 @@ function renderAdminInventory(list) { statusPill = `${p.stock} unid.`; } + const iconBadge = window.SiboPayIcons + ? window.SiboPayIcons.getFoodIconBadge(p.icono, p.nombre, 'badge') + : `
${p.icono || '🥪'}
`; + return `
-
${p.icono || '🥪'}
+
+ ${iconBadge} +
${p.nombre} @@ -4483,13 +4504,17 @@ function openCreateProductModal() { document.getElementById('adminProdId').value = ''; document.getElementById('adminProdNombre').value = ''; document.getElementById('adminProdPrecio').value = ''; - document.getElementById('adminProdIcono').value = '🥪'; + document.getElementById('adminProdIcono').value = 'sandwich'; document.getElementById('adminProdDescripcion').value = ''; document.getElementById('adminProdControlStock').checked = true; toggleStockInput(true); document.getElementById('adminProdStock').value = '15'; document.getElementById('adminProdMep').value = '1'; + if (window.SiboPayIcons) { + window.SiboPayIcons.renderIconPicker('adminProdIconPickerList', 'adminProdIcono', 'adminProdIconPreview', 'sandwich'); + } + const btnDel = document.getElementById('btnDeleteProduct'); if (btnDel) btnDel.style.display = 'none'; @@ -4515,7 +4540,7 @@ function openEditProductModal(prodId) { document.getElementById('adminProdId').value = prod.id; document.getElementById('adminProdNombre').value = prod.nombre || ''; document.getElementById('adminProdPrecio').value = prod.precio_colones || 0; - document.getElementById('adminProdIcono').value = prod.icono || '🥪'; + document.getElementById('adminProdIcono').value = prod.icono || 'sandwich'; document.getElementById('adminProdDescripcion').value = prod.descripcion || ''; const hasControl = prod.control_stock === 1; @@ -4524,6 +4549,10 @@ function openEditProductModal(prodId) { document.getElementById('adminProdStock').value = prod.stock !== undefined ? prod.stock : 0; document.getElementById('adminProdMep').value = (prod.cumple_mep !== undefined ? prod.cumple_mep : 1); + if (window.SiboPayIcons) { + window.SiboPayIcons.renderIconPicker('adminProdIconPickerList', 'adminProdIcono', 'adminProdIconPreview', prod.icono || 'sandwich'); + } + const btnDel = document.getElementById('btnDeleteProduct'); if (btnDel) btnDel.style.display = 'inline-block'; @@ -4548,7 +4577,7 @@ async function submitAdminProduct(e) { const nombre = document.getElementById('adminProdNombre').value.trim(); const categoria_id = parseInt(document.getElementById('adminProdCategoria').value, 10); const precio_colones = parseInt(document.getElementById('adminProdPrecio').value, 10); - const icono = document.getElementById('adminProdIcono').value.trim() || '🥪'; + const icono = document.getElementById('adminProdIcono').value.trim() || 'sandwich'; const descripcion = document.getElementById('adminProdDescripcion').value.trim(); const control_stock = document.getElementById('adminProdControlStock').checked ? 1 : 0; const stock = parseInt(document.getElementById('adminProdStock').value, 10) || 0; diff --git a/public/js/food-icons.js b/public/js/food-icons.js new file mode 100644 index 0000000..c1b87a3 --- /dev/null +++ b/public/js/food-icons.js @@ -0,0 +1,241 @@ +/** + * SiboPay Food & Beverage Vector Icons (SVG) + * Iconografía vectorial fina, minimalista y elegante para productos escolares y soda + */ + +(function (window) { + 'use strict'; + + const FOOD_ICONS = { + 'sandwich': { + label: 'Sandwich / Panini', + svg: '' + }, + 'croissant': { + label: 'Empanada / Repostería', + svg: '' + }, + 'utensils': { + label: 'Plato Fuerte / Almuerzo', + svg: '' + }, + 'cup-soda': { + label: 'Bebida / Fresco Natural', + svg: '' + }, + 'milk': { + label: 'Leche / Lácteos', + svg: '' + }, + 'coffee': { + label: 'Café / Infusión Caliente', + svg: '' + }, + 'apple': { + label: 'Fruta / Saludable', + svg: '' + }, + 'bowl': { + label: 'Bowl / Ensalada / Sopa', + svg: '' + }, + 'cookie': { + label: 'Galleta / Snack', + svg: '' + }, + 'pizza': { + label: 'Pizza / Taco / Rápida', + svg: '' + }, + 'meat': { + label: 'Carne / Pollo / Proteína', + svg: '' + }, + 'wheat': { + label: 'Cereal / Granola / Avena', + svg: '' + }, + 'ice-cream': { + label: 'Postre / Gelatina / Helado', + svg: '' + }, + 'store': { + label: 'Todos / Menú Completo', + svg: '' + } + }; + + // Mapeo automático de emojis antiguos a iconos SVG elegantes + const EMOJI_TO_KEY = { + '🥪': 'sandwich', + '🥟': 'croissant', + '🌮': 'pizza', + '🍳': 'utensils', + '🍗': 'meat', + '🍛': 'utensils', + '🍹': 'cup-soda', + '🥤': 'cup-soda', + '🧃': 'cup-soda', + '🥛': 'milk', + '🍉': 'apple', + '🥣': 'bowl', + '🌾': 'wheat', + '🍮': 'ice-cream', + '🍎': 'apple', + '🍕': 'pizza', + '🥗': 'bowl', + '🍪': 'cookie', + '🍽️': 'utensils', + '☕': 'coffee', + '🥩': 'meat', + '🍦': 'ice-cream', + '🥑': 'apple', + '🥐': 'croissant', + '🍞': 'sandwich', + '🍔': 'sandwich' + }; + + /** + * Resuelve el identificador de icono SVG a partir de una clave, emoji o nombre de producto + */ + function resolveIconKey(rawInput, fallbackName) { + if (!rawInput && !fallbackName) return 'sandwich'; + const input = String(rawInput || '').trim(); + + // 1. Si coincide directamente con una clave conocida + if (FOOD_ICONS[input]) return input; + + // 2. Si coincide con un emoji mapeado + if (EMOJI_TO_KEY[input]) return EMOJI_TO_KEY[input]; + + // 3. Analizar palabras clave en el nombre del producto + const text = (String(fallbackName || '') + ' ' + input).toLowerCase(); + if (text.includes('empanada') || text.includes('pastel') || text.includes('reposter') || text.includes('croissant')) return 'croissant'; + if (text.includes('sandwich') || text.includes('emparedado') || text.includes('pan') || text.includes('tostada')) return 'sandwich'; + if (text.includes('fresco') || text.includes('jugo') || text.includes('te frio') || text.includes('té') || text.includes('gaseosa') || text.includes('bebida') || text.includes('refresco')) return 'cup-soda'; + if (text.includes('leche') || text.includes('batido')) return 'milk'; + if (text.includes('cafe') || text.includes('café') || text.includes('chocolate caliente')) return 'coffee'; + if (text.includes('fruta') || text.includes('manzana') || text.includes('sandia') || text.includes('sandía') || text.includes('pina') || text.includes('piña')) return 'apple'; + if (text.includes('ensalada') || text.includes('sopa') || text.includes('bowl') || text.includes('yogurt')) return 'bowl'; + if (text.includes('pinto') || text.includes('casado') || text.includes('almuerzo') || text.includes('arroz') || text.includes('plato')) return 'utensils'; + if (text.includes('pollo') || text.includes('carne') || text.includes('bistec') || text.includes('chuleta')) return 'meat'; + if (text.includes('pizza') || text.includes('taco') || text.includes('wrap')) return 'pizza'; + if (text.includes('galleta') || text.includes('snack') || text.includes('barra') || text.includes('cereal') || text.includes('avena')) return 'cookie'; + if (text.includes('gelatina') || text.includes('helado') || text.includes('postre') || text.includes('flan')) return 'ice-cream'; + + return 'sandwich'; + } + + /** + * Retorna el SVG puro del icono + */ + function getFoodSvg(rawInput, fallbackName, size = 22) { + const key = resolveIconKey(rawInput, fallbackName); + const item = FOOD_ICONS[key] || FOOD_ICONS['sandwich']; + return item.svg.replace(' + ${svg} +
+ `; + } + + if (variant === 'badge') { + const svg = getFoodSvg(key, null, 17); + return ` +
+ ${svg} +
+ `; + } + + if (variant === 'inline') { + const svg = getFoodSvg(key, null, 15); + return `${svg}`; + } + + return getFoodSvg(key, fallbackName, 20); + } + + /** + * Renderiza el selector de iconos finos para los modales de creación/edición de productos + */ + function renderIconPicker(containerId, inputId, previewId, currentKey) { + const container = document.getElementById(containerId); + const input = document.getElementById(inputId); + const preview = document.getElementById(previewId); + if (!container) return; + + const resolved = resolveIconKey(currentKey || (input ? input.value : 'sandwich')); + if (input) input.value = resolved; + if (preview) preview.innerHTML = getFoodIconBadge(resolved, null, 'card'); + + const pickerKeys = [ + 'sandwich', 'croissant', 'utensils', 'cup-soda', + 'milk', 'coffee', 'apple', 'bowl', + 'cookie', 'pizza', 'meat', 'ice-cream' + ]; + + container.innerHTML = pickerKeys.map(k => { + const isAct = (k === resolved); + const svg = getFoodSvg(k, null, 18); + const label = FOOD_ICONS[k]?.label || k; + return ` + + `; + }).join(''); + } + + function onPickIcon(key, containerId, inputId, previewId) { + const input = document.getElementById(inputId); + const preview = document.getElementById(previewId); + if (input) input.value = key; + if (preview) preview.innerHTML = getFoodIconBadge(key, null, 'card'); + + const container = document.getElementById(containerId); + if (container) { + container.querySelectorAll('.btn-food-icon-picker').forEach(b => { + b.classList.remove('active'); + b.style.borderColor = 'var(--border)'; + b.style.background = 'var(--card-bg)'; + b.style.color = 'var(--text-muted)'; + }); + const activeBtn = document.getElementById(`btnFoodPick_${key}`); + if (activeBtn) { + activeBtn.classList.add('active'); + activeBtn.style.borderColor = '#0284c7'; + activeBtn.style.background = '#f0f9ff'; + activeBtn.style.color = '#0284c7'; + } + } + } + + // Exportar al ámbito global + window.SiboPayIcons = { + FOOD_ICONS, + resolveIconKey, + getFoodSvg, + getFoodIconBadge, + renderIconPicker, + onPickIcon + }; + +})(window); diff --git a/public/js/pos.js b/public/js/pos.js index a3c02e0..7324eb7 100644 --- a/public/js/pos.js +++ b/public/js/pos.js @@ -157,13 +157,19 @@ async function loadCatalog() { function renderPosCategories() { const bar = document.getElementById('posCategoriesBar'); if (!bar) return; + const storeIcon = window.SiboPayIcons ? window.SiboPayIcons.getFoodIconBadge('store', 'Todos', 'inline') : ''; bar.innerHTML = ` - - ${posCategories.map(c => ` - - `).join('')} + + ${posCategories.map(c => { + const catIcon = window.SiboPayIcons ? window.SiboPayIcons.getFoodIconBadge(c.icono, c.nombre, 'inline') : `${c.icono || '🍽️'} `; + return ` + + `; + }).join('')} `; } @@ -339,7 +345,7 @@ function renderPosProducts(catId) { title="${isFirstMatch ? 'Primer resultado coincidente (pulsa Enter para cobrar)' : ''}" onclick="${isOutOfStock ? `alert('El producto \\'${prod.nombre.replace(/'/g, "\\'")}\\' se encuentra bloqueado o agotado.')` : `addToPosCart(${prod.id})`}"> ${isOutOfStock ? '
BLOQUEADO
' : (isFirstMatch ? '
Enter ↵
' : '')} -
${prod.icono || '🥪'}
+ ${window.SiboPayIcons ? window.SiboPayIcons.getFoodIconBadge(prod.icono, prod.nombre, 'card') : `
${prod.icono || '🥪'}
`}
${prod.nombre}
${prod.cumple_mep ? '🌿 MEP Saludable' : ''} @@ -533,11 +539,17 @@ function updatePosCartUI() { list.innerHTML = posCart.map((item, idx) => { const subtotal = item.product.precio_colones * item.cantidad; total += subtotal; + const itemBadge = window.SiboPayIcons + ? window.SiboPayIcons.getFoodIconBadge(item.product.icono, item.product.nombre, 'badge') + : ''; return `
-
- ${item.product.icono ? `${item.product.icono}` : ''}${item.product.nombre} -
₡${item.product.precio_colones.toLocaleString('es-CR')} c/u
+
+ ${itemBadge} +
+ ${item.product.nombre} +
₡${item.product.precio_colones.toLocaleString('es-CR')} c/u
+
@@ -1255,7 +1267,7 @@ async function loadPreOrders() { list.innerHTML = orders.map(ord => { const hora = new Date(ord.creado_en).toLocaleTimeString('es-CR', { hour: '2-digit', minute: '2-digit' }); const items = Array.isArray(ord.items) ? ord.items : []; - const itemsList = items.map(i => `${i.cantidad}x ${i.icono || '🥪'} ${i.nombre}`).join(', '); + const itemsList = items.map(i => `${i.cantidad}× ${i.nombre}`).join(' • '); const avatarUrl = ord.foto_url || 'https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=150'; return ` @@ -1281,8 +1293,8 @@ async function loadPreOrders() {
-
- 📦 +
+ ${itemsList}
diff --git a/public/pos.html b/public/pos.html index 03677f4..a644de2 100644 --- a/public/pos.html +++ b/public/pos.html @@ -52,10 +52,10 @@
@@ -85,10 +85,10 @@ 🔔 Notificaciones - 👨‍🍳 Admin + Admin - 📱 PWA Estudiante ↗ + PWA Estudiante ↗
@@ -96,18 +96,18 @@
@@ -455,6 +457,7 @@ +