sandoche / Darkmode.js

🌓 Add a dark-mode / night-mode to your website in a few seconds
https://darkmodejs.learn.uno
MIT License
2.72k stars 176 forks source link

Could not auto set darkmode after 1.3.4 #25

Closed WingLim closed 4 years ago

WingLim commented 4 years ago

I have try v1.3.4 v1.4.0 v1.5.0 and v1.5.1 all of these version can set Local Storage darkmode: true but only v1.3.4 can read it and use darkmode automatically and I try to visit other site which use darkmode.js in your README Demo all of them can not auto set darkmode here is my code

<script src="https://cdn.jsdelivr.net/npm/darkmode-js@1.5.1/lib/darkmode-js.min.js"></script>
<script>
  let options = {
    label: '🌓'
  };
  const darkmode = new Darkmode(options);
  darkmode.showWidget();
</script>
WingLim commented 4 years ago

okay I found the problem in here https://github.com/sandoche/Darkmode.js/blob/116cc3d291194558ade66bb8021ac1e6ff0d4c9f/lib/darkmode-js.js#L143 the default value saveInCookies is false but the README say the default is true, maybe you need to change it

sandoche commented 4 years ago

Ah yes, it's true, thanks for noticing, I will fix this! Or fill free to make a pull request with the fix!

sandoche commented 4 years ago

I will do it today.

sandoche commented 4 years ago

@WingLim, I solved it, I let you try with 1.5.2 and feel free to reopen an issue if it's still not good.

WingLim commented 4 years ago

@sandoche ok, I have try it, it works, thanks.