File tree 2 files changed +62
-11
lines changed 2 files changed +62
-11
lines changed Original file line number Diff line number Diff line change @@ -384,6 +384,44 @@ following diagram.
384
384
.. raw :: html
385
385
:file: logging_flow.svg
386
386
387
+ .. raw :: html
388
+
389
+ <script >
390
+ /*
391
+ * This snippet is needed to handle the case where a light or dark theme is
392
+ * chosen via the theme is selected in the page. We call the existing handler
393
+ * and then add a dark-theme class to the body when the dark theme is selected.
394
+ * The SVG styling (above) then does the rest.
395
+ *
396
+ * If the pydoc theme is updated to set the dark-theme class, this snippet
397
+ * won't be needed any more.
398
+ */
399
+ (function () {
400
+ var oldActivateTheme = activateTheme;
401
+
402
+ function updateBody (theme ) {
403
+ let elem = document .body ;
404
+
405
+ if (theme === ' dark' ) {
406
+ elem .classList .add (' dark-theme' );
407
+ }
408
+ else {
409
+ elem .classList .remove (' dark-theme' );
410
+ }
411
+ }
412
+
413
+ activateTheme = function (theme ) {
414
+ oldActivateTheme (theme);
415
+ updateBody (theme);
416
+ };
417
+ /*
418
+ * If the page is refreshed, make sure we update the body - the overriding
419
+ * of activateTheme won't have taken effect yet.
420
+ */
421
+ updateBody (localStorage .getItem (' currentTheme' ) || ' auto' );
422
+ })();
423
+ </script >
424
+
387
425
Loggers
388
426
^^^^^^^
389
427
You can’t perform that action at this time.
0 commit comments