mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
Added support for preference-based color schemes
This commit is contained in:
parent
a4d6c783ab
commit
2491b23ade
@ -86,6 +86,9 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<body dir="{{ direction }}">
|
<body dir="{{ direction }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if "prefers" == palette.scheme %}
|
||||||
|
<script>matchMedia("(prefers-color-scheme: dark)").matches&&document.body.setAttribute("data-md-color-scheme","slate")</script>
|
||||||
|
{% endif %}
|
||||||
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
|
<input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off">
|
||||||
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
<input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off">
|
||||||
<label class="md-overlay" for="__drawer"></label>
|
<label class="md-overlay" for="__drawer"></label>
|
||||||
|
@ -180,6 +180,14 @@
|
|||||||
<body dir="{{ direction }}">
|
<body dir="{{ direction }}">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- Experimental: set color scheme based on preference -->
|
||||||
|
{% if "prefers" == palette.scheme %}
|
||||||
|
<script>
|
||||||
|
if (matchMedia("(prefers-color-scheme: dark)").matches)
|
||||||
|
document.body.setAttribute("data-md-color-scheme", "slate")
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
State toggles - we need to set autocomplete="off" in order to reset the
|
State toggles - we need to set autocomplete="off" in order to reset the
|
||||||
drawer on back button invocation in some browsers
|
drawer on back button invocation in some browsers
|
||||||
|
Loading…
Reference in New Issue
Block a user