File tree 7 files changed +47
-5
lines changed
7 files changed +47
-5
lines changed Original file line number Diff line number Diff line change 42
42
name ="twitter:description "
43
43
content ="Track, Discover and Share Anime and Manga "
44
44
/>
45
+
46
+ <!-- sets theme before body loads so that we don't get a flash of unstyled content.
47
+ Cannot be of type module, as that will run it after <body> has initialised -->
48
+ < script src ="/src/theme-init.ts "> </ script >
49
+ < link
50
+ rel ="stylesheet "
51
+ type ="text/css "
52
+ href ="/src/styles/index.css "
53
+ media ="screen "
54
+ />
45
55
</ head >
46
56
47
57
< body >
48
- < div id ="app "> <!--ssr-outlet--> </ div >
58
+ < div id ="app ">
59
+ <!--ssr-outlet-->
60
+ </ div >
49
61
< script type ="module " src ="/src/entry-client.tsx "> </ script >
50
62
</ body >
51
63
</ html >
Original file line number Diff line number Diff line change 1
1
/* stylelint-disable scale-unlimited/declaration-strict-value */
2
2
3
- . theme- dark {
3
+ : root[ data-theme = ' dark' ] {
4
4
/***** Color Palette *****/
5
5
--red : # da5e51 ;
6
6
--light-red : # fc755c ;
Original file line number Diff line number Diff line change 1
1
/* stylelint-disable scale-unlimited/declaration-strict-value */
2
2
3
- . theme-light {
3
+ : root {
4
4
/***** Color Palette *****/
5
5
--red : # da5e51 ;
6
6
--light-red : # fc755c ;
Original file line number Diff line number Diff line change 1
1
/* stylelint-disable scale-unlimited/declaration-strict-value */
2
2
3
- . theme- oled {
3
+ : root[ data-theme = ' oled' ] {
4
4
/***** Color Palette *****/
5
5
--red : # da5e51 ;
6
6
--light-red : # fc755c ;
Original file line number Diff line number Diff line change
1
+ // This file is imported directly in index.html to eliminate flash of unstyled content
2
+ // Do NOT add an export statement to this, or it will break
3
+ const themeKey = 'theme' ;
4
+
5
+ const getPreferredTheme = ( ) : string => {
6
+ const storedTheme = localStorage . getItem ( themeKey ) ;
7
+
8
+ return storedTheme ??
9
+ window . matchMedia ( '(prefers-color-scheme: dark)' ) . matches
10
+ ? 'dark'
11
+ : 'light' ;
12
+ } ;
13
+
14
+ const setTheme = ( ) => {
15
+ const body = document . querySelector ( ':root' ) ;
16
+ body ?. setAttribute ( `data-${ themeKey } ` , getPreferredTheme ( ) ) ;
17
+ } ;
18
+
19
+ setTheme ( ) ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "compilerOptions" : {
3
+ "composite" : true ,
4
+ "isolatedModules" : false
5
+ },
6
+ "include" : [" src/theme-init.ts" ]
7
+ }
Original file line number Diff line number Diff line change 20
20
"isolatedModules" : true ,
21
21
"allowJs" : false
22
22
},
23
- "include" : [" ./src" ]
23
+ "include" : [" ./src" ],
24
+ "references" : [
25
+ { "path" : " ./tsconfig.node.json" },
26
+ { "path" : " ./tsconfig.head.json" }
27
+ ]
24
28
}
You can’t perform that action at this time.
0 commit comments