2025-10-15 02:29:21 -05:00
|
|
|
<header class="w-full p-2 fixed top-0 left-0 right-0 z-30">
|
2025-10-15 02:10:24 -05:00
|
|
|
<div class="max-w-7xl mx-auto flex items-center justify-between px-3">
|
|
|
|
|
<div class="flex items-center gap-4">
|
|
|
|
|
<!-- small logo + name -->
|
|
|
|
|
<a href="/" class="flex items-center gap-2 mr-2">
|
|
|
|
|
<div class="w-7 h-7">
|
|
|
|
|
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg" class="w-full h-full">
|
|
|
|
|
<defs><linearGradient id="navg" x1="0" x2="1"><stop offset="0%" stop-color="#06b6d4"/><stop offset="100%" stop-color="#3b82f6"/></linearGradient></defs>
|
|
|
|
|
<circle cx="50" cy="50" r="42" fill="url(#navg)"/>
|
|
|
|
|
<g transform="translate(50,50)"><path d="M-12,-4 L0,-18 L12,-4 L0,12 Z" fill="#fff"/></g>
|
|
|
|
|
</svg>
|
|
|
|
|
</div>
|
|
|
|
|
<span class="text-white font-semibold hidden sm:inline"><%= appName %></span>
|
|
|
|
|
</a>
|
|
|
|
|
<!-- mini guild selector compact -->
|
|
|
|
|
<div class="hidden md:block">
|
2025-10-15 02:23:18 -05:00
|
|
|
<div class="relative inline-block">
|
2025-10-15 02:29:21 -05:00
|
|
|
<button id="miniGuildBtn" class="px-2 py-0.5 rounded-full bg-white/5 text-white text-sm flex items-center gap-2" aria-expanded="false" aria-controls="miniGuildList">
|
2025-10-15 02:23:18 -05:00
|
|
|
<span id="miniGuildName" class="text-sm"><%= selectedGuildName || 'Seleccionar servidor' %></span>
|
|
|
|
|
<svg class="w-3 h-3 text-white/80" viewBox="0 0 20 20" fill="none"><path d="M6 8l4 4 4-4" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
|
|
|
</button>
|
2025-10-15 02:29:21 -05:00
|
|
|
<div id="miniGuildList" class="origin-top-left absolute top-full left-0 mt-2 w-56 bg-white/80 backdrop-blur-md rounded-lg p-1 hidden transition-transform duration-150 z-50" style="max-height:18rem; overflow:auto; background-color: rgba(12,15,18,0.92);">
|
2025-10-15 02:10:24 -05:00
|
|
|
<% if (guilds && guilds.length) { %>
|
2025-10-15 02:29:21 -05:00
|
|
|
<% guilds.forEach(g => { %>
|
|
|
|
|
<div class="p-1 rounded-md hover:bg-white/5 cursor-pointer text-white guild-item flex items-center gap-3" data-id="<%= g.id %>">
|
|
|
|
|
<% if (g.icon) { %>
|
|
|
|
|
<img src="https://cdn.discordapp.com/icons/<%= g.id %>/<%= g.icon %>.png" class="w-5 h-5 rounded-full" alt="icon">
|
|
|
|
|
<% } else { %>
|
|
|
|
|
<div class="w-5 h-5 rounded-full bg-white/8 flex items-center justify-center text-xs text-white">S</div>
|
|
|
|
|
<% } %>
|
|
|
|
|
<div class="flex-1 text-sm truncate pl-1"><%= g.name %></div>
|
|
|
|
|
</div>
|
|
|
|
|
<% }) %>
|
2025-10-15 02:10:24 -05:00
|
|
|
<% } else { %>
|
|
|
|
|
<div class="p-2 text-slate-300">No servers</div>
|
|
|
|
|
<% } %>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="flex items-center gap-4">
|
|
|
|
|
<% if (user) { %>
|
2025-10-15 00:14:08 -05:00
|
|
|
<div class="relative">
|
2025-10-15 02:10:24 -05:00
|
|
|
<button id="userBtn" class="flex items-center gap-2 px-2 py-1 rounded-full hover:bg-white/5 focus:outline-none" aria-expanded="false">
|
|
|
|
|
<% if (user.id && user.avatar) { %>
|
|
|
|
|
<img src="https://cdn.discordapp.com/avatars/<%= user.id %>/<%= user.avatar %>.png" class="w-8 h-8 rounded-full" alt="avatar">
|
2025-10-14 23:45:34 -05:00
|
|
|
<% } else { %>
|
2025-10-15 02:10:24 -05:00
|
|
|
<img src="/assets/images/snap1.svg" class="w-8 h-8 rounded-full" alt="avatar">
|
2025-10-14 23:45:34 -05:00
|
|
|
<% } %>
|
2025-10-15 02:10:24 -05:00
|
|
|
<svg class="w-3 h-3 text-white/80 ml-1" viewBox="0 0 20 20" fill="none"><path d="M6 8l4 4 4-4" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
|
|
|
|
</button>
|
2025-10-15 02:15:23 -05:00
|
|
|
<div id="userMenu" class="origin-top-right absolute right-0 mt-2 w-36 bg-white/80 backdrop-blur-md rounded-md p-2 hidden z-50" style="background-color: rgba(12,15,18,0.9);">
|
2025-10-15 02:10:24 -05:00
|
|
|
<a href="/auth/logout" class="block px-3 py-2 text-sm text-rose-300 hover:bg-white/5 rounded">Log out</a>
|
2025-10-14 23:45:34 -05:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2025-10-15 00:17:59 -05:00
|
|
|
<% } else { %>
|
|
|
|
|
<a href="/auth/discord" class="text-sm text-white/70 px-3 py-2 rounded-md hover:bg-white/5">Entrar</a>
|
|
|
|
|
<% } %>
|
2025-10-14 22:39:14 -05:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
|
|
<div style="height:56px"></div>
|
2025-10-14 23:45:34 -05:00
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
(function(){
|
|
|
|
|
const btn = document.getElementById('miniGuildBtn');
|
|
|
|
|
const list = document.getElementById('miniGuildList');
|
2025-10-15 00:14:08 -05:00
|
|
|
const userBtn = document.getElementById('userBtn');
|
|
|
|
|
const userMenu = document.getElementById('userMenu');
|
|
|
|
|
function openDropdown(el, container) {
|
|
|
|
|
if (!el || !container) return;
|
|
|
|
|
container.classList.remove('hidden');
|
|
|
|
|
// animate in
|
|
|
|
|
requestAnimationFrame(()=>{
|
|
|
|
|
container.classList.remove('scale-95','opacity-0','pointer-events-none');
|
|
|
|
|
container.classList.add('scale-100','opacity-100');
|
|
|
|
|
el.setAttribute('aria-expanded','true');
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function closeDropdown(el, container) {
|
|
|
|
|
if (!el || !container) return;
|
|
|
|
|
container.classList.add('scale-95','opacity-0');
|
|
|
|
|
container.classList.remove('scale-100','opacity-100');
|
|
|
|
|
el.setAttribute('aria-expanded','false');
|
|
|
|
|
// after animation, hide to prevent tab focus
|
|
|
|
|
setTimeout(()=> container.classList.add('hidden','pointer-events-none'), 180);
|
|
|
|
|
}
|
2025-10-15 01:17:46 -05:00
|
|
|
if (btn && list) {
|
|
|
|
|
// ensure the dropdown itself is scrollable when many guilds exist
|
|
|
|
|
list.style.maxHeight = '20rem';
|
|
|
|
|
list.style.overflowY = 'auto';
|
2025-10-15 00:14:08 -05:00
|
|
|
btn.addEventListener('click', (e)=>{
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
const expanded = btn.getAttribute('aria-expanded') === 'true';
|
|
|
|
|
if (expanded) closeDropdown(btn, list); else openDropdown(btn, list);
|
|
|
|
|
});
|
|
|
|
|
Array.from(list.querySelectorAll('.guild-item')).forEach(it=>{
|
|
|
|
|
it.addEventListener('click', ()=>{
|
|
|
|
|
const id = it.getAttribute('data-id');
|
|
|
|
|
if (id) window.location.href = `/dashboard/${id}/overview`;
|
|
|
|
|
});
|
2025-10-15 01:17:46 -05:00
|
|
|
// keyboard activation (Enter / Space)
|
|
|
|
|
it.addEventListener('keydown', (ev)=>{
|
|
|
|
|
if (ev.key === 'Enter' || ev.key === ' ') {
|
|
|
|
|
ev.preventDefault();
|
|
|
|
|
it.click();
|
|
|
|
|
}
|
|
|
|
|
});
|
2025-10-15 00:14:08 -05:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (userBtn && userMenu) {
|
|
|
|
|
userBtn.addEventListener('click', (e)=>{
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
const expanded = userBtn.getAttribute('aria-expanded') === 'true';
|
|
|
|
|
if (expanded) closeDropdown(userBtn, userMenu); else openDropdown(userBtn, userMenu);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// close on outside click or Escape
|
2025-10-14 23:45:34 -05:00
|
|
|
document.addEventListener('click', (e)=>{
|
2025-10-15 00:14:08 -05:00
|
|
|
if (btn && list && !btn.contains(e.target) && !list.contains(e.target)) closeDropdown(btn, list);
|
|
|
|
|
if (userBtn && userMenu && !userBtn.contains(e.target) && !userMenu.contains(e.target)) closeDropdown(userBtn, userMenu);
|
2025-10-14 23:45:34 -05:00
|
|
|
});
|
2025-10-15 00:14:08 -05:00
|
|
|
document.addEventListener('keydown', (e)=>{
|
|
|
|
|
if (e.key === 'Escape') {
|
|
|
|
|
if (btn && list) closeDropdown(btn, list);
|
|
|
|
|
if (userBtn && userMenu) closeDropdown(userBtn, userMenu);
|
|
|
|
|
}
|
2025-10-14 23:45:34 -05:00
|
|
|
});
|
|
|
|
|
})();
|
|
|
|
|
</script>
|
2025-10-15 02:34:21 -05:00
|
|
|
|
|
|
|
|
<!-- Mobile modals -->
|
|
|
|
|
<div id="mobileGuildModal" class="fixed inset-0 bg-black/60 hidden z-50">
|
|
|
|
|
<div class="absolute bottom-0 left-0 right-0 bg-[#1f2933] rounded-t-xl p-4 max-h-[80vh] overflow-auto">
|
|
|
|
|
<div class="flex items-center justify-between mb-3">
|
|
|
|
|
<h3 class="text-white font-medium">Servers</h3>
|
|
|
|
|
<button id="mobileGuildClose" class="text-white/70">Cerrar</button>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="mobileGuildList" class="space-y-2">
|
|
|
|
|
<% if (guilds && guilds.length) { %>
|
|
|
|
|
<% guilds.forEach(g => { %>
|
|
|
|
|
<div class="flex items-center gap-3 p-2 rounded-md hover:bg-white/5 cursor-pointer" data-id="<%= g.id %>">
|
|
|
|
|
<% if (g.icon) { %>
|
|
|
|
|
<img src="https://cdn.discordapp.com/icons/<%= g.id %>/<%= g.icon %>.png" class="w-8 h-8 rounded-full" alt="icon">
|
|
|
|
|
<% } else { %>
|
|
|
|
|
<div class="w-8 h-8 rounded-full bg-white/8"></div>
|
|
|
|
|
<% } %>
|
|
|
|
|
<div class="text-white"><%= g.name %></div>
|
|
|
|
|
</div>
|
|
|
|
|
<% }) %>
|
|
|
|
|
<% } else { %>
|
|
|
|
|
<div class="text-slate-300">No servers</div>
|
|
|
|
|
<% } %>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div id="mobileUserSheet" class="fixed inset-0 bg-black/60 hidden z-50">
|
|
|
|
|
<div class="absolute bottom-0 left-0 right-0 bg-[#1f2933] rounded-t-xl p-4">
|
|
|
|
|
<h3 class="text-white font-medium mb-3">User settings</h3>
|
|
|
|
|
<a href="/dashboard/select-guild" class="block py-2 text-white">Servers</a>
|
|
|
|
|
<a href="/auth/logout" class="block py-2 text-rose-300">Log out</a>
|
|
|
|
|
<div class="text-right mt-2"><button id="mobileUserClose" class="text-white/70">Cerrar</button></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
(function(){
|
|
|
|
|
const mobileGuildModal = document.getElementById('mobileGuildModal');
|
|
|
|
|
const mobileGuildClose = document.getElementById('mobileGuildClose');
|
|
|
|
|
const mobileUserSheet = document.getElementById('mobileUserSheet');
|
|
|
|
|
const mobileUserClose = document.getElementById('mobileUserClose');
|
|
|
|
|
function isMobile(){ return window.innerWidth < 768; }
|
|
|
|
|
// override mini guild click on mobile
|
|
|
|
|
const miniBtn = document.getElementById('miniGuildBtn');
|
|
|
|
|
const miniList = document.getElementById('miniGuildList');
|
|
|
|
|
if (miniBtn) {
|
|
|
|
|
miniBtn.addEventListener('click', (e)=>{
|
|
|
|
|
if (isMobile()) {
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
mobileGuildModal.classList.remove('hidden');
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
mobileGuildClose?.addEventListener('click', ()=> mobileGuildModal.classList.add('hidden'));
|
|
|
|
|
mobileGuildModal?.addEventListener('click',(e)=>{ if (e.target === mobileGuildModal) mobileGuildModal.classList.add('hidden'); });
|
|
|
|
|
// clicking mobile guild item
|
|
|
|
|
document.getElementById('mobileGuildList')?.addEventListener('click', (e)=>{
|
|
|
|
|
let el = e.target;
|
|
|
|
|
while (el && !el.dataset?.id) el = el.parentElement;
|
|
|
|
|
if (el && el.dataset && el.dataset.id) { window.location.href = `/dashboard/${el.dataset.id}/overview`; }
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// user menu mobile
|
|
|
|
|
const userBtnMobile = document.getElementById('userBtn');
|
|
|
|
|
if (userBtnMobile) userBtnMobile.addEventListener('click', (e)=>{ if (isMobile()) { e.stopPropagation(); mobileUserSheet.classList.remove('hidden'); } });
|
|
|
|
|
mobileUserClose?.addEventListener('click', ()=> mobileUserSheet.classList.add('hidden'));
|
|
|
|
|
mobileUserSheet?.addEventListener('click',(e)=>{ if (e.target === mobileUserSheet) mobileUserSheet.classList.add('hidden'); });
|
|
|
|
|
})();
|
|
|
|
|
</script>
|