perf: optimize dark and light mode toggle
This commit is contained in:
parent
96286031ff
commit
d9c4d973b3
|
@ -56,6 +56,11 @@ code-theme(mode) {
|
|||
code-theme('light');
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
code-theme('light');
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
|
|
|
@ -140,6 +140,11 @@ root-color(mode) {
|
|||
root-color('light');
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: light) {
|
||||
:root {
|
||||
root-color('light');
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
|
|
|
@ -9,6 +9,7 @@ KEEP.initModeToggle = () => {
|
|||
|
||||
enableLightMode() {
|
||||
document.body.classList.remove('dark-mode');
|
||||
document.body.classList.add('light-mode');
|
||||
this.iconDom.className = 'fas fa-moon';
|
||||
KEEP.styleStatus.isDark = false;
|
||||
KEEP.setStyleStatus();
|
||||
|
@ -16,6 +17,7 @@ KEEP.initModeToggle = () => {
|
|||
|
||||
enableDarkMode() {
|
||||
document.body.classList.add('dark-mode');
|
||||
document.body.classList.remove('light-mode');
|
||||
this.iconDom.className = 'fas fa-sun';
|
||||
KEEP.styleStatus.isDark = true;
|
||||
KEEP.setStyleStatus();
|
||||
|
|
Loading…
Reference in New Issue