News for hackers. Stuff that matters.
Re:Using Dark Mode in CSS with MacOS Mojave by modernerd on Thursday October 25, 2018 @04:41AM (#18299428)
This is a great blog post to build awareness of the prefers-color-scheme feature.

But I don't think it's safe to assume that someone who sets a dark UI also wants web pages displayed like that.

I set dark mode in macOS to have the UI fade into the background and reveal the content; I don't want or expect that websites will present white text on a dark background too. That's fine for coding but can be less readable for long form articles depending on the ambient lighting.

https://ux.stackexchange.com/q/53264/

Re:Using Dark Mode in CSS with MacOS Mojave by S_A_P on Thursday October 25, 2018 @07:34AM (#18300102)
As a counterpoint, I find a white app or webpage jarring in dark mode and much prefer light/white text on dark background. I’m happy that the rest of the os is catching up with how I’ve run my IDE for years.
Re:Using Dark Mode in CSS with MacOS Mojave by Cub3 on Thursday October 25, 2018 @11:53AM (#18301857)
Agreed, i've been using the DarkReader extension to make everything 'Dark Mode'

https://darkreader.org/

Re:Using Dark Mode in CSS with MacOS Mojave by wlesieutre on Thursday October 25, 2018 @02:26PM (#18303270)
Another option for Safari is Nightlight

https://www.gofake1.net/projects/nightlight.html

Re:Using Dark Mode in CSS with MacOS Mojave by hnarayanan on Thursday October 25, 2018 @08:38AM (#18300399)
I agree. It is extremely jarring to have light content in an otherwise intentionally dark-moded interface.
Re:Using Dark Mode in CSS with MacOS Mojave by Fuxy on Thursday October 25, 2018 @10:56AM (#18301363)
it is but it's not feasible for the system theme to change the styles of websites.

Just ask any Linux user that uses dark themes and you will find out what happens when the system theme messes with the site theme.

I myself always set a light theme in my Firefox config so I don't get a black on black text/background issue.

With how customized the styling on sites is every site needs to implement their own dark version otherwise you will run into situations where the styling is broken.

Re:Using Dark Mode in CSS with MacOS Mojave by SpacePotatoe on Thursday October 25, 2018 @11:21AM (#18301576)
>it is but it's not feasible for the system theme to change the styles of websites. Just ask any Linux user that uses dark themes and you will find out what happens when the system theme messes with the site theme.

It is done completely different fashion than it was done on gnu/linux, on linux it was probably done by changing user agent style sheet (changes default bg color on body etc), when here it is done with media query (which webdev must explicit implement on his part so he can make sure that everything works).

Re:Using Dark Mode in CSS with MacOS Mojave by S_A_P on Thursday October 25, 2018 @11:10AM (#18301478)
That I agree with, and this "responsibility" ultimately falls on the webmaster/content provider to allow a dark theme in a method similar to this post...
Re:Using Dark Mode in CSS with MacOS Mojave by jackpeterfletch on Thursday October 25, 2018 @10:36AM (#18301191)
Well in this camp. I know there's evidence to suggest that black on white is better for reading comprehension, but I honestly find it straining.

To me black on white is just a hangover from old skeuomorphic design principles.

Re:Using Dark Mode in CSS with MacOS Mojave by Fuxy on Thursday October 25, 2018 @11:01AM (#18301403)
I found that black background with white text is great when you have perfect eyesight but once your eyesight starts to go and you start needing glasses white background with black text is easier to read.

it's quite odd. It could be just a personal thing though.

Re:Using Dark Mode in CSS with MacOS Mojave by mixmastamyk on Thursday October 25, 2018 @11:55AM (#18301879)
Don't believe so, have preferred dark themes and worn glasses for twenty years.

The bigger factor seems to be environment you are currently in:

- Fluorescent operating room/accountant's office/Initech --> white backgrounds needed.

- Darkened lab/color-correct studio/night-time --> dark backgrounds.

And of course this has gotten worse over the years as control over the gui theme has been lost.

Re:Using Dark Mode in CSS with MacOS Mojave by stephenr on Thursday October 25, 2018 @05:33AM (#18299601)
I'd assume this is intended for web pages/apps to allow their in-page controls/navigation to fade into the background, revealing the content.

E.g. in a crud app with top/side nav, and then a form in the main section, the nav bars can be rendered as pale/dark to suit the user selection, while the main content area retains the focus.

Re:Using Dark Mode in CSS with MacOS Mojave by modernerd on Thursday October 25, 2018 @05:42AM (#18299646)
Yes, I definitely see the appeal for web apps.

Just personally don't want to read 2,000+ word articles of white text on a dark background just because I like the browser UI to be dark. Others might, though — hopefully browsers will offer a setting for dark mode independent of the OS-level setting.

Re:Using Dark Mode in CSS with MacOS Mojave by eecc on Thursday October 25, 2018 @06:30AM (#18299839)
That’s up to website developer to make a mess of it, or to desaturate the normal color scheme or whatever other pleasant option.
Re:Using Dark Mode in CSS with MacOS Mojave by stephenr on Friday October 26, 2018 @06:34AM (#18308079)
I think it'll be a while before most sites even consider adopting this (it's not even listed to check support on caniuse.com), and even if it does become widespread, reader mode has style-override controls to make the page more suitable for long-form reading just as it does now.
Re:Using Dark Mode in CSS with MacOS Mojave by ThomPete on Thursday October 25, 2018 @10:18AM (#18301065)
Exactly! That's my take on this too.

Dark Mode should only be for UI elements not for actual content. They would never do that with a PDF either.

Re:Using Dark Mode in CSS with MacOS Mojave by josho on Thursday October 25, 2018 @10:58AM (#18301381)
Curious, I ended up turning off dark mode because I found web pages were jarringly bright compared to everything else on the screen.
Re:Using Dark Mode in CSS with MacOS Mojave by Fuxy on Thursday October 25, 2018 @11:04AM (#18301419)
Don't you use websites that have a dark theme more instead. I always preferred websites that allowed me to select a dark theme and it seems to be more and more popular to do that.

Hell even you-tube does that now.

Re:Using Dark Mode in CSS with MacOS Mojave by josho on Thursday October 25, 2018 @02:00PM (#18302995)
This is great, it means many sites won't have much work to support the CSS media query.

I still would prefer to change a setting once, rather than establish a profile on every website to enable a dark theme.

Re:Using Dark Mode in CSS with MacOS Mojave by Sharlin on Thursday October 25, 2018 @02:23PM (#18303236)
Well, Youtube should have had a dark theme from day one. It makes zero sense to show videos on a bright white background.
Re:Using Dark Mode in CSS with MacOS Mojave by michaelmior on Thursday October 25, 2018 @10:34AM (#18301175)
It's really a matter of preference. I personally would be happy if my PDFs would automatically display in "dark mode" (not that I expect that to be implemented). Perhaps browsers just need a setting to toggle this.
Re:Using Dark Mode in CSS with MacOS Mojave by mixmastamyk on Thursday October 25, 2018 @12:16PM (#18302047)
Ctrl+I on Evince/Atril doc viewers. Then set as default: Ctrl+T
Re:Using Dark Mode in CSS with MacOS Mojave by michaelmior on Friday October 26, 2018 @07:40AM (#18308336)
On Linux I use MuPDF which can also invert. (Although this isn't really "dark mode", since most PDF documents are black text on white, it gets the job done.)
Re:Using Dark Mode in CSS with MacOS Mojave by Fuxy on Thursday October 25, 2018 @11:06AM (#18301445)
Moon reader + on android allows you to invert the colours and that's what I do every time when I read pdf's and the like.
Re:Using Dark Mode in CSS with MacOS Mojave by scroblart on Thursday October 25, 2018 @09:40PM (#18306113)
It is nice to have the option of map pdf colors to correspond to one's color theme.

I like to read pdfs in emacs alongside my notes, and I am very pleased that emacs' pdf-tools allows me to map colors as I choose (kind of - there are only two colors, foreground and background).

Re:Using Dark Mode in CSS with MacOS Mojave by consto on Thursday October 25, 2018 @11:20AM (#18301561)
Why not? I have a chrome extension to darken and/or invert webpages and PDFs, and I have SumatraPDF setup white text on black background for editing LaTeX?
Re:Using Dark Mode in CSS with MacOS Mojave by morley on Thursday October 25, 2018 @08:33AM (#18300371)
This is why I think they should focus on exposing the dark mode setting in Javascript instead of CSS.

Sites that support dark mode should (and will almost always) have a toggle for it. It'd be better if this setting helped _inform_ the default initial state rather than _forcing_ a choice on you. To me, that's a lot easier done with a Javascript API than CSS.

Re:Using Dark Mode in CSS with MacOS Mojave by yunyu on Thursday October 25, 2018 @08:37AM (#18300393)
You'd be able to do this with the matchMedia API: https://developer.mozilla.org/en-US/docs/Web/API/Window/matc...
Re:Using Dark Mode in CSS with MacOS Mojave by morley on Thursday October 25, 2018 @10:59AM (#18301391)
I didn't know about that, thanks for that!
Re:Using Dark Mode in CSS with MacOS Mojave by stephenr on Thursday October 25, 2018 @10:53AM (#18301322)
More javascript is almost never the best solution to any problem, particular when it’s shown that css can achieve the same result.
Re:Using Dark Mode in CSS with MacOS Mojave by morley on Thursday October 25, 2018 @11:00AM (#18301398)
My argument is that CSS doesn't achieve the same result; it forces one particular mode on you instead of allowing a choice.
Re:Using Dark Mode in CSS with MacOS Mojave by stephenr on Thursday October 25, 2018 @11:11AM (#18301487)
You have all the choice in the world. Use whatever tech you want (browser js, server side templating, client side xslt, etc) to have an attribute on the body element indicating opt-in status, and use that in your media query to target only the users who want it.

With the css solution it’s doable on a site that has no javascript.

Re:Using Dark Mode in CSS with MacOS Mojave by int_19h on Thursday October 25, 2018 @02:57PM (#18303548)
The right place for the switch in this case is the browser. The browser should have a button for light/dark/system, defaulting to system. And CSS should follow that.

JS should not be involved, and we don't need every site to have its own version of the switch, located in a different place and looking different.

Re:Using Dark Mode in CSS with MacOS Mojave by reaperducer on Thursday October 25, 2018 @04:12PM (#18304188)
You don't need Javascript to implement a switch that changes from light mode to dark mode. That can be easily done in CSS. I've done it on web sites to switch to a high-contrast color scheme for people with vision difficulties.
Re:Using Dark Mode in CSS with MacOS Mojave by codazoda on Thursday October 25, 2018 @09:24AM (#18300692)
You could easily apply or remove the css via Javascript to allow enable / disable of the feature.
Re:Using Dark Mode in CSS with MacOS Mojave by giobox on Thursday October 25, 2018 @11:06AM (#18301438)
Exactly. This is going to be the simplest browser extension anyone has ever written, if someone hasn’t done so already.
Re:Using Dark Mode in CSS with MacOS Mojave by reificator on Thursday October 25, 2018 @01:24PM (#18302599)
> But I don't think it's safe to assume that someone who sets a dark UI also wants web pages displayed like that.

If it's done well, absolutely it's safe to assume.

I am extremely excited to research and start using this feature. I don't want to force anyone to use dark UIs that don't want them, but simultaneously I can't bring myself to make more light-themed apps and pages when I want exclusively dark themes for everything that runs on my machine.

Re:Using Dark Mode in CSS with MacOS Mojave by jackpeterfletch on Thursday October 25, 2018 @05:28AM (#18299588)
Would imagine they'll add the option in browsers to override the operating systems setting.
Re:Using Dark Mode in CSS with MacOS Mojave by stephenr on Thursday October 25, 2018 @05:35AM (#18299609)
Third-party ones (Mozilla, Google) may but I'll be surprised if Apple and Microsoft don't just tie it to their respective OS' 'dark mode' setting.
Re:Using Dark Mode in CSS with MacOS Mojave by lostgame on Thursday October 25, 2018 @03:29PM (#18303838)
"But I don't think it's safe to assume that someone who sets a dark UI also wants web pages displayed like that."

I don't think it's safe to assume they don't. I can't stand web pages in general that are white background/black text.

I've coded in black background / white (or coloured) text for about two decades now, and I'm so glad Apple is making the dark theme a standard at this point. There's literally thousands of articles about the eye strain that's caused from the poor decision to present information this way. We don't need literally at this point millions of photons screaming light at our faces at more than 300 nits every moment.

Re:Using Dark Mode in CSS with MacOS Mojave by akuji1993 on Thursday October 25, 2018 @05:30AM (#18299599)
Also while it's very cool that they support this in Safari, I highly doubt someone will do CSS adjustments JUST for Safari users like this. Either your page already has a dark theme or you won't really bother about this.
Re:Using Dark Mode in CSS with MacOS Mojave by stephenr on Thursday October 25, 2018 @05:33AM (#18299602)
As someone else pointed out (https://news.ycombinator.com/item?id=18298848) this is in a draft for CSS Media Queries level 5
Re:Using Dark Mode in CSS with MacOS Mojave by akuji1993 on Thursday October 25, 2018 @05:50AM (#18299678)
Hm, okay. Then it might make sense to support this, if your user base heavily relies on MacOS. Thanks for the link.
Re:Using Dark Mode in CSS with MacOS Mojave by michaelmior on Thursday October 25, 2018 @10:35AM (#18301184)
Windows has also had dark mode for apps for a while, so I wouldn't be surprised if Edge picks this up in the future.
Re:Using Dark Mode in CSS with MacOS Mojave by kitsunesoba on Thursday October 25, 2018 @11:22AM (#18301577)
Also on Linux GNOME has had a popular dark mode for its default theme (Adwaita) for ages now, and KDE has a bundled dark theme bundled by default (IIRC, haven’t used KDE in ages).

I think Android has this option too?

Basically, it’s not just a “macOS thing”, lots of systems now have dark modes.

Re:Using Dark Mode in CSS with MacOS Mojave by aczerepinski on Thursday October 25, 2018 @07:44AM (#18300149)
If you can justify dozens of CSS adjustments for IE11, it isn't much of a stretch to spend half that amount of time making something cool for (typically) higher value Safari users as well.
Re:Using Dark Mode in CSS with MacOS Mojave by ikfmpwdsoz on Thursday October 25, 2018 @09:11AM (#18300596)
What do you mean by "higher value"? Getting IE11 to work will net you an extra 2.85% of the market, but adding a very minor feature that's only usable by Safari users doesn't seem to be profitable at all.
Re:Using Dark Mode in CSS with MacOS Mojave by sparewalking on Thursday October 25, 2018 @09:58AM (#18300901)
> only usable by Safari users doesn't seem to be profitable at all.

Why is that? According to [1] Safari has 14% market share. Just the desktop version has 5%.

[1] http://gs.statcounter.com/browser-market-share

Re:Using Dark Mode in CSS with MacOS Mojave by aczerepinski on Thursday October 25, 2018 @10:18AM (#18301060)
By higher value, I mean they spend more money.
Re:Using Dark Mode in CSS with MacOS Mojave by Insanity on Thursday October 25, 2018 @05:05PM (#18304579)
Not sure if you could back that up. I assume you say this because tech-savvy people will not use IE?

But that is assuming the content is aimed at this group.

Re:Using Dark Mode in CSS with MacOS Mojave by Gaelan on Thursday October 25, 2018 @10:21AM (#18301090)
I imagine that they’re saying Safari users are generally of a “more valuable” demographic (maybe because they’re rich enough to afford Macs?)
Re:Using Dark Mode in CSS with MacOS Mojave by _emacsomancer_ on Thursday October 25, 2018 @11:35AM (#18301688)
I can't stare at a "light theme" screen for very long, I find.