mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 18:27:56 +02:00
fix(theme): preserve sidebar height on collapse (#8328)
This commit is contained in:
parent
6be3beb8c9
commit
1bf058979e
4 changed files with 23 additions and 16 deletions
|
@ -7,10 +7,11 @@
|
|||
|
||||
@media (min-width: 997px) {
|
||||
.expandButton {
|
||||
position: sticky;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
|
|
@ -60,15 +60,20 @@ export default function DocRootLayoutSidebar({
|
|||
}
|
||||
}}>
|
||||
<ResetOnSidebarChange>
|
||||
<DocSidebar
|
||||
sidebar={sidebar}
|
||||
path={pathname}
|
||||
onCollapse={toggleSidebar}
|
||||
isHidden={hiddenSidebar}
|
||||
/>
|
||||
<div
|
||||
className={clsx(
|
||||
styles.sidebarViewport,
|
||||
hiddenSidebar && styles.sidebarViewportHidden,
|
||||
)}>
|
||||
<DocSidebar
|
||||
sidebar={sidebar}
|
||||
path={pathname}
|
||||
onCollapse={toggleSidebar}
|
||||
isHidden={hiddenSidebar}
|
||||
/>
|
||||
{hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}
|
||||
</div>
|
||||
</ResetOnSidebarChange>
|
||||
|
||||
{hiddenSidebar && <ExpandButton toggleSidebar={toggleSidebar} />}
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -29,4 +29,11 @@
|
|||
width: var(--doc-sidebar-hidden-width);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.sidebarViewport {
|
||||
top: 0;
|
||||
position: sticky;
|
||||
height: 100%;
|
||||
max-height: 100vh;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,13 +9,9 @@
|
|||
.sidebar {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
max-height: 100vh;
|
||||
height: 100%;
|
||||
position: sticky;
|
||||
top: 0;
|
||||
padding-top: var(--ifm-navbar-height);
|
||||
width: var(--doc-sidebar-width);
|
||||
transition: opacity 50ms ease;
|
||||
}
|
||||
|
||||
.sidebarWithHideableNavbar {
|
||||
|
@ -24,8 +20,6 @@
|
|||
|
||||
.sidebarHidden {
|
||||
opacity: 0;
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue