Add responsive design, not perfect but working
This commit is contained in:
6 files changed
+229
-42
No files matched your search
+23
-38
@@ -30,7 +30,9 @@
|
||||
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap"
|
||||
rel="stylesheet"
|
||||
/>
|
||||
|
||||
|
||||
<!-- Responsive Design -->
|
||||
<link rel="stylesheet" href="css/responsive.css">
|
||||
<style>
|
||||
/* Use Open Props design tokens */
|
||||
* {
|
||||
@@ -71,6 +73,7 @@
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
position: relative;
|
||||
isolation: isolate;
|
||||
}
|
||||
|
||||
#map {
|
||||
@@ -296,16 +299,7 @@
|
||||
padding: var(--size-4);
|
||||
}
|
||||
|
||||
/* Map controls */
|
||||
.map-controls {
|
||||
position: absolute;
|
||||
top: var(--size-4);
|
||||
right: var(--size-4);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: var(--size-2);
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.control-btn {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
@@ -481,27 +475,6 @@
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 768px) {
|
||||
.sidebar {
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
height: 100%;
|
||||
transform: translateX(-100%);
|
||||
}
|
||||
.sidebar.active {
|
||||
transform: translateX(0);
|
||||
}
|
||||
.app-container {
|
||||
flex-direction: column;
|
||||
}
|
||||
.map-controls {
|
||||
top: auto;
|
||||
bottom: var(--size-4);
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
.site-header {
|
||||
background: var(--gray-9);
|
||||
padding: var(--size-4) var(--size-6);
|
||||
@@ -1398,16 +1371,14 @@
|
||||
window.updateJourneyPath = updateJourneyPath;
|
||||
window.clearAllMarkers = clearAllMarkers;
|
||||
window.setMode = setMode;
|
||||
|
||||
|
||||
// ==================== START ====================
|
||||
// This function is called after auth check
|
||||
function startMap() {
|
||||
initMap();
|
||||
// Check for journey parameter
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
const journeyToLoad = urlParams.get('journey');
|
||||
if (journeyToLoad) {
|
||||
// Fetch the journey and load its markers
|
||||
fetch(`${API_BASE}/journeys/${journeyToLoad}`, { credentials: 'include' })
|
||||
.then(res => res.json())
|
||||
.then(journey => {
|
||||
@@ -1422,14 +1393,28 @@
|
||||
bindEventListeners();
|
||||
}
|
||||
window.startMap = startMap;
|
||||
})();
|
||||
|
||||
})(); // end of IIFE
|
||||
|
||||
// ==================== SIDEBAR HELPER (outside IIFE) ====================
|
||||
function initSidebar() {
|
||||
const sidebar = document.querySelector('.sidebar');
|
||||
if (!sidebar) return;
|
||||
const isMobile = window.innerWidth <= 768;
|
||||
if (isMobile) {
|
||||
sidebar.classList.add('collapsed');
|
||||
} else {
|
||||
sidebar.classList.remove('collapsed');
|
||||
}
|
||||
}
|
||||
|
||||
// ==================== AUTHENTICATION CHECK ====================
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
const authenticated = await checkAuthAndRedirect();
|
||||
if (authenticated) {
|
||||
updateUserMenu();
|
||||
window.startMap(); // call the map initializer from the IIFE
|
||||
window.addEventListener('resize', initSidebar);
|
||||
initSidebar();
|
||||
window.startMap();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user