From e281834c9ae9b27e7e42810465c8802b66fd6488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Kukie=C5=82a?= <53443372+kukimik@users.noreply.github.com> Date: Sat, 11 May 2024 05:34:29 +0200 Subject: [PATCH] dhall-docs: dark mode - default to browser settings (#2582) --- 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') }