Skip to content
Open
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
9 changes: 5 additions & 4 deletions src/components/Nav/NavPanels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ export const NavPanels = (props: NavPanelsProps) => {
jumpToState,
} = props;

const [isOpen, setIsOpen] = useState({ main: false, jump: false });
const [isOpen, setIsOpen] = useState({ main: true, jump: true });
const [isMobile, setIsMobile] = useState(true);

// Defaults to closed on mobile, open on desktop
// Have to do this in a lifecycle method
// so that we can still server-side render
useEffect(() => {
const startsMobile = window.innerWidth < 768;
setIsMobile(startsMobile);
setIsOpen({ main: !startsMobile, jump: !startsMobile });
requestAnimationFrame(() => {
document.documentElement.setAttribute("data-nav-panels-ready", "true");
});

// We use a resize observer to the user's window crosses the
// threshhold between mobile and desktop
const documentObserver = new ResizeObserver((entries) => {
Expand Down
17 changes: 14 additions & 3 deletions src/components/Nav/styles.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
.jumpto {
border-color: var(--sidebar-type-color);

animation: height 0.3s ease-in-out;
animation: none;
flex-grow: 0;
border-bottom-width: 1px;
height: 40px;
Expand Down Expand Up @@ -262,7 +262,9 @@
margin-top: 4px;
}

/* Interaction */
:global(html[data-nav-panels-ready="true"]) .jumpto {
animation: height 0.3s ease-in-out;
}

.jumpto:global(.open) {
flex-grow: 1;
Expand All @@ -277,7 +279,17 @@
}
}
}
@media (max-width: ($breakpoint-tablet - 1px)) {
:global(html:not([data-nav-panels-ready="true"])) .mainlinks:global(.open) {
height: 43px;
}

:global(html:not([data-nav-panels-ready="true"])) .jumpto:global(.open) {
flex-grow: 0;
height: 40px;
overflow: hidden;
}
}
/* Page-specific modifications */
:global(.reference-item) .jumpto ul {
grid-template-columns: 1fr;
Expand All @@ -286,4 +298,3 @@
.jumpto ul li.linklabel:not(:global(.small), :first-child) {
margin-top: 10px;
}