Initial commit on Forgejo
Fresh repository history for elektrine/tarakan hosted at https://git.elektrine.com/elektrine/tarakan.
This commit is contained in:
commit
af6077b9c3
455 changed files with 78366 additions and 0 deletions
21
assets/js/theme.js
Normal file
21
assets/js/theme.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Runs blocking in <head>, before the first paint.
|
||||
//
|
||||
// app.js is a deferred module, so anything it does happens after the browser
|
||||
// has already drawn the page - which is why the theme toggle used to flash the
|
||||
// wrong option on load, and why a manually chosen theme would show a frame of
|
||||
// the OS one first. This has to stay a classic script with no defer/async, and
|
||||
// it has to stay small enough that blocking on it is free.
|
||||
//
|
||||
// Absent attribute means "follow the OS", so the only work here is restoring a
|
||||
// manual choice. Everything else - the pressed styling, the toggle handlers -
|
||||
// is CSS and app.js respectively.
|
||||
(function () {
|
||||
try {
|
||||
var theme = localStorage.getItem("tarakan:theme")
|
||||
if (theme === "light" || theme === "dark") {
|
||||
document.documentElement.setAttribute("data-theme", theme)
|
||||
}
|
||||
} catch (_error) {
|
||||
// Private mode or blocked storage: fall through to the OS preference.
|
||||
}
|
||||
})()
|
||||
Loading…
Add table
Add a link
Reference in a new issue