@@ -98,33 +98,34 @@ const clientThemeCode = `
9898// a theme, then I'll know what you want in the future and you'll not see this
9999// script anymore.
100100;(() => {
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+
104105 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...
107110 // 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!
111113 } else {
112114 cl.add(theme);
113115 }
116+
114117 const meta = document.querySelector('meta[name=color-scheme]');
115118 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';
121120 } 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!
125123 }
126124})();
127- ` ;
125+ `
126+ // Remove double slash comments & replace excess white space with a single space.
127+ . replace ( / ( (?< = [ ^ : ] ) \/ \/ .* | \s ) + / g, ' ' )
128+ . trim ( ) ;
128129
129130const themeStylesCode = `
130131 /* default light, but app-preference is "dark" */
0 commit comments