From 90af5d373f6c703b4373490527e991b931e751be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?kleines=20Filmr=C3=B6llchen?= Date: Sat, 23 Nov 2024 21:12:38 +0100 Subject: [PATCH] space status on mobile revamp of the mobile header --- static/main.css | 31 +++++++++++-------------------- static/main.js | 15 ++++++--------- templates/page.html | 11 ++--------- 3 files changed, 19 insertions(+), 38 deletions(-) diff --git a/static/main.css b/static/main.css index 949ddcd..480a4bd 100644 --- a/static/main.css +++ b/static/main.css @@ -67,7 +67,7 @@ h3 { #space-image { height: 8vh; - transition: height 0.2s, transform 0.2s; + transition: height 0.2s; &:hover { height: 11vh; @@ -82,8 +82,8 @@ header { display: grid; grid-template: "logo . nav nav" - "logo . . ." min-content - "logo . space-text space-image" min-content / + "logo . space-text space-image" min-content + "logo . . ." min-content / minmax(min-content, 25vw) 1fr auto minmax(0, min-content); overflow: hidden; @@ -108,43 +108,34 @@ header { @media screen and (width > 1700px) { header { position: fixed; + /* subtract exactly the margins to get the 100% horizontal fill we need */ width: calc(100vw - 2 * 3em); } } +/* mobile header, just some vertical rearranging and smaller margins */ @media screen and (width < 650px) { body { margin: 1.5rem; margin-top: 0; } + header { grid-template: - "logo space-image" minmax(0, 20vh) - "nav nav" min-content / - auto minmax(0, min-content); + "logo logo" minmax(3cm, 10vh) + "nav nav" + "space-text space-image" min-content / + auto min-content; #space-image-container { margin-top: auto; margin-bottom: auto; margin-left: auto; } - - #space-text { - display: none; - } - } -} - -@media screen and (width < 400px) { - header { - grid-template: - ". logo ." minmax(3cm, 10vh) - "space-text space-text space-image" min-content - "nav nav nav" / - 1fr minmax(min-content, 30vh) 1fr; } } +/* skip to content element, lots of positioning styles copied from html5-boilerplate */ #skip-header { background: var(--main-bg-color); border: 0; diff --git a/static/main.js b/static/main.js index 277585e..6e55182 100644 --- a/static/main.js +++ b/static/main.js @@ -4,8 +4,7 @@ const refreshRate = 60 * 1000; function checkSpace() { const icon = document.getElementById("space-image"); - const stateItem = document.getElementById("space-state"); - const stateLastUpdateItem = document.getElementById("space-last-update"); + const stateItem = document.getElementById("space-text"); let stateText = "", stateLastUpdate = ""; fetch("https://spaceapi.ctbk.de/") @@ -19,30 +18,28 @@ function checkSpace() { openText = "geschlossen"; icon.src = data.state.icon.closed; } - stateText = `Der Space ist derzeit ${openText}.`; const lastchangeString = data.state.lastchange ? new Date(data.state.lastchange * 1000).toLocaleString(true, { timeStyle: "short", dateStyle: "medium", }) : "unbekannt"; - stateLastUpdate = "Letzte Statusänderung: " + lastchangeString; - console.log("Icon: " + icon.src); + stateText = `Space ${openText} seit ${lastchangeString}`; + stateLastUpdate = `Letzte Statusänderung: ${lastchangeString}`; }) .catch((error) => { icon.src = "/img/unknown.png"; - stateText = "Der Spacestatus ist unbekannt"; + stateText = "Spacestatus unbekannt"; console.error("Error on space state retrieval:", error); }) .then(() => { icon.alt = stateText; icon.text = stateLastUpdate; - stateItem.innerText = stateText; - stateLastUpdateItem.innerText = stateLastUpdate; + stateItem.innerHTML = stateText; }); } -const interval = setInterval(() => { +setInterval(() => { checkSpace(); }, refreshRate); diff --git a/templates/page.html b/templates/page.html index 52a5c0b..583c019 100644 --- a/templates/page.html +++ b/templates/page.html @@ -68,16 +68,9 @@ truncate(length=150) %} {% else %} {% set description = "" %} {% endif %} Verein FSCK -

-
Nächstes Treffen: siehe Termine
-

+

-