From 3df6c1bde7882466bdf882923d8af531da2a5d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 3 Dec 2023 15:25:30 +0100 Subject: [PATCH] openapi: switch color on OS color scheme change #745 --- exampleSite/layouts/partials/menu-footer.html | 3 +++ static/js/theme.js | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/exampleSite/layouts/partials/menu-footer.html b/exampleSite/layouts/partials/menu-footer.html index 4ffbe01022..5e180bc42a 100644 --- a/exampleSite/layouts/partials/menu-footer.html +++ b/exampleSite/layouts/partials/menu-footer.html @@ -36,5 +36,8 @@ // we have to wait until the CSS class .default-animation has settled and and the buttons have loaded to recalculate the scheme again setTimeout( githubButtonsInit, 400 ); }); + window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { + setTimeout( githubButtonsInit, 400 ); + }); \ No newline at end of file diff --git a/static/js/theme.js b/static/js/theme.js index 70eac20a29..e868406832 100644 --- a/static/js/theme.js +++ b/static/js/theme.js @@ -1665,3 +1665,9 @@ ready( function(){ moveTopbarButtons(); adjustEmptyTopbarContents(); })(); + +(function(){ + window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => { + initOpenapi( true ); + }); +})();