mirror of https://github.com/lxndrblz/anatole.git

Alexander Bilz
21.48.2020 6ddf3af7b143473e5c41a100ab146fef80dd453f
Proposal for dark theme

- Loads last theme configuration
- Adjusted color schema
- Replaced switch by menu item
1 files added
4 files modified
154 ■■■■■ changed files
README.md 1 ●●●● patch | view | raw | blame | history
assets/css/style.css 76 ●●●● patch | view | raw | blame | history
assets/js/anatole.js 37 ●●●●● patch | view | raw | blame | history
layouts/partials/footer.html 28 ●●●●● patch | view | raw | blame | history
layouts/partials/navbar.html 12 ●●●●● patch | view | raw | blame | history
README.md
@@ -10,6 +10,7 @@
### Features include:
- Profile picture and slogan
- Dark mode
- Navigation items
- Pagination
- Google Analytics (optional)
assets/css/style.css
@@ -1,6 +1,7 @@
@charset "UTF-8";
:root{
  --bg-color:#fff;
  --secondary-bg-color:#fff;
  --heading-color: #5f5f5f;
  --body-color: rgba(0, 0, 0, 0.5);
  --post-color: rgba(0, 0, 0, 0.44);
@@ -14,14 +15,14 @@
  -webkit-font-smoothing: antialiased;
}
html[data-theme='dark'] {
  --bg-color:#222831;
  --secondary-bg-color: #393e46;
  --heading-color: #d65a31;
  --body-color: white;
  --bg-color:rgb(28, 28, 33);
  --secondary-bg-color:rgb(28, 28, 33);
  --heading-color:rgba(191, 191, 191, 0.5);
  --body-color: rgba(191, 191, 191, 0.5);
  --post-color: rgba(0, 0, 0, 0.44);
  --border-color: rgba(0, 0, 0, 0.15);
  --nav-text-color: #fff;
  --border-color: rgb(38, 38, 38);;
  --pre-bg-color: #21212d;
  --nav-text-color:rgb(191, 191, 191);
  --tag-color: rgb(83, 83, 83) !important;
  
}
@@ -49,7 +50,7 @@
  border-radius: 3px;
  color: #fff;
  background-color: #f9f9fd;
  border: 1px solid #f2f2f2;
  border: 1px solid var(--border-color);
}
.tag::before {
@@ -175,7 +176,7 @@
  z-index: 3;
  background-color: var(--secondary-bg-color);
  height: 60px;
  border-bottom: 1px solid #f2f2f2;
  border-bottom: 1px solid var(--border-color);
}
.page-top .nav {
  list-style: none;
@@ -199,59 +200,6 @@
  padding-bottom: 22px;
  border-bottom: 1px solid var(--nav-text-color);
}
.theme-switch {
  display: inline-block;
  height: 34px;
  position: relative;
  width: 60px;
}
.theme-switch-wrapper{
    float: right;
}
.theme-switch input {
  display:none;
}
.slider {
  background-color: #ccc;
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: .4s;
}
.slider:before {
  background-color: #fff;
  bottom: 4px;
  content: "";
  height: 26px;
  left: 4px;
  position: absolute;
  transition: .4s;
  width: 26px;
}
input:checked + .slider {
  background-color: #66bb6a;
}
input:checked + .slider:before {
  transform: translateX(26px);
}
.slider.round {
  border-radius: 34px;
}
.slider.round:before {
  border-radius: 50%;
}
.page-top .information {
  float: right;
  padding-top: 12px;
@@ -286,7 +234,7 @@
  left: 0;
  position: fixed;
  z-index: 4;
  border-right: 1px solid #f2f2f2;
  border-right: 1px solid var(--border-color);
}
.sidebar .logo-title {
  text-align: center;
@@ -396,7 +344,7 @@
}
.post .post-footer {
  padding: 0 0 30px 0;
  border-bottom: 1px solid #f2f2f2;
  border-bottom: 1px solid var(--border-color);
}
.post .post-footer .meta {
  max-width: 100%;
@@ -502,7 +450,7 @@
#disqus_thread {
  margin: 30px;
  border-bottom: 1px solid #f2f2f2;
  border-bottom: 1px solid var(--border-color);
}
.footer {
assets/js/anatole.js
New file
@@ -0,0 +1,37 @@
const themeSwitcher = document.querySelector('.theme-switch');
function getTheme(){
    return localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
}
// switch themes
function switchTheme(e) {
    var theme = getTheme();
    if (theme == 'light') {
        document.documentElement.setAttribute('data-theme', 'dark');
        localStorage.setItem('theme', 'dark');
    }
    else {
        document.documentElement.setAttribute('data-theme', 'light');
        localStorage.setItem('theme', 'light');
    }
}
// initialize default value
var theme = getTheme();
if (theme === null) {
    document.documentElement.setAttribute('data-theme', 'light');
    localStorage.setItem('theme', 'light');
}
else {
    // load a stored theme
    if (theme == 'light') {
        document.documentElement.setAttribute('data-theme', 'light');
    }
    else {
        document.documentElement.setAttribute('data-theme', 'dark');
    }
}
themeSwitcher.addEventListener('click', switchTheme, false);
layouts/partials/footer.html
@@ -6,36 +6,12 @@
<script type="text/javascript" src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
{{ $migrate := resources.Get "js/jquery-migrate.js" }}
{{ $appear := resources.Get "js/jquery-appear.js" }}
{{ $js := slice $migrate $appear | resources.Concat "js/bundle.js" }}
{{ $anatole := resources.Get "js/anatole.js" }}
{{ $js := slice $migrate $appear $anatole | resources.Concat "js/bundle.js" }}
{{ $secureJS := $js |  resources.Minify | resources.Fingerprint }}
<script type="text/javascript" src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
{{- partial "medium-zoom.html" . -}}
{{- partial "math.html" . -}}
{{- template "_internal/google_analytics_async.html" . -}}
<script type="text/javascript" >
const toggleSwitch = document.querySelector('.theme-switch input[type="checkbox"]');
function switchTheme(e) {
    if (e.target.checked) {
        document.documentElement.setAttribute('data-theme', 'dark');
        localStorage.setItem('theme', 'dark');
    }
    else {
        document.documentElement.setAttribute('data-theme', 'light');
        localStorage.setItem('theme', 'light');
    }
}
toggleSwitch.addEventListener('change', switchTheme, false);
const currentTheme = localStorage.getItem('theme') ? localStorage.getItem('theme') : null;
if (currentTheme) {
    document.documentElement.setAttribute('data-theme', currentTheme);
    if (currentTheme === 'dark') {
        toggleSwitch.checked = true;
    }
}
</script>
</html>
layouts/partials/navbar.html
@@ -5,12 +5,10 @@
        <li><a {{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }}class="current"{{end}} href="{{ .URL }}" title="{{ .Title }}">{{ .Name }}</a></li>
        {{ end }}
        <div class="theme-switch-wrapper">
            <label class="theme-switch" for="checkbox">
                <input type="checkbox" id="checkbox" />
                <div class="slider round"></div>
          </label>
        </div>
        <li>
        <a class="theme-switch" title="Switch Theme">
            <i class="fa fa-adjust fa-fw" aria-hidden="true"></i>
        </a>
        </li>
    </div>
</div>