From 33e4afc00912b0f213a6654f8ca52719f18d81fb Mon Sep 17 00:00:00 2001 From: Rafael Foster Date: Mon, 27 Apr 2026 21:53:18 -0300 Subject: [PATCH] Refine calendar icon picker --- public/locales/ar.json | 2 +- public/locales/el.json | 2 +- public/locales/en.json | 2 +- public/locales/es.json | 2 +- public/locales/fr.json | 2 +- public/locales/hi.json | 2 +- public/locales/it.json | 2 +- public/locales/ja.json | 2 +- public/locales/pt.json | 2 +- public/locales/ru.json | 2 +- public/locales/sv.json | 2 +- public/locales/tr.json | 2 +- public/locales/uk.json | 2 +- public/locales/zh.json | 2 +- public/pages/calendar.js | 78 +++++++++++++++++++++++++++---- public/styles/calendar.css | 96 ++++++++++++++++++++++++++++++++++++-- public/sw.js | 8 ++-- 17 files changed, 181 insertions(+), 29 deletions(-) diff --git a/public/locales/ar.json b/public/locales/ar.json index 86517da..208e6e2 100644 --- a/public/locales/ar.json +++ b/public/locales/ar.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/el.json b/public/locales/el.json index 2adff64..3766bb8 100644 --- a/public/locales/el.json +++ b/public/locales/el.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/en.json b/public/locales/en.json index fc3cb6a..99dbc67 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -805,7 +805,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/es.json b/public/locales/es.json index 0a0ab1d..3b40e92 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/fr.json b/public/locales/fr.json index 95164a3..70f6310 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/hi.json b/public/locales/hi.json index 5f38fb0..062c3dd 100644 --- a/public/locales/hi.json +++ b/public/locales/hi.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/it.json b/public/locales/it.json index f316596..6bd7786 100644 --- a/public/locales/it.json +++ b/public/locales/it.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/ja.json b/public/locales/ja.json index dbda8e5..00e5874 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/pt.json b/public/locales/pt.json index 82e226f..f0d49cc 100644 --- a/public/locales/pt.json +++ b/public/locales/pt.json @@ -864,7 +864,7 @@ "offset1week": "1 semana antes", "offset2weeks": "2 semanas antes", "offsetCustom": "Personalizado...", - "customAmountLabel": "Quantidade", + "customAmountLabel": "Número", "customUnitLabel": "Unidade", "customMinutes": "Minutos", "customHours": "Horas", diff --git a/public/locales/ru.json b/public/locales/ru.json index 4590170..32fe2b2 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/sv.json b/public/locales/sv.json index b16347b..0d8cd69 100644 --- a/public/locales/sv.json +++ b/public/locales/sv.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/tr.json b/public/locales/tr.json index 1d3352e..0fcf71b 100644 --- a/public/locales/tr.json +++ b/public/locales/tr.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/uk.json b/public/locales/uk.json index a124847..7cb3a5f 100644 --- a/public/locales/uk.json +++ b/public/locales/uk.json @@ -805,7 +805,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/locales/zh.json b/public/locales/zh.json index 597fb3e..31b8337 100644 --- a/public/locales/zh.json +++ b/public/locales/zh.json @@ -863,7 +863,7 @@ "offset1week": "1 week before", "offset2weeks": "2 weeks before", "offsetCustom": "Custom...", - "customAmountLabel": "Amount", + "customAmountLabel": "Number", "customUnitLabel": "Unit", "customMinutes": "Minutes", "customHours": "Hours", diff --git a/public/pages/calendar.js b/public/pages/calendar.js index e61a478..5341722 100644 --- a/public/pages/calendar.js +++ b/public/pages/calendar.js @@ -991,6 +991,48 @@ function openEventModal({ mode, event = null, date = null, reminder = null }) { bindDateInputs(panel); + const iconInput = panel.querySelector('#modal-icon'); + const iconTrigger = panel.querySelector('#modal-icon-trigger'); + const iconGrid = panel.querySelector('#modal-icon-grid'); + const selectIcon = (icon) => { + const nextIcon = eventIconName(icon); + if (iconInput) iconInput.value = nextIcon; + if (iconTrigger) { + iconTrigger.dataset.icon = nextIcon; + const iconEl = iconTrigger.querySelector('[data-lucide]'); + iconEl?.setAttribute('data-lucide', nextIcon); + } + iconGrid?.querySelectorAll('.event-icon-picker__option').forEach((btn) => { + const active = btn.dataset.icon === nextIcon; + btn.classList.toggle('event-icon-picker__option--active', active); + btn.setAttribute('aria-checked', active ? 'true' : 'false'); + }); + if (window.lucide) lucide.createIcons(); + }; + + iconTrigger?.addEventListener('click', () => { + if (!iconGrid) return; + iconGrid.hidden = !iconGrid.hidden; + iconTrigger.setAttribute('aria-expanded', iconGrid.hidden ? 'false' : 'true'); + }); + iconGrid?.addEventListener('click', (e) => { + const btn = e.target.closest('.event-icon-picker__option'); + if (!btn) return; + selectIcon(btn.dataset.icon); + iconGrid.hidden = true; + iconTrigger?.setAttribute('aria-expanded', 'false'); + iconTrigger?.focus(); + }); + document.addEventListener('click', function closeIconPicker(e) { + if (!panel.isConnected) { + document.removeEventListener('click', closeIconPicker); + return; + } + if (iconGrid?.hidden || iconGrid?.contains(e.target) || iconTrigger?.contains(e.target)) return; + iconGrid.hidden = true; + iconTrigger?.setAttribute('aria-expanded', 'false'); + }); + const reminderOffset = panel.querySelector('#modal-reminder-offset'); const reminderCustom = panel.querySelector('#modal-reminder-custom'); reminderOffset?.addEventListener('change', () => { @@ -1021,8 +1063,16 @@ function buildEventModalContent({ mode, event, date, reminder = null }) { const endTime = isEdit && event.end_datetime && event.end_datetime.length > 10 ? localTime(event.end_datetime) : '10:00'; const selectedIcon = eventIconName(isEdit ? event.icon : 'calendar'); - const iconOpts = EVENT_ICONS.map((icon) => - `` + const iconButtons = EVENT_ICONS.map((icon) => + `` ).join(''); const userOpts = [ @@ -1033,16 +1083,28 @@ function buildEventModalContent({ mode, event, date, reminder = null }) { ].join(''); return ` -