From a31224318a934cf274d51a160b0b92edaa57985e Mon Sep 17 00:00:00 2001 From: kukimik Date: Thu, 18 Apr 2024 17:58:31 +0200 Subject: [PATCH] dhall-docs: dark mode - default to browser settings --- dhall-docs/src/Dhall/data/assets/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dhall-docs/src/Dhall/data/assets/index.js b/dhall-docs/src/Dhall/data/assets/index.js index 23b310d3f..ab0136880 100644 --- a/dhall-docs/src/Dhall/data/assets/index.js +++ b/dhall-docs/src/Dhall/data/assets/index.js @@ -2,7 +2,8 @@ const DARK_MODE_OPT = 'dark-mode' const DARK_MODE_ACTIVE = 'dark-mode-active' const DARK_MODE_INACTIVE = 'dark-mode-inactive' -if (localStorage.getItem(DARK_MODE_OPT) == DARK_MODE_ACTIVE) { +if (!localStorage.hasOwnProperty(DARK_MODE_OPT) && window.matchMedia('(prefers-color-scheme: dark)').matches + || localStorage.getItem(DARK_MODE_OPT) == DARK_MODE_ACTIVE) { document.documentElement.classList.add('dark-mode') }