From 435c1c87e07073638d227bc6a7682fbeb7532575 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Wed, 25 May 2022 09:48:16 -0500 Subject: [PATCH] WIP --- layouts/_default/baseof.html | 18 +++++++++--------- src/stylus/core.styl | 4 ++-- src/stylus/theme.styl | 4 ++++ static/global.js | 27 ++++----------------------- 4 files changed, 19 insertions(+), 34 deletions(-) diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index b26ca60..cea773a 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -15,7 +15,7 @@
Skip to Content
- @@ -25,18 +25,18 @@
{{ $currentPage := . }} {{ range .Site.Menus.main }} - {{ $active := or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} - {{ $active = or $active (eq .Name $currentPage.Title) }} - {{ $active = or $active (and (eq .Name "Blog") (eq $currentPage.Section "post")) }} - {{ $active = or $active (and (eq .Name "Tags") (eq $currentPage.Section "tags")) }} - {{ .Name }} + {{ $active := or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} + {{ $active = or $active (eq .Name $currentPage.Title) }} + {{ $active = or $active (and (eq .Name "Blog") (eq $currentPage.Section "post")) }} + {{ $active = or $active (and (eq .Name "Tags") (eq $currentPage.Section "tags")) }} + {{ .Name }} {{ end }}
-
- -
diff --git a/src/stylus/core.styl b/src/stylus/core.styl index fe67d02..d8b510c 100644 --- a/src/stylus/core.styl +++ b/src/stylus/core.styl @@ -221,7 +221,7 @@ ul.horizontal-blocks flex-grow 1 display flex padding 0.5em 2em - background-color rgba(255, 255, 255, 0.05) + background-color var(--header-bg) text-align center justify-content center align-items center @@ -229,5 +229,5 @@ ul.horizontal-blocks white-space nowrap &:hover - background-color rgba(255, 255, 255, 0.1) + background-color var(--header-hover-bg) diff --git a/src/stylus/theme.styl b/src/stylus/theme.styl index aed527d..961e3b2 100644 --- a/src/stylus/theme.styl +++ b/src/stylus/theme.styl @@ -101,3 +101,7 @@ body.dark-theme .hide-in-dark-theme { display: none } body.dark-theme .hide-in-light-theme { display: inherit } body.light-theme .hide-in-dark-theme { display: inherit } body.light-theme .hide-in-light-theme { display: none } + +@media (prefers-reduced-motion: no-preference) { + * { transition: background-color 0.2s ease, color 0.2s ease } +} diff --git a/static/global.js b/static/global.js index 0e3a632..6f00ade 100644 --- a/static/global.js +++ b/static/global.js @@ -1,27 +1,11 @@ const body = document.body const queryAll = sel => document.querySelectorAll(sel) -const initTheme = () => { - const curTheme = localStorage.getItem('theme') - const oldTheme = curTheme == 'dark' ? 'light' : 'dark' - body.classList.add(`${curTheme}-theme`) - body.classList.remove(`${oldTheme}-theme`) +const resetTheme = () => { + body.classList.remove('dark-theme', 'light-theme') } -if (localStorage.getItem('theme') === null) { - localStorage.setItem('theme', window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light') -} - -initTheme() - -const toggleTheme = ev => { - localStorage.setItem('theme', localStorage.getItem('theme') == 'dark' ? 'light' : 'dark') - initTheme() - if (!!ev.target) ev.preventDefault() - return false -} - -queryAll('.theme-toggler').forEach(a => a.addEventListener('click', toggleTheme)) +queryAll('.theme-toggler').forEach(a => a.addEventListener('click', () => console.log('yo'))) queryAll('.js-only').forEach(a => a.classList.remove('js-only')) queryAll('.js-disabled-only').forEach(a => a.remove()) @@ -39,18 +23,15 @@ initAlign() const toggleAlign = ev => { localStorage.setItem('align', localStorage.getItem('align') == 'center' ? 'left' : 'center') initAlign() - if (!!ev.target) ev.preventDefault() + if (ev.target) ev.preventDefault() return false } queryAll('.align-toggler').forEach(a => a.addEventListener('click', toggleAlign)) window.addEventListener('load', _ev => { - console.log('loaded') const selector = [1, 2, 3, 4, 5, 6].map(n => `h${n}[id]`).join(',') - console.log(selector) queryAll(selector).forEach(el => { - console.log(el) const anchorLink = document.createElement('a') anchorLink.classList.add('anchor-link') anchorLink.textContent = 'ยง' -- 2.47.0