gabotorresruiz commented on code in PR #38399:
URL: https://github.com/apache/superset/pull/38399#discussion_r2885369640


##########
superset/templates/superset/spa.html:
##########
@@ -35,19 +35,35 @@
     {% endblock %}
 
     <style>
+      {% if entry == 'embedded' %}
+      html, body {
+        background: transparent !important;
+      }
+      {% else %}
       body {
-        background: #fff;
+        background: {{ theme_tokens.colorBgBase | default('#fff') }};
         color: #000;
       }
-
-      @media (prefers-color-scheme: dark) {
-        body {
-          background: #000;
-          color: #fff;
-        }
-      }
+      {% endif %}
     </style>
 
+    {% if dark_theme_bg and entry != 'embedded' %}
+    <script nonce="{{ macros.get_nonce() }}">
+      (function() {
+        try {
+          var mode = localStorage.getItem('superset-theme-mode');
+          var shouldBeDark = mode === 'dark' ||
+            (mode !== 'default' && window.matchMedia('(prefers-color-scheme: 
dark)').matches);

Review Comment:
   This is actually intentional. When `localStorage` has no 
`superset-theme-mode` value, ThemeController's `determineInitialMode()` 
defaults to `ThemeMode.SYSTEM`, which follows OS preference. So our inline 
script mirrors that behavior (null is treated the same as 'system')
   
   If we changed to mode === 'system' as suggested, first-time users with dark 
OS would see a light background initially, then `ThemeController` would kick in 
with `SYSTEM --> dark`, causing a light-to-dark flash. The exact problem this 
PR fixes



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to