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

@@ -1378,7 +1378,16 @@ function updateTabButtons() {
}); });
} }
function isPostsViewActive() {
const postsView = document.querySelector('[data-view="posts"]');
return Boolean(postsView && postsView.classList.contains('app-view--active'));
}
function updateTabInUrl() { function updateTabInUrl() {
if (!isPostsViewActive()) {
return;
}
const url = new URL(window.location.href); const url = new URL(window.location.href);
if (currentTab === 'pending') { if (currentTab === 'pending') {
url.searchParams.set('tab', 'pending'); url.searchParams.set('tab', 'pending');
@@ -1387,7 +1396,8 @@ function updateTabInUrl() {
} else { } else {
url.searchParams.set('tab', 'all'); url.searchParams.set('tab', 'all');
} }
window.history.replaceState({}, document.title, `${url.pathname}?${url.searchParams.toString()}${url.hash}`); const nextState = { ...(window.history.state || {}), view: 'posts' };
window.history.replaceState(nextState, document.title, `${url.pathname}?${url.searchParams.toString()}${url.hash}`);
} }
function getTabKey(tab = currentTab) { function getTabKey(tab = currentTab) {
@@ -2770,6 +2780,12 @@ document.querySelectorAll('.tab-btn').forEach(btn => {
}); });
}); });
window.addEventListener('app:view-change', (event) => {
if (event && event.detail && event.detail.view === 'posts') {
updateTabInUrl();
}
});
if (manualPostForm) { if (manualPostForm) {
manualPostForm.addEventListener('submit', handleManualPostSubmit); manualPostForm.addEventListener('submit', handleManualPostSubmit);
} }

View File

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

View File

@@ -83,37 +83,64 @@ header {
} }
.site-nav { .site-nav {
display: inline-flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 6px;
background: rgba(255, 255, 255, 0.6); padding: 4px 0;
border-radius: 999px; border-bottom: 1px solid rgba(15, 23, 42, 0.08);
padding: 6px; position: relative;
backdrop-filter: blur(8px); }
border: 1px solid rgba(148, 163, 184, 0.25);
.site-nav::after {
content: "";
position: absolute;
left: 0;
right: 0;
bottom: -1px;
height: 1px;
background: linear-gradient(90deg, rgba(79, 70, 229, 0.7), rgba(14, 165, 233, 0.7));
opacity: 0.35;
} }
.site-nav__btn { .site-nav__btn {
border-radius: 999px;
padding: 10px 18px;
border: none; border: none;
background: transparent; background: transparent;
font-weight: 600; font-weight: 600;
color: #0f172a; color: #475569;
cursor: pointer; cursor: pointer;
transition: all 0.2s ease; transition: color 0.2s ease, transform 0.2s ease;
box-shadow: none; font-size: 15px;
letter-spacing: 0.01em;
padding: 10px 16px;
position: relative;
}
.site-nav__btn::after {
content: "";
position: absolute;
left: 12px;
right: 12px;
bottom: -8px;
height: 3px;
border-radius: 999px;
background: linear-gradient(135deg, #4338ca, #0ea5e9);
transform: translateY(6px);
opacity: 0;
transition: opacity 0.15s ease, transform 0.2s ease;
} }
.site-nav__btn:hover { .site-nav__btn:hover {
background: rgba(15, 23, 42, 0.05); color: #0f172a;
transform: translateY(-1px); transform: translateY(-1px);
} }
.site-nav__btn.nav-active { .site-nav__btn.nav-active {
background: linear-gradient(135deg, #2563eb, #7c3aed); color: #0f172a;
color: white; }
box-shadow: 0 12px 30px rgba(37, 99, 235, 0.35);
.site-nav__btn.nav-active::after {
opacity: 1;
transform: translateY(0);
} }
.header-controls { .header-controls {