summaryrefslogtreecommitdiff
diff options
from:
to:
context:
space:
mode:
-rw-r--r--views/layouts/general-page.html33
1 files changed, 25 insertions, 8 deletions
diff --git a/views/layouts/general-page.html b/views/layouts/general-page.html
index 8a621c4..cc66a2c 100644
--- a/views/layouts/general-page.html
+++ b/views/layouts/general-page.html
@@ -17,10 +17,10 @@
<script>
function changeUrl(path, toAppend = false) {
- const urlParams = new URLSearchParams(window.location.search);
+ const urlParams = new URLSearchParams(window.location.search);
const newPathname = location.pathname.endsWith('/') ? location.pathname.slice(0, -1) : location.pathname;
const newPath = toAppend ? `${newPathname}${path}` : `${path}`;
-
+
history.pushState({}, '', `${newPath}${urlParams.entries.length == 0 ? '' : '?' + urlParams.toString()}`);
window.dispatchEvent(new Event('popstate'));
return false;
@@ -171,17 +171,17 @@
<div id="sidebar" class="bg-sidebar flex sticky flex-col z-20 w-[100dvw] xs:w-[90dvw] sm:w-[80dvw] md:w-[75dvw] lg:w-[70dvw] xl:w-[65dvw] 2xl:w-[60dvw] [@media(max-height:32rem)]:w-[5rem] h-[5rem] [@media(max-height:32rem)]:h-[100dvh] mx-auto [@media(max-height:32rem)]:mx-0
shadow-[0_0_1rem_black]">
<div class="text-[3rem] text-stroke-(--sidebar-stroke-color) text-stroke-[0.1dvw] flex flex-row [@media(max-height:32rem)]:flex-col gap-0 relative z-20">
- <a href="/{{ .Lang }}" class="w-[5rem] h-[5rem]">
+ <a href="/{{ .Lang }}" id="sidebar-home-button" class="w-[5rem] h-[5rem]">
<i onclick="return changeUrl('/{{ .Lang }}');" class="fas fa-home flex w-full h-full content-center text-center text-sidebar hover:bg-background-dark transition-colors duration-300 rounded-lg"></i>
</a>
- <a href="/{{ .Lang }}/blog" class="w-[5rem] h-[5rem]">
+ <a href="/{{ .Lang }}/blog" id="sidebar-blog-button" class="w-[5rem] h-[5rem]">
<i onclick="return changeUrl('/{{ .Lang }}/blog');" class="fas fa-search flex w-full h-full content-center text-center text-sidebar hover:bg-background-dark transition-colors duration-300 rounded-lg"></i>
</a>
- <a href="/{{ .Lang }}/map" class="w-[5rem] h-[5rem]">
+ <a href="/{{ .Lang }}/map" id="sidebar-map-button" class="w-[5rem] h-[5rem]">
<i class="fas fa-map flex w-full h-full content-center text-center text-sidebar hover:bg-background-dark transition-colors duration-300 rounded-lg"></i>
</a>
- <i onclick="toggleThemeWheel();" id="theme-button" class="fas fa-swatchbook flex w-[5rem] h-[5rem] content-center text-center text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 rounded-lg"></i>
- <a href="./" class="w-[5rem] h-[5rem]">
+ <i onclick="toggleThemeWheel();" id="sidebar-theme-button" class="fas fa-swatchbook flex w-[5rem] h-[5rem] content-center text-center text-sidebar hover:bg-background-dark cursor-pointer transition-colors duration-300 rounded-lg"></i>
+ <a href="./" id="sidebar-back-button" class="w-[5rem] h-[5rem]">
<i onclick="return changeUrl('/../', true);" class="fas fa-circle-left flex w-full h-full content-center text-center text-sidebar hover:bg-background-dark transition-colors duration-300 rounded-lg"></i>
</a>
</div>
@@ -192,6 +192,23 @@
<div class="theme-icon" data-theme="ram"></div>
<div class="theme-pin"></div>
</div>
+ <script>
+ function hideButtonsOnRoot() {
+ if (location.pathname == "" || location.pathname == "/") {
+ document.getElementById("sidebar-home-button").classList.add('hidden');
+ document.getElementById("sidebar-map-button").classList.add('hidden');
+ document.getElementById("sidebar-blog-button").classList.add('hidden');
+ document.getElementById("sidebar-back-button").classList.add('hidden');
+ } else {
+ document.getElementById("sidebar-home-button").classList.remove('hidden');
+ document.getElementById("sidebar-map-button").classList.remove('hidden');
+ document.getElementById("sidebar-blog-button").classList.remove('hidden');
+ document.getElementById("sidebar-back-button").classList.remove('hidden');
+ }
+ }
+ window.addEventListener("popstate", hideButtonsOnRoot)
+ window.addEventListener("load", hideButtonsOnRoot, {once: true});
+ </script>
</div>
<div class="bg-background-dark @container/main flex z-10 w-[100dvw] xs:w-[90dvw] sm:w-[80dvw] md:w-[75dvw] lg:w-[70dvw] xl:w-[65dvw] 2xl:w-[60dvw] grow-0 h-[calc(100dvh-5rem)] [@media(max-height:32rem)]:h-[100dvh] mx-auto [@media(max-height:32rem)]:mx-0
@@ -234,7 +251,7 @@
<script>
const themeWheel = document.getElementById('theme-wheel');
- const themeButton = document.getElementById('theme-button');
+ const themeButton = document.getElementById('sidebar-theme-button');
const themeIcons = document.querySelectorAll('.theme-icon');
const themeWheelRadius = convertRemToPixels(6);