Skip to content

Commit d1040c5

Browse files
authored
Fix: Sidebar position sticky (#1086)
* add: sidebar position sticky * fix workflows error * fix workflows error * Fix: Increase bottom margin of sidebar to prevent overlap with 'Need Help' section * fix sidebar height
1 parent c701374 commit d1040c5

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

components/Sidebar.tsx

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export const SidebarLayout = ({ children }: { children: React.ReactNode }) => {
181181
return (
182182
<div className='max-w-[1400px] mx-auto flex flex-col items-center'>
183183
<section>
184-
<div className='bg-primary dark:bg-slate-900 w-full h-12 mt-[4.5rem] z-150 flex relative flex-col justify-center items-center lg:hidden '>
184+
<div className='bg-primary dark:bg-slate-900 w-full h-12 mt-[4.5rem] z-150 flex relative flex-col justify-center items-center lg:hidden '>
185185
<div
186186
className='z-[150] flex w-full bg-primary dark:bg-slate-900 justify-between items-center'
187187
onMouseDown={(e) => e.stopPropagation()}
@@ -197,15 +197,12 @@ export const SidebarLayout = ({ children }: { children: React.ReactNode }) => {
197197
{getStartedPath.includes(pathWtihoutFragment) && (
198198
<h3 className='text-white ml-12'>Getting Started</h3>
199199
)}
200-
201200
{getReferencePath.includes(pathWtihoutFragment) && (
202201
<h3 className='text-white ml-12'>Reference</h3>
203202
)}
204-
205203
{getSpecificationPath.includes(pathWtihoutFragment) && (
206204
<h3 className='text-white ml-12'>Specification</h3>
207205
)}
208-
209206
{router.pathname === null && (
210207
<h3 className='text-white ml-12'>Docs</h3>
211208
)}
@@ -232,17 +229,19 @@ export const SidebarLayout = ({ children }: { children: React.ReactNode }) => {
232229
<div
233230
className={`z-[150] absolute top-10 mt-24 left-0 h-full w-screen bg-white dark:bg-slate-900 dark:shadow-lg transform ${open ? '-translate-x-0' : '-translate-x-full'} transition-transform duration-300 ease-in-out filter drop-shadow-md `}
234231
>
235-
<div className='flex flex-col dark:bg-slate-900'>
232+
<div className='flex flex-col dark:bg-slate-900'>
236233
<DocsNav open={open} setOpen={setOpen} />
237234
</div>
238235
</div>
239236
<div className='dark:bg-slate-800 max-w-[1400px] grid grid-cols-1 lg:grid-cols-4 mx-4 md:mx-12'>
240-
<div className='hidden lg:block mt-24'>
241-
<DocsNav open={open} setOpen={setOpen} />
242-
<CarbonAds
243-
className='lg:mt-8 w-4/5 mx-auto lg:ml-4'
244-
variant='sidebar'
245-
/>
237+
<div className='hidden lg:block mt-24 sticky top-24 h-[calc(100vh-6rem)] overflow-hidden'>
238+
<div className='h-full overflow-y-auto scrollbar-hidden'>
239+
<DocsNav open={open} setOpen={setOpen} />
240+
<CarbonAds
241+
className='lg:mt-8 w-4/5 mx-auto lg:ml-4'
242+
variant='sidebar'
243+
/>
244+
</div>
246245
</div>
247246
<div className='col-span-4 md:col-span-3 lg:mt-20 lg:w-5/6 mx-4 md:mx-0'>
248247
{children}

styles/globals.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,3 +294,9 @@ border-radius: 4px; */
294294
background: grey;
295295
border-radius: 8px;
296296
}
297+
.scrollbar-hidden {
298+
scrollbar-width: none;
299+
}
300+
.scrollbar-hidden::-webkit-scrollbar {
301+
display: none;
302+
}

0 commit comments

Comments
 (0)