dark-mode-switch icon indicating copy to clipboard operation
dark-mode-switch copied to clipboard

Detect if user has prefers-dark-mode setting on

Open coliff opened this issue 5 years ago • 8 comments

Requirements:

  • dark-mode-switch should detect the users system preference and use that unless they have already made a change to the switch (which is saved in local storage). So if someone has already set the dark mode switch on, but they have a light-mode set on their OS or browser preference it would prioritise the dark-mode-switch setting
  • I think this 'Detect if user has prefers-dark-mode setting on' feature should be enabled as standard in a v2 of this script, but open to suggestions if it should be an option.

coliff avatar Jul 03 '19 10:07 coliff

I think this is something browsers will adopt sooner than later: See this stackoverflow answer.

In a cursory search, to check this via JavaScript you may follow this website's advice on a reactive JavaScript approach.

AlexanderMorou avatar Sep 16 '19 22:09 AlexanderMorou

would be cool if we add a line of code to auto switch dark mode depending on time of the day. IF user local time passed sunset enable dark mode, else Light Mode.

telecomsxchange avatar Oct 29 '19 22:10 telecomsxchange

I'd love to help out with this, if no one else is already working on it

filipe-gomes avatar Nov 10 '19 02:11 filipe-gomes

Hi @filipe-gomes - yes, go for it! I updated my original post with a couple of thoughts on the requirements.

coliff avatar Nov 12 '19 07:11 coliff

Hi @filipe-gomes - yes, go for it! I updated my original post with a couple of thoughts on the requirements.

Thanks! I'm working on a project where I just implemented that. I will start looking into implementing this with the switch tonight after work.

filipe-gomes avatar Nov 12 '19 13:11 filipe-gomes

Hi @coliff -- looks like @popoway found a pretty easy solution to this ^^. Is that something you/we can add to the main source here?

cullub avatar Jul 10 '20 12:07 cullub

I would like to work on it.

Priya19999 avatar Oct 07 '20 09:10 Priya19999

Is anyone already working on that? We may, as we have a downstream issue at https://github.com/coliff/dark-mode-switch/issues/2 implement this.

rugk avatar Jan 18 '21 18:01 rugk