fix: memperbaiki responsivitas header pada tampilan mobile

This commit is contained in:
2026-06-10 17:34:09 +07:00
parent 1cf6967e46
commit d258e37c02
3 changed files with 235 additions and 19 deletions
+69 -4
View File
@@ -135,7 +135,7 @@ $isAdmin = isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
</a>
<?php endif; ?>
<div style="width: 1px; height: 20px; background: rgba(255,255,255,0.1); margin: 0 4px;"></div>
<div style="width: 1px; height: 20px; background: rgba(255,255,255,0.1); margin: 0 4px;" class="header-tools-divider"></div>
<div class="tool-btn" id="connection-status" title="Status Koneksi">
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
@@ -150,6 +150,61 @@ $isAdmin = isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
</div>
<!-- Hamburger Menu Button (Mobile Only) -->
<button class="hamburger-menu-btn" id="hamburger-menu-btn" onclick="toggleMobileMenu(event)" title="Menu">
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M4 6h16M4 12h16M4 18h16" />
</svg>
</button>
<!-- Dropdown Menu (Mobile Only) -->
<div class="mobile-menu-dropdown" id="mobile-menu-dropdown">
<?php if ($isAdmin): ?>
<div class="mobile-menu-user">
<img src="<?php echo htmlspecialchars($_SESSION['avatar']); ?>" class="mobile-avatar" alt="Avatar">
<div>
<div class="mobile-username"><?php echo htmlspecialchars($_SESSION['username']); ?></div>
<div class="mobile-role">Admin</div>
</div>
</div>
<div class="mobile-menu-divider"></div>
<?php endif; ?>
<?php if ($isAdmin): ?>
<a href="logout.php" class="mobile-menu-item logout-link">
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" />
</svg>
<span>Logout</span>
</a>
<?php else: ?>
<a href="login.php" class="mobile-menu-item">
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M11 16l-4-4m0 0l4-4m-4 4h14m-5 4v1a3 3 0 01-3 3H7a3 3 0 01-3-3V7a3 3 0 01-3-3V7a3 3 0 013-3h7a3 3 0 013 3v1" />
</svg>
<span>Login Operator</span>
</a>
<?php endif; ?>
<div class="mobile-menu-divider"></div>
<div class="mobile-menu-item" id="mobile-connection-status">
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round"
d="M8.111 16.404a5.5 5.5 0 017.778 0M12 20h.01m-7.08-7.071c3.904-3.905 10.236-3.905 14.141 0M1.394 9.393c5.857-5.857 15.355-5.857 21.213 0" />
</svg>
<span><strong id="mobile-connection-text">Online</strong></span>
</div>
<div class="mobile-menu-item" id="mobile-about-btn">
<svg fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round"
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span>Tentang Aplikasi</span>
</div>
</div>
</div>
</div>
@@ -378,10 +433,20 @@ $isAdmin = isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
if (dropdown) dropdown.classList.toggle('active');
}
// Tutup dropdown saat klik di luar area profil
// Toggle mobile hamburger menu
function toggleMobileMenu(e) {
e.stopPropagation();
var menu = document.getElementById('mobile-menu-dropdown');
if (menu) menu.classList.toggle('active');
}
// Tutup dropdown saat klik di luar area profil / menu mobile
document.addEventListener('click', function() {
var dropdown = document.getElementById('profile-dropdown');
if (dropdown) dropdown.classList.remove('active');
var menu = document.getElementById('mobile-menu-dropdown');
if (menu) menu.classList.remove('active');
});
</script>
@@ -401,9 +466,9 @@ $isAdmin = isset($_SESSION['role']) && $_SESSION['role'] === 'admin';
</div>
<h4 class="app-title">WebGIS Poverty Map</h4>
<p class="app-desc">Sistem Pemetaan Penduduk Miskin Kota Pontianak. Aplikasi ini dirancang untuk memetakan penyebaran penduduk miskin serta mempermudah analisis spasial sebaran bantuan sosial di sekitar rumah ibadah secara dinamis.</p>
<div class="modal-divider"></div>
<div class="credits-section">
<div class="credit-row">
<span class="credit-label">Pengembang:</span>
+36 -12
View File
@@ -930,16 +930,33 @@ function closeDashboard() {
// ==========================================
function updateConnectionStatus() {
var statusEl = document.getElementById('connection-status');
if (!statusEl) return;
var mobileStatusEl = document.getElementById('mobile-connection-status');
var mobileStatusText = document.getElementById('mobile-connection-text');
if (navigator.onLine) {
statusEl.classList.remove('offline');
statusEl.classList.add('online');
statusEl.setAttribute('title', 'Koneksi Stabil');
if (statusEl) {
statusEl.classList.remove('offline');
statusEl.classList.add('online');
statusEl.setAttribute('title', 'Koneksi Stabil');
}
if (mobileStatusEl) {
mobileStatusEl.style.color = '#10b981';
}
if (mobileStatusText) {
mobileStatusText.textContent = 'Online';
}
} else {
statusEl.classList.remove('online');
statusEl.classList.add('offline');
statusEl.setAttribute('title', 'Koneksi Terputus - Peta mungkin tidak dimuat sempurna');
if (statusEl) {
statusEl.classList.remove('online');
statusEl.classList.add('offline');
statusEl.setAttribute('title', 'Koneksi Terputus - Peta mungkin tidak dimuat sempurna');
}
if (mobileStatusEl) {
mobileStatusEl.style.color = '#ef4444';
}
if (mobileStatusText) {
mobileStatusText.textContent = 'Offline';
}
}
}
@@ -955,15 +972,22 @@ updateConnectionStatus();
// 17. MODAL TENTANG APLIKASI
// ==========================================
var aboutBtn = document.getElementById('about-btn');
var mobileAboutBtn = document.getElementById('mobile-about-btn');
var aboutModal = document.getElementById('about-modal');
var aboutCloseBtn = document.getElementById('about-close-btn');
var aboutOkBtn = document.getElementById('about-ok-btn');
if (aboutBtn && aboutModal) {
aboutBtn.addEventListener('click', function (e) {
e.preventDefault();
aboutModal.classList.add('active');
});
var openAboutModal = function (e) {
e.preventDefault();
aboutModal.classList.add('active');
// Tutup menu mobile jika sedang terbuka
var menu = document.getElementById('mobile-menu-dropdown');
if (menu) menu.classList.remove('active');
};
if (aboutModal) {
if (aboutBtn) aboutBtn.addEventListener('click', openAboutModal);
if (mobileAboutBtn) mobileAboutBtn.addEventListener('click', openAboutModal);
var closeModal = function () {
aboutModal.classList.remove('active');
+130 -3
View File
@@ -468,6 +468,14 @@ body {
flex-shrink: 0;
}
.hamburger-menu-btn {
display: none;
}
.mobile-menu-dropdown {
display: none;
}
.tool-btn {
background: rgba(255, 255, 255, 0.07);
border: 1px solid rgba(255, 255, 255, 0.1);
@@ -1758,9 +1766,128 @@ body {
gap: 4px;
}
.tool-btn {
width: 30px;
height: 30px;
.header-tools-divider,
.user-profile-menu,
.auth-btn,
#connection-status,
#about-btn {
display: none !important;
}
.hamburger-menu-btn {
display: flex;
align-items: center;
justify-content: center;
background: rgba(255, 255, 255, 0.07);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 8px;
width: 34px;
height: 34px;
color: #94a3b8;
cursor: pointer;
transition: all 0.15s;
}
.hamburger-menu-btn:hover {
background: rgba(255, 255, 255, 0.12);
color: #e2e8f0;
}
.hamburger-menu-btn svg {
width: 18px;
height: 18px;
}
.mobile-menu-dropdown {
position: absolute;
top: calc(100% + 8px);
right: 10px;
width: 200px;
background: rgba(15, 23, 42, 0.96);
backdrop-filter: blur(16px);
-webkit-backdrop-filter: blur(16px);
border: 1px solid rgba(255, 255, 255, 0.08);
border-radius: var(--radius-md);
box-shadow: var(--shadow-lg);
padding: 8px;
display: flex;
flex-direction: column;
gap: 4px;
z-index: 1250;
opacity: 0;
visibility: hidden;
transform: translateY(-8px) scale(0.95);
transform-origin: top right;
transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.mobile-menu-dropdown.active {
opacity: 1;
visibility: visible;
transform: translateY(0) scale(1);
display: flex;
}
.mobile-menu-item {
display: flex;
align-items: center;
gap: 8px;
padding: 10px 12px;
font-size: 13px;
font-weight: 600;
color: #cbd5e1;
text-decoration: none;
border-radius: 6px;
transition: all 0.15s ease;
cursor: pointer;
}
.mobile-menu-item:hover {
background: rgba(255, 255, 255, 0.05);
color: #f1f5f9;
}
.mobile-menu-item svg {
width: 16px;
height: 16px;
flex-shrink: 0;
}
.mobile-menu-divider {
height: 1px;
background: rgba(255, 255, 255, 0.06);
margin: 4px 6px;
}
.mobile-menu-user {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 12px;
}
.mobile-avatar {
width: 32px;
height: 32px;
border-radius: 50%;
border: 1.5px solid var(--primary);
object-fit: cover;
}
.mobile-username {
font-size: 13px;
font-weight: 700;
color: #f8fafc;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 130px;
}
.mobile-role {
font-size: 10.5px;
color: #64748b;
margin-top: 1px;
}
/* Sidebar Full-width (100%) */