Skip to content
Merged
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
10 changes: 8 additions & 2 deletions src/components/docs/layout/sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use client";

import * as Tabs from "@radix-ui/react-tabs";
import { useEffect, useState } from "react";
import { useEffect, useRef, useState } from "react";
import { NavigationSideBar } from "../../navigation/navigation-sidebar";

export const Sidebar = ({
Expand All @@ -11,12 +11,15 @@ export const Sidebar = ({
}) => {
const [currentIndex, setCurrentIndex] = useState(0);
const [isMounted, setIsMounted] = useState(false);
const sidebarRef = useRef<HTMLDivElement>(null);

useEffect(() => {
setIsMounted(true);
const handleTabChange = (e: CustomEvent) => {
const newValue = e.detail.value;
setCurrentIndex(Number.parseInt(newValue));
// The sidebar scrolls, so start each tab at the top.
sidebarRef.current?.scrollTo({ top: 0 });
};

window.addEventListener("tabChange" as any, handleTabChange);
Expand All @@ -26,7 +29,10 @@ export const Sidebar = ({
}, []);

return (
<div className="border border-neutral-border/50 sticky hidden brand-glass-gradient lg:block mr-4 min-h-[calc(100vh-8rem)] h-fit w-80 p-4 ml-8 top-4 rounded-2xl dark:border dark:border-neutral-border-subtle/30 shadow-xl flex-shrink-0">
<div
ref={sidebarRef}
className="border border-neutral-border/50 sticky hidden brand-glass-gradient lg:block mr-4 min-h-[calc(100vh-8rem)] h-fit max-h-[calc(100vh-2rem)] overflow-y-auto overscroll-contain [scrollbar-width:thin] w-80 p-4 ml-8 top-4 rounded-2xl dark:border dark:border-neutral-border-subtle/30 shadow-xl flex-shrink-0"
>
<div className="relative w-full overflow-x-hidden">
<div
className="flex transition-transform duration-300 ease-in-out"
Expand Down
Loading