Diffstat (limited to 'views/layouts')
| -rw-r--r-- | views/layouts/general-page.html | 187 |
1 files changed, 78 insertions, 109 deletions
diff --git a/views/layouts/general-page.html b/views/layouts/general-page.html index b435402..d787c16 100644 --- a/views/layouts/general-page.html +++ b/views/layouts/general-page.html @@ -24,18 +24,6 @@ /> <link rel="stylesheet" - href="{{ .StaticStorageBaseUrl }}/libs/font-awesome/7.2.0/css/fontawesome.min.css" - /> - <link - rel="stylesheet" - href="{{ .StaticStorageBaseUrl }}/libs/font-awesome/7.2.0/css/brands.min.css" - /> - <link - rel="stylesheet" - href="{{ .StaticStorageBaseUrl }}/libs/font-awesome/7.2.0/css/solid.min.css" - /> - <link - rel="stylesheet" href="{{ .StaticStorageBaseUrl }}/libs/leaflet/1.9.4/leaflet.css" /> <link @@ -55,6 +43,11 @@ type="image/svg+xml" media="(prefers-color-scheme: dark)" /> + <link + rel="icon" + href="/favicon.ico" + type="image/x-icon" + /> {{- with .LinkedData }} <script type="application/ld+json"> {{ . }} @@ -318,14 +311,50 @@ switchTheme(savedTheme); </script> - <div - id="general-page-top-embeds" - class="flex" - hx-get="/api/v1/general-page/top-embeds{{ if .QueryString }}?{{ .QueryString }}{{ end }}" - hx-trigger="load" - hx-target="this" - hx-swap="innerHTML" - ></div> + <script src="{{ .StaticStorageBaseUrl }}/libs/htmx/2.0.6/htmx.min.js"></script> + <script src="{{ .StaticStorageBaseUrl }}/libs/leaflet/1.9.4/leaflet.js"></script> + <script src="{{ .StaticStorageBaseUrl }}/libs/imagesloaded/5.0.0/imagesloaded.pkgd.min.js"></script> + <script src="{{ .StaticStorageBaseUrl }}/libs/packery/3.0.0/dist/packery.pkgd.min.js"></script> + + <script> + // Enable fitWidth-like attribute for Packery. Source: https://codepen.io/desandro/pen/kVmLYz + var __resetLayout = Packery.prototype._resetLayout; + Packery.prototype._resetLayout = function () { + __resetLayout.call(this); + var parentSize = getSize(this.element.parentNode); + var colW = this.columnWidth + this.gutter; + this.fitWidth = + Math.floor((parentSize.innerWidth + this.gutter) / colW) * + colW; + this.packer.width = this.fitWidth; + this.packer.height = Number.POSITIVE_INFINITY; + this.packer.reset(); + }; + + Packery.prototype._getContainerSize = function () { + var emptyWidth = 0; + for (var i = 0, len = this.packer.spaces.length; i < len; i++) { + var space = this.packer.spaces[i]; + if ( + space.y === 0 && + space.height === Number.POSITIVE_INFINITY + ) { + emptyWidth += space.width; + } + } + + return { + width: this.fitWidth - this.gutter - emptyWidth, + height: this.maxY - this.gutter, + }; + }; + + Packery.prototype.needsResizeLayout = function () { + return true; + }; + </script> + + <div id="general-page-top-embeds" class="flex">{{ .RenderedTopEmbeds }}</div> <div id="general-page-top-embeds-trigger" hx-get="/api/v1/general-page/top-embeds{{ if .QueryString }}?{{ .QueryString }}{{ end }}" @@ -346,9 +375,7 @@ class="flex flex-row w-full h-24 md:flex-col md:w-24 md:h-full bg-paper bg-background shadow-elevation-6 z-2 shrink-0" > <a - class="w-18 h-18 bg-conic-225 rounded-xl m-3 - from-accent-light/10 via-transparent to-accent-light/10 transition-colors duration-1500 ease-in-out - hover:cursor-pointer hover:from-accent-light/50 hover:via-transparent hover:to-accent-light/50" + class="w-18 h-18 rounded-xl m-3 accent-button" onclick="return changeUrl('/..', true);" href="../" id="sidebar-back-button" @@ -357,9 +384,7 @@ <svg viewBox="0 0 24 24"><use href="#icon-back"/></svg> </a> <a - class="w-18 h-18 bg-conic-225 rounded-xl m-3 - from-accent-light/10 via-transparent to-accent-light/10 transition-colors duration-1500 ease-in-out - hover:cursor-pointer hover:from-accent-light/50 hover:via-transparent hover:to-accent-light/50" + class="w-18 h-18 rounded-xl m-3 accent-button" onclick="return changeUrl('/{{ .Lang }}');" href="/{{ .Lang }}" id="sidebar-home-button" @@ -368,9 +393,7 @@ <svg viewBox="0 0 24 24"><use href="#icon-logo"/></svg> </a> <a - class="w-18 h-18 bg-conic-225 rounded-xl m-3 - from-accent-light/10 via-transparent to-accent-light/10 transition-colors duration-1500 ease-in-out - hover:cursor-pointer hover:from-accent-light/50 hover:via-transparent hover:to-accent-light/50" + class="w-18 h-18 rounded-xl m-3 accent-button" onclick="return changeUrl('/{{ .Lang }}/blog');" href="/{{ .Lang }}/blog" id="sidebar-blog-button" @@ -379,9 +402,7 @@ <svg viewBox="0 0 24 24"><use href="#icon-newspaper"/></svg> </a> <a - class="w-18 h-18 bg-conic-225 rounded-xl m-3 - from-accent-light/10 via-transparent to-accent-light/10 transition-colors duration-1500 ease-in-out - hover:cursor-pointer hover:from-accent-light/50 hover:via-transparent hover:to-accent-light/50" + class="w-18 h-18 rounded-xl m-3 accent-button" href="/{{ .Lang }}/map" id="sidebar-map-button" draggable="false" @@ -389,9 +410,7 @@ <svg viewBox="0 0 24 24"><use href="#icon-map"/></svg> </a> <div - class="w-18 h-18 bg-conic-225 rounded-xl m-3 - from-accent-light/10 via-transparent to-accent-light/10 transition-colors duration-1500 ease-in-out - hover:cursor-pointer hover:from-accent-light/50 hover:via-transparent hover:to-accent-light/50" + class="w-18 h-18 rounded-xl m-3 accent-button" onclick="toggleThemeWheel()" id="sidebar-theme-button" draggable="false" @@ -399,9 +418,7 @@ <svg class="sidebar-theme-button-content" viewBox="0 0 24 24"><use href="#icon-palette"/></svg> </div> <a - class="w-18 h-18 bg-conic-225 rounded-xl m-3 - from-accent-light/10 via-transparent to-accent-light/10 transition-colors duration-1500 ease-in-out - hover:cursor-pointer hover:from-accent-light/50 hover:via-transparent hover:to-accent-light/50" + class="w-18 h-18 rounded-xl m-3 accent-button" onclick="return changeUrl('/{{ .Lang }}/user');" href="/{{ .Lang }}/user" id="sidebar-user-button" @@ -434,6 +451,11 @@ ); function updateSidebar() { + sidebarHomeButton.classList.remove("active"); + sidebarMapButton.classList.remove("active"); + sidebarBlogButton.classList.remove("active"); + sidebarBackButton.classList.remove("active"); + sidebarUserButton.classList.remove("active"); if ( location.pathname == "" || location.pathname == "/" @@ -455,6 +477,9 @@ "onclick", `return changeUrl('/${lang}', false);`, ); + if (location.pathname == `/${lang}`) { + sidebarHomeButton.classList.add("active"); + } sidebarMapButton.setAttribute( "href", `/${lang}/map`, @@ -467,6 +492,9 @@ "onclick", `return changeUrl('/${lang}/blog', false);`, ); + if (location.pathname.startsWith(`/${lang}/blog`)) { + sidebarBlogButton.classList.add("active"); + } sidebarUserButton.setAttribute( "href", `/${lang}/user`, @@ -475,6 +503,9 @@ "onclick", `return changeUrl('/${lang}/user', false);`, ); + if (location.pathname.startsWith(`/${lang}/user`)) { + sidebarUserButton.classList.add("active"); + } } } window.addEventListener("popstate", updateSidebar); @@ -485,23 +516,19 @@ </nav> <div - class="flex flex-1 z-1 bg-paper bg-background shadow-elevation-3 @container/body" + class="flex flex-1 min-h-0 z-1 bg-paper bg-background shadow-elevation-3 @container/body" > <div class="bg-paper bg-background-dark border-r-2 border-dashed border-main-hard" ></div> <div - class="max-h-full max-w-full flex flex-col grow bg-paper bg-background-dark relative pt-4 pr-0 md:pr-4" + class="max-h-full max-w-full flex flex-col grow bg-paper bg-background-dark relative md:pt-4 md:pr-4" > <header id="general-page-header" class="max-xs:hidden [@media(max-height:32rem)]:hidden flex flex-col ml-8 basis-8" - hx-get="/api/v1/general-page/header{{ if .QueryString }}?{{ .QueryString }}{{ end }}" - hx-trigger="load" - hx-target="this" - hx-swap="innerHTML" - ></header> + >{{ .RenderedHeader }}</header> <div id="general-page-header-trigger" hx-get="/api/v1/general-page/header{{ if .QueryString }}?{{ .QueryString }}{{ end }}" @@ -516,12 +543,8 @@ <main id="general-page-body" - class="relative flex flex-col grow overflow-y-auto" - hx-get="/api/v1/general-page/body{{ if .QueryString }}?{{ .QueryString }}{{ end }}" - hx-trigger="load" - hx-target="this" - hx-swap="innerHTML" - ></main> + class="relative flex-1 overflow-y-auto" + >{{ .RenderedBody }}</main> <div id="general-page-body-trigger" hx-get="/api/v1/general-page/body{{ if .QueryString }}?{{ .QueryString }}{{ end }}" @@ -533,11 +556,7 @@ <footer id="general-page-footer" class="flex flex-row basis-4 my-1" - hx-get="/api/v1/general-page/footer{{ if .QueryString }}?{{ .QueryString }}{{ end }}" - hx-trigger="load" - hx-target="this" - hx-swap="innerHTML" - ></footer> + >{{ .RenderedFooter }}</footer> <div id="general-page-footer-trigger" hx-get="/api/v1/general-page/footer{{ if .QueryString }}?{{ .QueryString }}{{ end }}" @@ -559,57 +578,7 @@ <div class="grow bg-split-right"></div> - <script src="{{ .StaticStorageBaseUrl }}/libs/htmx/2.0.6/htmx.min.js"></script> - <script src="{{ .StaticStorageBaseUrl }}/libs/leaflet/1.9.4/leaflet.js"></script> - <script src="{{ .StaticStorageBaseUrl }}/libs/imagesloaded/5.0.0/imagesloaded.pkgd.min.js"></script> - <script src="{{ .StaticStorageBaseUrl }}/libs/packery/3.0.0/dist/packery.pkgd.min.js"></script> - - <script> - // Enable fitWidth-like attribute for Packery. Source: https://codepen.io/desandro/pen/kVmLYz - var __resetLayout = Packery.prototype._resetLayout; - Packery.prototype._resetLayout = function () { - __resetLayout.call(this); - var parentSize = getSize(this.element.parentNode); - var colW = this.columnWidth + this.gutter; - this.fitWidth = - Math.floor((parentSize.innerWidth + this.gutter) / colW) * - colW; - this.packer.width = this.fitWidth; - this.packer.height = Number.POSITIVE_INFINITY; - this.packer.reset(); - }; - - Packery.prototype._getContainerSize = function () { - var emptyWidth = 0; - for (var i = 0, len = this.packer.spaces.length; i < len; i++) { - var space = this.packer.spaces[i]; - if ( - space.y === 0 && - space.height === Number.POSITIVE_INFINITY - ) { - emptyWidth += space.width; - } - } - - return { - width: this.fitWidth - this.gutter - emptyWidth, - height: this.maxY - this.gutter, - }; - }; - - Packery.prototype.needsResizeLayout = function () { - return true; - }; - </script> - - <div - id="general-page-bottom-embeds" - class="flex" - hx-get="/api/v1/general-page/bottom-embeds{{ if .QueryString }}?{{ .QueryString }}{{ end }}" - hx-trigger="load" - hx-target="this" - hx-swap="innerHTML" - ></div> + <div id="general-page-bottom-embeds" class="flex">{{ .RenderedBottomEmbeds }}</div> <div id="general-page-bottom-embeds-trigger" hx-get="/api/v1/general-page/bottom-embeds{{ if .QueryString }}?{{ .QueryString }}{{ end }}" @@ -622,7 +591,6 @@ const themeWheel = document.getElementById("theme-wheel"); const themeButton = document.getElementById("sidebar-theme-button"); const themeIcons = document.querySelectorAll(".theme-icon"); - const themeWheelRadius = convertRemToPixels(6); themeIcons.forEach((icon) => { if (icon.getAttribute("data-theme") == savedTheme) { @@ -651,7 +619,7 @@ const clipPath = createSliceClipPath( startAngle, endAngle, - themeWheelRadius, + convertRemToPixels(6), ); icon.style.clipPath = clipPath; }); @@ -686,6 +654,7 @@ const buttonRect = themeButton.getBoundingClientRect(); const buttonCenterX = buttonRect.left + buttonRect.width / 2; const buttonCenterY = buttonRect.top + buttonRect.height / 2; + const themeWheelRadius = convertRemToPixels(6); const margin = 0; |