From 460f5fd26228c3ccde02babce3fe65b9ab2133bb Mon Sep 17 00:00:00 2001 From: tangly1024 Date: Mon, 6 Dec 2021 11:03:50 +0800 Subject: [PATCH] =?UTF-8?q?feature=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SideBarDrawer.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/components/SideBarDrawer.js b/components/SideBarDrawer.js index 5b593bc5..8e9f9c1b 100644 --- a/components/SideBarDrawer.js +++ b/components/SideBarDrawer.js @@ -13,19 +13,32 @@ const SideBarDrawer = ({ post, currentTag, cRef, tags, posts, categories, curren handleSwitchSideDrawerVisible: () => switchSideDrawerVisible() } }) - const [isHidden, changeHiddenStatus] = useState(true) + const [isShow, changeHiddenStatus] = useState(false) // 点击按钮更改侧边抽屉状态 const switchSideDrawerVisible = () => { - changeHiddenStatus(!isHidden) + changeHiddenStatus(!isShow) + if (window) { + const sideBarDrawer = window.document.getElementById('sidebar-drawer') + const sideBarDrawerBackground = window.document.getElementById('sidebar-drawer-background') + + if (isShow) { + sideBarDrawer.classList.replace('-ml-72', 'ml-0') + sideBarDrawerBackground.classList.replace('hidden', 'block') + } else { + sideBarDrawer.classList.replace('ml-0', '-ml-72') + sideBarDrawerBackground.classList.replace('block', 'hidden') + } + } } return <> -
+ {/* 背景蒙版 */}