Skip to content

Commit

Permalink
try to fix mp sidebar error
Browse files Browse the repository at this point in the history
  • Loading branch information
glicht committed Jun 17, 2021
1 parent b79774e commit 84e0bf3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/theme/MarketplaceSidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,19 @@ function DocSidebarItem(props) {
}
}

function useShowAnnouncementBar() {
const {isAnnouncementBarClosed} = useUserPreferencesContext();
const [showAnnouncementBar, setShowAnnouncementBar] = useState(
!isAnnouncementBarClosed,
);
useScrollPosition(({scrollY}) => {
if (!isAnnouncementBarClosed) {
setShowAnnouncementBar(scrollY === 0);
}
});
return showAnnouncementBar;
}

function MarketplaceSidebar({
path,
sidebar,
Expand All @@ -327,6 +340,7 @@ function MarketplaceSidebar({
totalPacks,
totalFilteredPacks,
}) {
const showAnnouncementBar = useShowAnnouncementBar();
const [showResponsiveSidebar, setShowResponsiveSidebar] = useState(false);
const {
navbar: { hideOnScroll },
Expand Down Expand Up @@ -357,8 +371,7 @@ function MarketplaceSidebar({
styles.menu,
{
"menu--show": showResponsiveSidebar,
[styles.menuWithAnnouncementBar]:
!isAnnouncementBarClosed && scrollY === 0,
[styles.menuWithAnnouncementBar]: showAnnouncementBar
}
)}
>
Expand Down

0 comments on commit 84e0bf3

Please sign in to comment.