Comments (2)
OS theme detection is made possible by the prefers-color-scheme media query:
- https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme
- https://caniuse.com/#feat=prefers-color-scheme
Specifying a separate stylesheet for light/dark OS themes can be done as follows:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple-dark.css" media="(prefers-color-scheme: dark)">
I have made this change to the docsify-themeable site. View it with the latest Safari Technical Preview and toggle your macOS Mohave's light/dark color scheme to see the effect.
FWIW, this solutions is less-than-ideal because it requires both stylesheets to be downloaded, but it makes it very easy to specify separate stylesheets for light and dark color schemes. I could also offer a new stylesheet that contains the CSS custom property values from both the "Simple" and "Simple Dark" themes which would remove the additional stylesheet request and handle all of this automatically, but this approach prevents users from specifying their own light and dark themes. For now, it seems easiest to just recommend the approach above, favoring flexibility over the slight performance hit taken from downloading two stylesheets.
Be aware that while Firefox Nightly supports the prefers-color-scheme media query, it requires a browser restart to detect color scheme changes. A bug has been filed, so hopefully this will be addressed before Firefox 67 is released.
from docsify-themeable.
Related: https://developers.google.com/speed/docs/insights/OptimizeCSSDelivery#example
from docsify-themeable.
Related Issues (20)
- The drop-down arrow does not appear when using "routerMode: 'history'" HOT 2
- Changing the padding (top/bottom) on "blockquote" HOT 2
- expand/collapse icons in the sidebar not working when external link present HOT 3
- Browser console reports an uncaught error HOT 2
- Sidebar not aligning to left of page HOT 1
- sidebar not aligned between file and folder classes HOT 2
- Inactive chevron in multilevel menu show up as active HOT 6
- Inactive chevron in multilevel menu show up as active HOT 3
- Page content is not using all available space on large screens HOT 1
- Unexpected style of title when I come to the third level of the sidebar HOT 1
- Can we make the sidebar arrow in theme-simple point right if it has multiple sidebar .md files HOT 1
- On a phone brower, when touching any sidebar contents, the sidebar will hide automatically. HOT 5
- Top level sidebar items should always be collapsible HOT 2
- Table in small screens will render with CSS attribute `content`
- Switch button for dark/light mode HOT 2
- In the cover page Custom background is invalid HOT 5
- Quotation Marks Inconsistent HOT 5
- Unexplained 'TypeError: Attempted to assign to readonly property.' console error message HOT 8
- Keyboard focus is not visible at Hamburger menu present at the UI.
- "onlyCover: true" spinner is not removed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from docsify-themeable.