bugfix theme/css
This commit is contained in:
parent
b39c4102ed
commit
65a6bdbb99
@ -2,9 +2,6 @@
|
|||||||
* Version: 1.0.0
|
* Version: 1.0.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* :root { */
|
|
||||||
/* color-scheme: only light; */
|
|
||||||
/* } */
|
|
||||||
html,
|
html,
|
||||||
body {
|
body {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
@ -57,7 +54,6 @@ ul.dashed {
|
|||||||
|
|
||||||
html.theme-dark {
|
html.theme-dark {
|
||||||
color-scheme: dark;
|
color-scheme: dark;
|
||||||
background-image: none;
|
|
||||||
background-image: linear-gradient(-10deg, #1010206F 60%, #5050506F);
|
background-image: linear-gradient(-10deg, #1010206F 60%, #5050506F);
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<header><button title="Dark theme on/off" onclick="toggleTheme();">☀</button></header>
|
<header>
|
||||||
|
<button title="Dark theme on/off" onclick="toggleTheme();">☀</button>
|
||||||
|
</header>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<h1>Ward Truyen home</h1>
|
<h1>Ward Truyen home</h1>
|
||||||
|
@ -2,6 +2,11 @@ function toggleTheme() {
|
|||||||
const theme = "theme-dark";//localStorage.getItem('theme');
|
const theme = "theme-dark";//localStorage.getItem('theme');
|
||||||
const root = document.querySelector(":root");
|
const root = document.querySelector(":root");
|
||||||
root.classList.toggle(theme);
|
root.classList.toggle(theme);
|
||||||
|
if (root.classList.contains(theme)) {
|
||||||
|
localStorage.setItem('theme', theme);
|
||||||
|
} else {
|
||||||
|
localStorage.setItem('theme', "theme-light");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setTheme(themeName) {
|
function setTheme(themeName) {
|
||||||
@ -23,12 +28,11 @@ function detectTheme() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (window.matchMedia('(prefers-color-scheme: light)').matches) {
|
if (window.matchMedia('(prefers-color-scheme: light)').matches) {
|
||||||
// setTheme('theme-light');
|
setTheme('theme-light');
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// setTheme('theme-light');
|
setTheme('theme-light');
|
||||||
}
|
}
|
||||||
detectTheme();
|
detectTheme();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user