Compare commits
2 commits
10b5ce30a3
...
aa9153e50d
Author | SHA1 | Date | |
---|---|---|---|
aa9153e50d | |||
dba1380966 |
2 changed files with 18 additions and 15 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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') {
|
||||||
|
|
Loading…
Add table
Reference in a new issue