From af4d3562e387be5758a861faab0353c7f55e8963 Mon Sep 17 00:00:00 2001 From: XPoet Date: Mon, 7 Sep 2020 15:56:13 +0800 Subject: [PATCH] pref: aside toc toggle --- source/css/layout/_partial/tools.styl | 4 +++ source/css/layout/page.styl | 51 ++------------------------- source/js/post.js | 8 ++++- 3 files changed, 14 insertions(+), 49 deletions(-) diff --git a/source/css/layout/_partial/tools.styl b/source/css/layout/_partial/tools.styl index 98892ca..2c97496 100644 --- a/source/css/layout/_partial/tools.styl +++ b/source/css/layout/_partial/tools.styl @@ -59,6 +59,10 @@ $li-margin-bottom = 12px; display: none; } + &.page-aside-toggle { + display: none; + } + } } diff --git a/source/css/layout/page.styl b/source/css/layout/page.styl index da0f3eb..8a16ed0 100644 --- a/source/css/layout/page.styl +++ b/source/css/layout/page.styl @@ -5,6 +5,9 @@ $header-progress-height = 3px; $page-aside-width = 248px; .page-container { + + transition(); + position: relative; padding-top: $header-progress-height; @@ -12,8 +15,6 @@ $page-aside-width = 248px; padding-left: 0 !important; } - transition(); - .page-header { .header-progress { display: none; @@ -104,13 +105,7 @@ $page-aside-width = 248px; height: $header-shrink-height; } - .sidebar-tools { - top: $header-shrink-height + $component-interspace !important; - } - } - - } @@ -142,50 +137,10 @@ $page-aside-width = 248px; the-transition-ease-out(); } - .sidebar-tools { position: fixed; top: $header-height + $component-interspace; right: $component-interspace; transition(); } - - - /*.scroll-to-top { - display: none; - position: fixed; - - if (hexo-config('back2top.position') == left) { - left: ((100% - $main-content-width) / 4); - } else { - right: ((100% - $main-content-width) / 4); - } - bottom: $component-interspace; - - li { - cursor: pointer; - width: $tool-button-width; - height: $tool-button-width; - border-radius: 5px; - font-size: 1em; - display: flex; - align-items: center; - justify-content: center; - background: var(--background-color); - - if (hexo-config('magic.enable') == true) { - magic-style(1.1, 1.1); - } else { - border: 1px solid var(--third-text-color); - } - - &:hover { - transition(); - color: var(--background-color); - background: var(--primary-color); - } - } - } -*/ - } diff --git a/source/js/post.js b/source/js/post.js index ad6610c..e404f3c 100644 --- a/source/js/post.js +++ b/source/js/post.js @@ -1,4 +1,10 @@ window.addEventListener('DOMContentLoaded', () => { const navItems = document.querySelectorAll('.post-toc-wrap .post-toc li'); - navItems.length > 0 && window.utils.openToggle(); + const toggleDom = document.querySelector('.page-aside-toggle'); + + if (navItems.length) { + toggleDom.style.display = 'flex'; + window.utils.openToggle(); + } + });