Skip to content

Commit

Permalink
New option sidebar.padding
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Dec 1, 2019
1 parent e0629ea commit c09e66f
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ sidebar:
# - remove totally remove sidebar including sidebar toggle.
display: post

# Sidebar padding in pixels.
padding: 18
# Sidebar offset from top menubar in pixels (only for Pisces | Gemini).
offset: 12
# Enable sidebar on narrow view (only for Muse | Mist).
Expand Down
3 changes: 1 addition & 2 deletions layout/_partials/head/head.swig
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
},
localsearch: {{ theme.local_search | json }},
path: '{{ config.search.path }}',
motion: {{ theme.motion | json }},
sidebarPadding: 40
motion: {{ theme.motion | json }}
};
</script>
2 changes: 1 addition & 1 deletion source/css/_common/outline/sidebar/sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

.sidebar-inner {
color: $grey-dark;
padding: 20px 10px;
padding: $sidebar-padding 10px;
text-align: center;
}

Expand Down
1 change: 1 addition & 0 deletions source/css/_variables/base.styl
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ $posts-collapse-margin-mobile = 20px;
// Variables for sidebar section elements.
// --------------------------------------------------

$sidebar-padding = hexo-config('sidebar.padding') is a 'unit' ? unit(hexo-config('sidebar.padding'), px) : 18px;
$sidebar-offset = hexo-config('sidebar.offset') is a 'unit' ? unit(hexo-config('sidebar.offset'), px) : 12px;
$sidebar-nav-color = $black-light;
$sidebar-nav-hover-color = $whitesmoke;
Expand Down
2 changes: 1 addition & 1 deletion source/js/schemes/pisces.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var Affix = {
},
checkPosition: function() {
if (window.getComputedStyle(this.element).display === 'none') return;
let height = this.element.offsetHeight - CONFIG.sidebarPadding;
let height = this.element.offsetHeight - CONFIG.sidebar.padding * 2;
let offset = this.offset;
let offsetTop = offset.top;
let offsetBottom = offset.bottom;
Expand Down
2 changes: 1 addition & 1 deletion source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ NexT.utils = {
var sidebarNavHeight = sidebarNav.style.display !== 'none' ? sidebarNav.offsetHeight : 0;
var sidebarOffset = CONFIG.sidebar.offset || 12;
var sidebarb2tHeight = CONFIG.back2top.enable && CONFIG.back2top.sidebar ? document.querySelector('.back-to-top').offsetHeight : 0;
var sidebarSchemePadding = CONFIG.sidebarPadding + sidebarNavHeight + sidebarb2tHeight;
var sidebarSchemePadding = CONFIG.sidebar.padding * 2 + sidebarNavHeight + sidebarb2tHeight;
// Margin of sidebar b2t: 8px -10px -20px, brings a different of 12px.
if (NexT.utils.isPisces() || NexT.utils.isGemini()) sidebarSchemePadding += (sidebarOffset * 2) - 12;
// Initialize Sidebar & TOC Height.
Expand Down

0 comments on commit c09e66f

Please sign in to comment.