feat: add a switch to toggle light/dark theme

Add script for restoring preferred theme setting.
Update config for newer `mkdocs-material`.
Use native `mkdocs-material` styles where possible.

Closes: #45 #63
This commit is contained in:
Denis Bendrikov
2021-05-10 21:59:25 +03:00
parent 13386236e4
commit 2e470cd1b8
6 changed files with 45 additions and 31 deletions

View File

@@ -4,7 +4,7 @@
article img {
border: 1px solid #eee;
box-shadow: 0 0 1em #ccc;
box-shadow: 0 0 1em rgba(0, 0, 0, .6);
margin: 30px auto 10px;
}
@@ -24,30 +24,17 @@ article img.emojione {
background-color: #0d9cec !important;
}
@font-face{
font-family: "Geomanist";
src: url("../fonts/hinted-Geomanist-Book.ttf")
.md-header__button.md-logo img,
.md-nav__title .md-nav__button.md-logo img {
height: 1.4rem;
width: auto;
}
body {
font-family: "Open Sans", sans-serif;
font-size: 15px;
font-weight: normal;
font-style: normal;
font-stretch: normal;
line-height: 1.5;
letter-spacing: normal;
color: #577482;
}
h1, h2, h3, h4, .md-footer-nav__inner, .md-header-nav__title, footer.md-footer {
font-family: Geomanist;
}
.md-header-nav__title {
line-height: 2.9rem;
.md-nav__title .md-nav__button img {
height: 30px;
margin-top: 10px;
}
.md-header-nav__button img {
width: 145px;
}
}

View File

@@ -1,2 +0,0 @@
redirect: /tutorial/

4
docs/js/index.js Normal file
View File

@@ -0,0 +1,4 @@
const settings = JSON.parse(localStorage.getItem(__prefix('__palette')));
const scheme = settings?.color.scheme || (matchMedia('(prefers-color-scheme: dark)').matches ? 'slate' : 'default' );
document.body.setAttribute('data-md-color-scheme', scheme);