@@ -98,33 +98,34 @@ const clientThemeCode = `
98
98
// a theme, then I'll know what you want in the future and you'll not see this
99
99
// script anymore.
100
100
;(() => {
101
- const theme = window.matchMedia(${ JSON . stringify ( prefersDarkMQ ) } ).matches
102
- ? 'dark'
103
- : 'light';
101
+ const theme = window.matchMedia('${ prefersDarkMQ } ').matches
102
+ ? '${ Theme . DARK } '
103
+ : '${ Theme . LIGHT } ';
104
+
104
105
const cl = document.documentElement.classList;
105
- const themeAlreadyApplied = cl.contains('light') || cl.contains('dark');
106
- if (themeAlreadyApplied) {
106
+ if (
107
+ cl.contains('${ Theme . LIGHT } ') || cl.contains('${ Theme . DARK } ')
108
+ ) {
109
+ // The theme is already applied...
107
110
// this script shouldn't exist if the theme is already applied!
108
- console.warn(
109
- "Hi there, could you let me know you're seeing this message? Thanks!",
110
- );
111
+ console.warn("See theme-provider.tsx>clientThemeCode>cl.contains");
112
+ // Hi there, could you let me know you're seeing this console.warn? Thanks!
111
113
} else {
112
114
cl.add(theme);
113
115
}
116
+
114
117
const meta = document.querySelector('meta[name=color-scheme]');
115
118
if (meta) {
116
- if (theme === 'dark') {
117
- meta.content = 'dark light';
118
- } else if (theme === 'light') {
119
- meta.content = 'light dark';
120
- }
119
+ meta.content = theme === '${ Theme . DARK } ' ? 'dark light' : 'light dark';
121
120
} else {
122
- console.warn(
123
- "Hey, could you let me know you're seeing this message? Thanks!",
124
- );
121
+ console.warn("See theme-provider.tsx>clientThemeCode>meta");
122
+ // Hey, could you let me know you're seeing this console.warn? Thanks!
125
123
}
126
124
})();
127
- ` ;
125
+ `
126
+ // Remove double slash comments & replace excess white space with a single space.
127
+ . replace ( / ( (?< = [ ^ : ] ) \/ \/ .* | \s ) + / g, ' ' )
128
+ . trim ( ) ;
128
129
129
130
const themeStylesCode = `
130
131
/* default light, but app-preference is "dark" */
0 commit comments