diff --git a/config.php b/config.php index 2ff0140..7d7576b 100644 --- a/config.php +++ b/config.php @@ -1,7 +1,7 @@ { t.classList.toggle('active', t.dataset.filter === filter); }); + let visibleCount = 0; grid.querySelectorAll('.gallery-item').forEach(item => { const url = item.dataset.url || ''; const type = fileType(url); const show = filter === 'all' || type === filter; item.style.display = show ? '' : 'none'; + if (show) visibleCount++; }); + // Hide section headers when no items in that section are visible + grid.querySelectorAll('[data-section]:not(.gallery-item)').forEach(hdr => { + const section = hdr.dataset.section; + const hasVisible = !!grid.querySelector(`.gallery-item[data-section="${section}"]:not([style*="display: none"])`); + hdr.style.display = hasVisible ? '' : 'none'; + }); + // Show/hide the empty-filter placeholder + let placeholder = grid.querySelector('.gallery-filter-empty'); + if (visibleCount === 0 && total > 0) { + if (!placeholder) { + placeholder = document.createElement('div'); + placeholder.className = 'gallery-filter-empty col-span-full text-center py-16'; + const icons = { image: 'ph-image', audio: 'ph-music-note', pdf: 'ph-file-pdf' }; + const icon = icons[filter] || 'ph-folder-open'; + placeholder.innerHTML = `

no ${filter} assets

`; + grid.appendChild(placeholder); + } + placeholder.style.display = ''; + } else if (placeholder) { + placeholder.style.display = 'none'; + } }; document.querySelectorAll('#gallery-tabs .gallery-tab').forEach(t => { t.onclick = () => applyFilter(t.dataset.filter); @@ -137,15 +160,11 @@ export async function openGallery() { let html = ''; if (orphaned.length) { - html += `
orphaned (not used by any card)
`; + html += `
orphaned (not used by any card)
`; html += orphaned.map(f => ` -