egoist / docute

📚 Effortless documentation, done right.
https://docute.egoist.dev
MIT License
3.8k stars 427 forks source link

Automatically detect dark theme from system #233

Closed egoist closed 5 years ago

egoist commented 5 years ago

Issuehunt badges

Add detectSystemDarkTheme: true option.


IssueHunt Summary #### [egoist egoist](https://issuehunt.io/u/egoist) has been rewarded. ### Sponsors (Total: $100.00) - [issuehunt issuehunt](https://issuehunt.io/u/issuehunt) ($100.00) ### Tips - Checkout the [Issuehunt explorer](https://issuehunt.io/r/egoist/docute/) to discover more funded issues. - Need some help from other developers? [Add your repositories](https://issuehunt.io/r/new) on IssueHunt to raise funds.
IssueHuntBot commented 5 years ago

@issuehunt has funded $100.00 to this issue.


bardiharborow commented 5 years ago

I might whip this up if I get a chance, otherwise this supports Chrome 76+, Firefox 67+, Safari 12.1+.

CSS:

@media screen and (prefers-color-scheme: dark) { }

JS:

function onThemeChange(theme) {
  console.log("Dark: ", theme.matches);
}

var systemTheme = window.matchMedia("screen and (prefers-color-scheme: dark)");
onThemeChange(systemTheme);
systemTheme.addListener(onThemeChange); // listen for further changes
egoist commented 5 years ago

:tada: This issue has been resolved in version 4.20.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

IssueHuntBot commented 5 years ago

@egoist has rewarded $70.00 to @egoist. See it on IssueHunt