Skip to content
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
8 changes: 4 additions & 4 deletions website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
"babel-plugin-styled-components": "^1.12.0"
},
"dependencies": {
"@docusaurus/core": "^2.0.0-alpha.71",
"@docusaurus/preset-classic": "^2.0.0-alpha.71",
"@docusaurus/core": "2.0.0-alpha.75",
"@docusaurus/preset-classic": "2.0.0-alpha.75",
"change-case": "^4.1.2",
"clsx": "^1.1.1",
"react": "^16.10.2",
"react-dom": "^16.10.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-transition-group": "^4.4.1",
"styled-components": "^5.2.1"
},
Expand Down
24 changes: 16 additions & 8 deletions website/src/theme/DocSidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,19 @@ function DocSidebarItem(props) {
}
}

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

function DocSidebar({
path,
sidebar,
Expand All @@ -162,19 +175,14 @@ function DocSidebar({
isHidden,
docPluginId
}) {
const showAnnouncementBar = useShowAnnouncementBar();
const [showResponsiveSidebar, setShowResponsiveSidebar] = useState(false);
const {
navbar: {
hideOnScroll
},
hideableSidebar
} = useThemeConfig();
const {
isAnnouncementBarClosed
} = useUserPreferencesContext();
const {
scrollY
} = useScrollPosition();
Comment thread
juzhiyuan marked this conversation as resolved.
useLockBodyScroll(showResponsiveSidebar);
const windowSize = useWindowSize();
useEffect(() => {
Expand All @@ -191,7 +199,7 @@ function DocSidebar({
{hideOnScroll && <Logo tabIndex={-1} className={styles.sidebarLogo} />}
<div className={clsx('menu', 'menu--responsive', 'thin-scrollbar', styles.menu, {
'menu--show': showResponsiveSidebar,
[styles.menuWithAnnouncementBar]: !isAnnouncementBarClosed && scrollY === 0
[styles.menuWithAnnouncementBar]: showAnnouncementBar
})}>
<button aria-label={showResponsiveSidebar ? 'Close Menu' : 'Open Menu'} aria-haspopup="true" className="button button--secondary button--sm menu__button" type="button" onClick={() => {
setShowResponsiveSidebar(!showResponsiveSidebar);
Expand All @@ -213,4 +221,4 @@ function DocSidebar({
</div>;
}

export default DocSidebar;
export default DocSidebar;
Loading