File tree 3 files changed +10
-3
lines changed
3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change 1
1
<!DOCTYPE html>
2
- < html lang ="en " class =" dark " >
2
+ < html lang ="en ">
3
3
< head >
4
4
< meta charset ="UTF-8 ">
5
5
< link rel ="icon " href ="/favicon.ico ">
Original file line number Diff line number Diff line change @@ -20,10 +20,10 @@ let isDark = ref(html?.classList.contains('dark'))
20
20
function toggleDark() {
21
21
if (isDark .value ) {
22
22
html ?.classList .remove (' dark' )
23
- isDark .value = false
24
23
} else {
25
24
html ?.classList .add (' dark' )
26
- isDark .value = true
27
25
}
26
+ isDark .value = ! isDark .value
27
+ localStorage .setItem (' color-scheme' , isDark .value ? ' dark' : ' light' )
28
28
}
29
29
</script >
Original file line number Diff line number Diff line change @@ -4,6 +4,13 @@ import './tailwind.css'
4
4
import App from './demo/App.vue'
5
5
import VueTw from '.'
6
6
7
+ const colorScheme = localStorage . getItem ( 'color-scheme' )
8
+ if ( colorScheme === 'dark' ) {
9
+ document . querySelector ( 'html' ) ?. classList . add ( 'dark' )
10
+ } else {
11
+ document . querySelector ( 'html' ) ?. classList . remove ( 'dark' )
12
+ }
13
+
7
14
const router = createRouter ( {
8
15
history : createWebHistory ( ) ,
9
16
routes : [ ] ,
You can’t perform that action at this time.
0 commit comments