-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for prefers-color-scheme #35
Comments
It'll be nice if whiteglass supports diff --git a/_sass/whiteglass.scss b/_sass/whiteglass.scss
index c4d9def..a7512b7 100644
--- a/_sass/whiteglass.scss
+++ b/_sass/whiteglass.scss
@@ -39,6 +39,20 @@ $on-laptop: 800px !default;
+// Dark mode
+@media (prefers-color-scheme: dark) {
+ html {
+ background-color: invert($background-color);
+ filter: invert(100%) hue-rotate(180deg);
+ }
+
+ iframe, img, video {
+ filter: invert(100%) hue-rotate(180deg);
+ }
+}
+
+
+
// Import partials.
@import
"whiteglass/base",
diff --git a/assets/main.scss b/assets/main.scss
index 6d15a85..e6f1432 100644
--- a/assets/main.scss
+++ b/assets/main.scss
@@ -45,5 +45,19 @@ $on-laptop: 800px;
+// Dark mode
+@media (prefers-color-scheme: dark) {
+ html {
+ background-color: invert($background-color);
+ filter: invert(100%) hue-rotate(180deg);
+ }
+
+ iframe, img, video {
+ filter: invert(100%) hue-rotate(180deg);
+ }
+}
+
+
+
// Import partials from the `whiteglass` theme.
@import "whiteglass"; But this generates an inverted thumbnail when an image is dragged, so I think we should declare CSS for dark mode for each element. |
Jup, I would also argue that you might not want to provide a pitch-black dark mode, so a more delicate approach would be required. Will you take a further look into this? I'm happy to review/test any pulls. |
Inverting colors is a neat trick, but could fail in some exception cases, where the colors were gray or in the middle of the color spectrum. Made my own version for the night and evening time. See live demo on GitHub page: https://dorson.github.io/CSS-Dark-Mode-and-color-switch/ Have fun, feel free to fork, copy, adopt, port, etc... |
I tried using Darkreader browser extension to generate a dark color CSS for my blog using whiteglass theme, and it seems very well: just put its contents inside |
@taoky why don't you at least paste the generated CSS here so we can have a look and maybe use it as the base of a pull request to integrate it into the theme? |
My own website has some modification upon whiteglass style so I guess it's not suitable to directly paste mine here. I will generate another CSS and put it as a gist. |
I'm still a big fan of the theme.
I was wondering if you would consider adding support for a dark theme using the
prefers-color-scheme
media query.I've grown very fond of sites that support a dark theme when reading in low light environments.
The text was updated successfully, but these errors were encountered: