FIXED SIDEBAR SCROLL ISSUE!

This commit is contained in:
adueck 2024-10-08 18:10:50 -04:00
parent 6dfb47098c
commit f6a53c7b4d
2 changed files with 43 additions and 7 deletions

View File

@ -20,12 +20,14 @@
unicode-range: U+0600-06FF; unicode-range: U+0600-06FF;
} */ } */
.ais-SearchBox { margin: 1em 0; } .ais-SearchBox {
margin: 1em 0;
}
.table-of-contents { .table-of-contents {
padding-top: 1rem; padding-top: 1rem;
position: sticky !important; position: sticky !important;
top: 1rem; top: 4rem;
height: calc(100vh - 2rem); height: calc(100vh - 2rem);
overflow-y: auto; overflow-y: auto;
} }
@ -34,12 +36,15 @@
text-decoration: none; text-decoration: none;
color: #21252A; color: #21252A;
} }
.heading-link:hover { .heading-link:hover {
color: #21252A; color: #21252A;
} }
.heading-link:active { .heading-link:active {
color: #21252A; color: #21252A;
} }
.heading-link:visited { .heading-link:visited {
color: #21252A; color: #21252A;
} }
@ -67,19 +72,30 @@
} }
@media (min-width: 821px) { @media (min-width: 821px) {
.sticky-on-big { header {
position: sticky; position: sticky;
top: 0; top: 0;
z-index: 9999999;
} }
.sticky-on-big {
position: fixed;
top: 65px;
bottom: 0;
overflow-y: scroll;
}
} }
@media (max-width: 820px) { @media (max-width: 820px) {
.main-row { .main-row {
height: calc(100vh - 62px); height: calc(100vh - 62px);
} }
.header-title { .header-title {
margin-left: 3.5rem; margin-left: 3.5rem;
} }
.side-nav-btn { .side-nav-btn {
display: block; display: block;
position: fixed; position: fixed;
@ -87,9 +103,11 @@
background: white; background: white;
margin-left: 0.25rem; margin-left: 0.25rem;
} }
aside { aside {
overflow-x: hidden; overflow-x: hidden;
} }
.side-nav { .side-nav {
display: block; display: block;
min-width: 15rem; min-width: 15rem;
@ -101,10 +119,12 @@
z-index: 99999; z-index: 99999;
transition: all 0.25s linear; transition: all 0.25s linear;
} }
.side-nav-closed { .side-nav-closed {
transform: translate(-100%); transform: translate(-100%);
-webkit-transform: translate(-100%); -webkit-transform: translate(-100%);
} }
.overlay { .overlay {
display: block; display: block;
position: fixed; position: fixed;
@ -118,6 +138,7 @@
/* animate the transition */ /* animate the transition */
transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out;
} }
.overlay-showing { .overlay-showing {
z-index: 99998; z-index: 99998;
top: 0; top: 0;
@ -164,7 +185,7 @@
} }
.side-nav-item-selected { .side-nav-item-selected {
background-color: rgb(25,101,189, 0.3); background-color: rgb(25, 101, 189, 0.3);
} }
.side-nav-item-secondary { .side-nav-item-secondary {
@ -186,6 +207,7 @@
color: inherit; color: inherit;
font-weight: bold; font-weight: bold;
} }
.copyright a:hover { .copyright a:hover {
color: inherit; color: inherit;
font-weight: bold; font-weight: bold;

View File

@ -6,7 +6,7 @@
* *
*/ */
import { useState } from "react"; import { useEffect, useState } from "react";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
import classNames from "classnames"; import classNames from "classnames";
import SmoothCollapse from "react-smooth-collapse"; import SmoothCollapse from "react-smooth-collapse";
@ -19,17 +19,31 @@ function Sidebar({ content, navOpen, setNavOpen, pathname }) {
)); ));
const openSectionHeading = openSection ? openSection.heading : ""; const openSectionHeading = openSection ? openSection.heading : "";
const [sectionOpen, setSectionOpen] = useState(openSectionHeading); const [sectionOpen, setSectionOpen] = useState(openSectionHeading);
const [sidebarWidth, setSidebarWidth] = useState(200);
useEffect(() => {
const s = document.getElementById("sidebar");
if (s) {
setSidebarWidth(s.offsetWidth);
}
window.addEventListener("resize", () => {
const s = document.getElementById("sidebar");
if (s) {
setSidebarWidth(s.offsetWidth);
}
});
}, []);
function handleHeadingClick(h) { function handleHeadingClick(h) {
setSectionOpen(h === sectionOpen ? "" : h); setSectionOpen(h === sectionOpen ? "" : h);
} }
return ( return (
<> <>
<aside <aside
id="sidebar"
className={classNames( className={classNames(
"side-nav col-3 col-lg-2 p-0 bg-light", "side-nav col-3 col-lg-2 p-0 bg-light",
{ "side-nav-closed": !navOpen } { "side-nav-closed": !navOpen }
)}> )}>
<nav className="sticky-on-big flex-column align-items-start"> <nav className="sticky-on-big flex-column align-items-start" style={{ width: `${sidebarWidth}px` }}>
<Link to="/table-of-contents" style={{ textDecoration: "none", color: "inherit" }} onClick={() => setNavOpen(false)}> <Link to="/table-of-contents" style={{ textDecoration: "none", color: "inherit" }} onClick={() => setNavOpen(false)}>
<div className={classNames( <div className={classNames(
"side-nav-item", "side-nav-item",