diff --git a/app.js b/app.js index ccea8c8..cea0841 100644 --- a/app.js +++ b/app.js @@ -2,7 +2,7 @@ function loadPage(section, page) { let buttons = document.getElementById(section).getElementsByTagName("button"); let currSel; for (let i in buttons) { - if (buttons[i].classList?.contains("sel-btn")) { + if (buttons[i].classList?.contains("selected")) { if (page - 1 == i) return; else { currSel = buttons[i]; @@ -16,9 +16,9 @@ function loadPage(section, page) { .then((data) => { document.getElementById(section + "-content").innerHTML = data; if (currSel) { - currSel.classList.remove("sel-btn"); + currSel.classList.remove("selected"); } - document.getElementById(section).getElementsByTagName("button")[page - 1].classList.add("sel-btn"); + document.getElementById(section).getElementsByTagName("button")[page - 1].classList.add("selected"); }); } @@ -27,9 +27,9 @@ function activeSection(section) { const targetSection = document.getElementById(section); targetSection.style.display = "block"; - setTimeout(()=>{ - targetSection.scrollIntoView({ block: "start", behavior: "smooth" }); - },100) + setTimeout(() => { + targetSection.scrollIntoView({ block: "start", behavior: "smooth" }); + }, 100); } function hideAll() { @@ -37,18 +37,37 @@ function hideAll() { s.style.display = "none"; }); } +const HIDDEN_CLASS = "hidden"; - -function switchTheme(){ - let currTheme = document.documentElement.style.getPropertyValue('color-scheme'); - console.log(currTheme); - if (currTheme == "dark") { - document.getElementsByClassName("fa-sun")[0].style.display = "none"; - document.getElementsByClassName("fa-moon")[0].style.display = "block"; - document.documentElement.style.setProperty('color-scheme', 'light'); +function hideThemeSwitcher(currentTheme) { + if (currentTheme == "dark") { + document.getElementById("dark-icon")?.classList.add(HIDDEN_CLASS); + document.getElementById("light-icon")?.classList.remove(HIDDEN_CLASS); } else { - document.getElementsByClassName("fa-moon")[0].style.display = "none"; - document.getElementsByClassName("fa-sun")[0].style.display = "block"; - document.documentElement.style.setProperty('color-scheme', 'dark'); + document.getElementById("light-icon")?.classList.add(HIDDEN_CLASS); + document.getElementById("dark-icon")?.classList.remove(HIDDEN_CLASS); } -} \ No newline at end of file +} +function getCurrentTheme() { + const fromProperty = document.documentElement.style.getPropertyValue("color-scheme"); + if (fromProperty) return fromProperty; + const prefersTheme = window.matchMedia("(prefers-color-scheme: dark)") ? "dark" : "light"; + return prefersTheme; +} + +function setTheme(newTheme) { + document.documentElement.style.setProperty("color-scheme", newTheme); + hideThemeSwitcher(newTheme); +} + +function switchTheme() { + let currentTheme = getCurrentTheme(); + console.debug("Start theme switching to " + currentTheme + " theme"); + setTheme(currentTheme == "dark" ? "light" : "dark"); +} + +function initColorTheme() { + const currentTheme = getCurrentTheme(); + console.debug("Current theme is " + currentTheme + ""); + setTheme(currentTheme); +} diff --git a/build.sh b/build.sh index 48e19f5..83f25e6 100755 --- a/build.sh +++ b/build.sh @@ -22,14 +22,14 @@ write_section_header(){ - echo "

" >> $3 + echo "

" >> $3 echo "$2" | tr a-z A-Z >> $3 echo "

" >> $3 } write_img(){ - echo " -\"$1\"" >> $2 + echo " +$1" >> $2 } rm *.html @@ -37,32 +37,30 @@ rm *.html touch ./index.html echo " - + - + - + Gruvbox wallpapers - - + + -
- -
- -

Gruvbox Wallpapers

" > ./index.html @@ -85,16 +83,16 @@ do subhtml="${section}_page${page}.html" touch ./$subhtml - echo "
" >> ./index.html + echo "
" >> ./index.html - echo "
" >> ./index.html + echo "
" >> ./index.html countImgs=$(find "$subdir" -type f | wc -l) countImgs=$((countImgs - 1)) for i in $(seq 1 $((( $countImgs / $maxPerPage)+1))); do - echo "" >> ./index.html + echo "" >> ./index.html done echo "
" >> ./index.html - echo "
" >> ./index.html + echo "
" >> ./index.html echo "
" >> ./$subhtml for wallpaper in ${subdir}/* do @@ -128,18 +126,14 @@ done echo "" >> ./index.html diff --git a/style.css b/style.css index 9cbfc38..4c32a10 100644 --- a/style.css +++ b/style.css @@ -8,6 +8,7 @@ --fg-color-reverse: light-dark(#fbf1c7, #282828); --bg-color-3: light-dark(#bdae93, #665c54); + --bg-color-3-switch: light-dark(#665c54, #bdae93); --bg-color-hard: light-dark(#f9f5d7, #1d2021); --gray: light-dark(#7c6f64, #a89984); } @@ -19,8 +20,9 @@ body { font-family: "Curier New", monospace; } -*:not( i ) { +* { color: var(--fg-color); + border: none; } h1, @@ -87,27 +89,33 @@ img:hover { margin-top: 5px; margin-bottom: 10px; padding: 5px; - /*border-radius: 8px; */ color: var(--fg-color-reverse); - /*display: flex; - justify-content: center;*/ text-align: center; } -.pager button { +.btn { + cursor: pointer; background-color: var(--bg-color-reverse); - border: none; color: var(--fg-color-reverse); + + /* Horizontal and vertical center content */ + display: inline-flex; + flex-direction: column; + justify-content: center; + align-items: center; + + &:hover { + background-color: var(--bg-color-3-switch); + } +} + +.btn.pager-btn { padding: 10px 20px; - text-align: center; - text-decoration: none; - display: inline-block; font-size: 16px; font-weight: 900; margin: 4px 2px; - cursor: pointer; - &.sel-btn { + &.selected { background-color: var(--bg-color); color: var(--fg-color); @@ -125,26 +133,25 @@ img:hover { display: none; } -.float-btns{ +.float-btns { position: fixed; - /*top: 80%;*/ - bottom: 10px; - right: 35px; + bottom: 1rem; + right: 2rem; + display: flex; + flex-direction: column; + gap: 0.5rem; } -.float-btn{ - background-color: var(--bg-color-reverse); - border: none; - color: var(--fg-color-reverse); - text-align: center; - text-decoration: none; - display: inline-block; +.btn.float-btn { height: 2.5rem; width: 2.5rem; - margin-bottom: 10px; + font-size: 1.5rem; + + & i { + color: var(--fg-color-reverse); + } } -.float-btn span{ - font-size: 1.5rem; - color: var(--fg-color-reverse); -} \ No newline at end of file +.hidden { + display: none !important; +}