From 0540f3cfdef4a21edacdb56078ee1251ebb2322f Mon Sep 17 00:00:00 2001 From: jtagcat Date: Wed, 12 Aug 2020 17:49:35 +0300 Subject: [PATCH] Add support for prefers-color-scheme: dark. Light is ignored, since it can mean 'unset'. https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme --- layouts/partials/header.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/layouts/partials/header.html b/layouts/partials/header.html index dd941ec..fbc0e4a 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -45,7 +45,7 @@ let sunset; function setBodyClass() { - if (now > sunrise && now < sunset) return; + if (window.matchMedia("(prefers-color-scheme: dark)").matches || now > sunrise && now < sunset) return; document.body.classList.add('dark'); }