This commit is contained in:
Daniel Flanagan 2022-05-25 09:48:16 -05:00
parent 112895db10
commit 435c1c87e0
Signed by: lytedev
GPG Key ID: 5B2020A0F9921EF4
4 changed files with 19 additions and 34 deletions

View File

@ -15,7 +15,7 @@
<header> <header>
<a href="#start-of-content" class="hide-unless-focused">Skip to Content</a> <a href="#start-of-content" class="hide-unless-focused">Skip to Content</a>
<section> <section>
<a href="/" aria-label="index link" id="logo"> <a href="/" aria-label="index link" id="logo" title="go to site index">
{{ partial "logo.svg.html" . }} {{ partial "logo.svg.html" . }}
</a> </a>
<a href="/"> <a href="/">
@ -32,11 +32,11 @@
<a href="{{ .URL }}">{{ .Name }}</a> <a href="{{ .URL }}">{{ .Name }}</a>
{{ end }} {{ end }}
</section> </section>
<section style="position:absolute;height:100%;right:0"> <section style="position:absolute;height:100%;right:0" aria-hidden="true">
<button class="no-bg theme-toggler js-only centerize" aria-label="toggle dark theme"> <button class="no-bg theme-toggler js-only centerize" aria-label="toggle dark theme" title="toggle dark theme">
{{ partial "theme-toggle.html" . }} {{ partial "theme-toggle.html" . }}
</button> </button>
<button class="no-bg align-toggler js-only hidden-on-mobile centerize" aria-label="toggle text alignment"> <button class="no-bg align-toggler js-only hidden-on-mobile centerize" aria-label="toggle text alignment" title="toggle text alignment">
{{ partial "align-toggle.html" . }} {{ partial "align-toggle.html" . }}
</button> </button>
</section> </section>

View File

@ -221,7 +221,7 @@ ul.horizontal-blocks
flex-grow 1 flex-grow 1
display flex display flex
padding 0.5em 2em padding 0.5em 2em
background-color rgba(255, 255, 255, 0.05) background-color var(--header-bg)
text-align center text-align center
justify-content center justify-content center
align-items center align-items center
@ -229,5 +229,5 @@ ul.horizontal-blocks
white-space nowrap white-space nowrap
&:hover &:hover
background-color rgba(255, 255, 255, 0.1) background-color var(--header-hover-bg)

View File

@ -101,3 +101,7 @@ body.dark-theme .hide-in-dark-theme { display: none }
body.dark-theme .hide-in-light-theme { display: inherit } body.dark-theme .hide-in-light-theme { display: inherit }
body.light-theme .hide-in-dark-theme { display: inherit } body.light-theme .hide-in-dark-theme { display: inherit }
body.light-theme .hide-in-light-theme { display: none } 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 }
}

View File

@ -1,27 +1,11 @@
const body = document.body const body = document.body
const queryAll = sel => document.querySelectorAll(sel) const queryAll = sel => document.querySelectorAll(sel)
const initTheme = () => { const resetTheme = () => {
const curTheme = localStorage.getItem('theme') body.classList.remove('dark-theme', 'light-theme')
const oldTheme = curTheme == 'dark' ? 'light' : 'dark'
body.classList.add(`${curTheme}-theme`)
body.classList.remove(`${oldTheme}-theme`)
} }
if (localStorage.getItem('theme') === null) { queryAll('.theme-toggler').forEach(a => a.addEventListener('click', () => console.log('yo')))
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('.js-only').forEach(a => a.classList.remove('js-only')) queryAll('.js-only').forEach(a => a.classList.remove('js-only'))
queryAll('.js-disabled-only').forEach(a => a.remove()) queryAll('.js-disabled-only').forEach(a => a.remove())
@ -39,18 +23,15 @@ initAlign()
const toggleAlign = ev => { const toggleAlign = ev => {
localStorage.setItem('align', localStorage.getItem('align') == 'center' ? 'left' : 'center') localStorage.setItem('align', localStorage.getItem('align') == 'center' ? 'left' : 'center')
initAlign() initAlign()
if (!!ev.target) ev.preventDefault() if (ev.target) ev.preventDefault()
return false return false
} }
queryAll('.align-toggler').forEach(a => a.addEventListener('click', toggleAlign)) queryAll('.align-toggler').forEach(a => a.addEventListener('click', toggleAlign))
window.addEventListener('load', _ev => { window.addEventListener('load', _ev => {
console.log('loaded')
const selector = [1, 2, 3, 4, 5, 6].map(n => `h${n}[id]`).join(',') const selector = [1, 2, 3, 4, 5, 6].map(n => `h${n}[id]`).join(',')
console.log(selector)
queryAll(selector).forEach(el => { queryAll(selector).forEach(el => {
console.log(el)
const anchorLink = document.createElement('a') const anchorLink = document.createElement('a')
anchorLink.classList.add('anchor-link') anchorLink.classList.add('anchor-link')
anchorLink.textContent = '§' anchorLink.textContent = '§'