From 02770356aeec1ea4e4c81ed315f69545a5b2a54b Mon Sep 17 00:00:00 2001 From: Wahyudin Date: Tue, 13 Oct 2026 15:47:04 +0700 Subject: [PATCH] feat: add interactive floating profile dropdown menu with Profil Saya and Keluar Sistem --- resources/views/layouts/app.blade.php | 78 +++++++++++++++++++++++++-- 1 file changed, 73 insertions(+), 5 deletions(-) diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 2ed8921..fd1463d 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -405,10 +405,15 @@ - -
- -
+ + @@ -600,6 +627,47 @@ chevron.classList.toggle('rotate-180'); } } + + // Toggle Dropdown Menu Profil Pengguna di Pojok Kanan Atas + function toggleProfileDropdown() { + const dropdown = document.getElementById('userProfileDropdownMenu'); + const chevron = document.getElementById('userProfileChevron'); + const btn = document.getElementById('userProfileDropdownBtn'); + if (dropdown) { + const isHidden = dropdown.classList.toggle('hidden'); + if (btn) btn.setAttribute('aria-expanded', !isHidden); + } + if (chevron) { + chevron.classList.toggle('rotate-180'); + } + } + + // Tutup dropdown profil jika mengklik di luar area + document.addEventListener('click', function(event) { + const container = document.getElementById('userProfileContainer'); + const dropdown = document.getElementById('userProfileDropdownMenu'); + const chevron = document.getElementById('userProfileChevron'); + const btn = document.getElementById('userProfileDropdownBtn'); + if (container && dropdown && !container.contains(event.target)) { + dropdown.classList.add('hidden'); + if (chevron) chevron.classList.remove('rotate-180'); + if (btn) btn.setAttribute('aria-expanded', 'false'); + } + }); + + // Tutup dropdown profil jika menekan tombol Escape + document.addEventListener('keydown', function(event) { + if (event.key === 'Escape') { + const dropdown = document.getElementById('userProfileDropdownMenu'); + const chevron = document.getElementById('userProfileChevron'); + const btn = document.getElementById('userProfileDropdownBtn'); + if (dropdown && !dropdown.classList.contains('hidden')) { + dropdown.classList.add('hidden'); + if (chevron) chevron.classList.remove('rotate-180'); + if (btn) btn.setAttribute('aria-expanded', 'false'); + } + } + }); @yield('scripts')