Compare commits

...

2 commits

Author SHA1 Message Date
aa9153e50d light theme is default now
All checks were successful
/ build (push) Successful in 28s
2025-03-21 17:03:44 -07:00
dba1380966 fix light toggle 2025-03-21 17:01:57 -07:00
2 changed files with 18 additions and 15 deletions

View file

@ -9,18 +9,18 @@ html {
--font-family: comic-mono Consolas sans-serif; --font-family: comic-mono Consolas sans-serif;
--syntax-tab-size: 2; --syntax-tab-size: 2;
--background-color: var(--xkcd-very-dark-brown); --background-color: var(--xkcd-eggshell);
--text-color: var(--xkcd-light-grey); --text-color: var(--xkcd-dark-grey);
--text-color-link: var(--xkcd-steel-blue); --text-color-link: var(--xkcd-teal);
--accent-color: var(--xkcd-bronze); --accent-color: var(--xkcd-red-orange);
} }
@media(prefers-color-scheme: light) { @media(prefers-color-scheme: dark) {
html { html {
--background-color: var(--xkcd-eggshell); --background-color: var(--xkcd-very-dark-brown);
--text-color: var(--xkcd-dark-grey); --text-color: var(--xkcd-light-grey);
--text-color-link: var(--xkcd-teal); --text-color-link: var(--xkcd-steel-blue);
--accent-color: var(--xkcd-red-orange); --accent-color: var(--xkcd-bronze);
} }
} }

View file

@ -1,5 +1,12 @@
function themeToggle() { function themeToggle() {
const oldValue = localStorage.getItem('theme'); let oldValue = localStorage.getItem('theme');
if (!oldValue) {
oldValue = 'light';
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
oldValue = 'dark';
}
}
let newValue; let newValue;
if (oldValue == 'light') { if (oldValue == 'light') {
newValue = 'dark'; newValue = 'dark';
@ -15,11 +22,7 @@ function themeClear() {
themeRefresh(); themeRefresh();
} }
function themeRefresh(newValue) { function themeRefresh() {
if (newValue !== undefined) {
localStorage.setItem('theme', newValue);
}
const theme = localStorage.getItem('theme') const theme = localStorage.getItem('theme')
const el = document.getElementsByTagName('html')[0]; const el = document.getElementsByTagName('html')[0];
if (theme == 'light') { if (theme == 'light') {