From 814a3842953a67aa2852eac7b32d7e051387173d Mon Sep 17 00:00:00 2001 From: Hugo Date: Thu, 3 Aug 2023 20:38:04 +0200 Subject: [PATCH] feat: theme button --- scripts/main.js | 12 +++++------- styles/poster.css | 1 - styles/style.css | 22 +++++++++++++++++++++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/scripts/main.js b/scripts/main.js index b58fc74f..3a09e7fe 100644 --- a/scripts/main.js +++ b/scripts/main.js @@ -22,7 +22,7 @@ if (theme !== null) { } theme_switcher.addEventListener("click", () => { - if (theme_switcher.textContent.indexOf("off") !== -1) { + if (theme_switcher.getAttribute("title").indexOf("off") !== -1) { changeToDarkTheme(); } else { changeToLightTheme(); @@ -30,7 +30,7 @@ theme_switcher.addEventListener("click", () => { }); function changeToDarkTheme() { - theme_switcher.textContent = "turn the light on"; + theme_switcher.setAttribute("title", "turn the light on"); document.documentElement.style.setProperty("--border", "var(--dark-border)"); document.documentElement.style.setProperty("--text", "var(--dark-text)"); document.documentElement.style.setProperty("--bg", "var(--dark-bg)"); @@ -41,7 +41,7 @@ function changeToDarkTheme() { } function changeToLightTheme() { - theme_switcher.textContent = "turn the light off"; + theme_switcher.setAttribute("title", "turn the light off"); document.documentElement.style.setProperty("--border", "var(--light-border)"); document.documentElement.style.setProperty("--text", "var(--light-text)"); document.documentElement.style.setProperty("--bg", "var(--light-bg)"); @@ -84,12 +84,10 @@ window.addEventListener("resize", () => { } }); -main.addEventListener("click", (event) => { +main.addEventListener("click", () => { if (sections_button.getAttribute("opened") === "true") { closeMenu(); } }); -// DEBUG; -console.log(window.innerWidth); -console.log(window.innerHeight); + diff --git a/styles/poster.css b/styles/poster.css index 322e903a..3444f0a7 100644 --- a/styles/poster.css +++ b/styles/poster.css @@ -40,7 +40,6 @@ h2 { font-size: 2rem; } - p { font-size: 1.5rem; } diff --git a/styles/style.css b/styles/style.css index 9ee91891..d34d9d41 100644 --- a/styles/style.css +++ b/styles/style.css @@ -86,10 +86,24 @@ a:focus { } #logo { - font-size: 3rem; + font-size: 2.5rem; font-weight: bold; + font-variant: small-caps; } +#theme-switcher { + border: 3px solid var(--border); + width: 1.5rem; + height: 1.5rem; + border-radius: 3rem; + margin-left: auto; + background: linear-gradient(90deg, var(--border) 0%, var(--border) 50%, var(--bg) 51%, var(--bg) 100%); +} + +#theme-switcher:hover { + border-color: var(--hightlight); + background: linear-gradient(90deg, var(--hightlight) 0%, var(--hightlight) 50%, var(--bg) 51%, var(--bg) 100%); +} .account, .sections, #sections-menu { @@ -150,6 +164,7 @@ button { background: var(--bg); color: var(--text); margin: 0 2rem 0 0; + cursor: pointer; } @media screen and (max-height: 860px), @@ -177,4 +192,9 @@ screen and (max-width: 1500px) { .links { display: none; } + + header, + footer { + padding: 0 1rem; + } } \ No newline at end of file