reworked site

This commit is contained in:
2025-11-16 14:11:23 +01:00
parent 898f2e0b58
commit b7a9091183
3 changed files with 71 additions and 19 deletions

View File

@@ -20,8 +20,8 @@
<h1>📋 Post Tracker</h1>
</div>
<div class="site-nav">
<button type="button" class="site-nav__btn" data-view-target="posts">Beiträge</button>
<button type="button" class="site-nav__btn" data-view-target="dashboard">Dashboard</button>
<button type="button" class="site-nav__btn" data-view-target="posts">📝 Beiträge</button>
<button type="button" class="site-nav__btn" data-view-target="dashboard">📊 Dashboard</button>
<button type="button" class="site-nav__btn" data-view-target="settings">⚙️ Einstellungen</button>
<button type="button" class="site-nav__btn" data-view-target="bookmarks">🔖 Bookmarks</button>
</div>
@@ -645,6 +645,11 @@
const params = new URLSearchParams(window.location.search);
const initialParam = params.get('view');
const defaultView = viewMap[initialParam] ? initialParam : 'posts';
const VIEW_CHANGE_EVENT = 'app:view-change';
function dispatchViewChange(view) {
window.dispatchEvent(new CustomEvent(VIEW_CHANGE_EVENT, { detail: { view } }));
}
function setView(view, options = { updateHistory: true }) {
if (!viewMap[view]) {
@@ -667,11 +672,14 @@
nextParams.delete('view');
} else {
nextParams.set('view', view);
nextParams.delete('tab');
}
const query = nextParams.toString();
const newUrl = query ? `${window.location.pathname}?${query}` : window.location.pathname;
window.history.pushState({ view }, '', newUrl);
}
dispatchViewChange(view);
}
buttons.forEach((button) => {
@@ -691,6 +699,7 @@
initParams.delete('view');
} else {
initParams.set('view', defaultView);
initParams.delete('tab');
}
const initQuery = initParams.toString();
window.history.replaceState({ view: defaultView }, '', initQuery ? `${window.location.pathname}?${initQuery}` : window.location.pathname);