Skip to content

Commit

Permalink
Refactor sidebar-toggle, sidebar-dimmer & back-to-top
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Nov 9, 2022
1 parent 0c35aeb commit c7b92c3
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
4 changes: 2 additions & 2 deletions layout/_layout.njk
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
{%- endif %}
</header>

{{ partial('_partials/widgets.njk', {}, {cache: theme.cache.enable}) }}

<div class="main-inner {% block class %}{% endblock %}">
{%- include '_partials/header/sub-menu.njk' -%}
{% block content %}{% endblock %}
Expand All @@ -40,6 +38,8 @@
</div>
</footer>

{{ partial('_partials/widgets.njk', {}, {cache: theme.cache.enable}) }}

{{ partial('_scripts/index.njk', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/index.njk', {}, {cache: theme.cache.enable}) }}
{{ partial('_third-party/statistics/index.njk', {}, {cache: theme.cache.enable}) }}
Expand Down
7 changes: 0 additions & 7 deletions layout/_macro/sidebar.njk
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
{% macro render(display_toc) %}
<div class="toggle sidebar-toggle" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>

<aside class="sidebar">
{%- set display_toc = page.toc.enable and display_toc %}
{%- if display_toc %}
Expand Down Expand Up @@ -46,5 +40,4 @@
{%- endif %}
</div>
</aside>
<div class="sidebar-dimmer"></div>
{% endmacro %}
11 changes: 11 additions & 0 deletions layout/_partials/widgets.njk
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
{# Widgets with fixed position #}

{%- if theme.sidebar.display !== 'remove' and (theme.scheme === 'Muse' or theme.scheme === 'Mist') %}
<div class="toggle sidebar-toggle" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
<div class="sidebar-dimmer"></div>
{%- endif %}

{%- if theme.back2top.enable and not theme.back2top.sidebar %}
<div class="back-to-top" role="button" aria-label="{{ __('accessibility.back_to_top') }}">
<i class="fa fa-arrow-up"></i>
Expand Down
1 change: 0 additions & 1 deletion source/css/_common/outline/sidebar/index.styl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
@import 'sidebar-author-links';
@import 'sidebar-button';
@import 'sidebar-blogroll';
@import 'sidebar-dimmer';
@import 'sidebar-nav';
@import 'sidebar-toggle';
@import 'sidebar-toc';
Expand Down
24 changes: 0 additions & 24 deletions source/css/_common/outline/sidebar/sidebar-dimmer.styl

This file was deleted.

25 changes: 25 additions & 0 deletions source/css/_schemes/Muse/_sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,28 @@ if (hexo-config('sidebar.position') == 'right') {
white-space: nowrap;
}
}

.sidebar-dimmer {
display: none;
}

+tablet-mobile() {
.sidebar-dimmer {
background: black;
display: block;
height: 100%;
left: 0;
opacity: 0;
position: fixed;
top: 0;
transition: visibility .4s, opacity .4s;
visibility: hidden;
width: 100%;
z-index: $zindex-1;

.sidebar-active & {
opacity: .7;
visibility: visible;
}
}
}
4 changes: 0 additions & 4 deletions source/css/_schemes/Pisces/_sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
}
}

.sidebar-toggle {
display: none;
}

.sidebar-inner {
background: var(--content-bg-color);
border-radius: $border-radius;
Expand Down

0 comments on commit c7b92c3

Please sign in to comment.