Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Style back-to-top button to make sidebar more comfortable #1367

Merged
merged 3 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions source/css/_schemes/Pisces/_sidebar.styl
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,14 @@
}
}
}

if (hexo-config('back2top.sidebar')) {
// Only when back2top.sidebar is true, apply the following styles
.back-to-top {
margin: 8px - $sidebar-offset -10px -18px;

&.back-to-top-on {
margin-top: 16px;
}
}
}
4 changes: 2 additions & 2 deletions source/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,8 @@ NexT.utils = {
var sidebarOffset = CONFIG.sidebar.offset || 12;
var sidebarb2tHeight = CONFIG.back2top.enable && CONFIG.back2top.sidebar ? document.querySelector('.back-to-top').offsetHeight : 0;
var sidebarSchemePadding = (CONFIG.sidebar.padding * 2) + sidebarNavHeight + sidebarb2tHeight;
// Margin of sidebar b2t: 8px -10px -20px, brings a different of 12px.
if (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') sidebarSchemePadding += (sidebarOffset * 2) - 12;
// Margin of sidebar b2t: -4px -10px -18px, brings a different of 22px.
if (CONFIG.scheme === 'Pisces' || CONFIG.scheme === 'Gemini') sidebarSchemePadding += (sidebarOffset * 2) - 22;
// Initialize Sidebar & TOC Height.
var sidebarWrapperHeight = document.body.offsetHeight - sidebarSchemePadding + 'px';
document.querySelector('.site-overview-wrap').style.maxHeight = sidebarWrapperHeight;
Expand Down