diff --git a/src/components/collapsibleRightSidebar/index.tsx b/src/components/collapsibleRightSidebar/index.tsx new file mode 100644 index 00000000000000..716e2b142f477e --- /dev/null +++ b/src/components/collapsibleRightSidebar/index.tsx @@ -0,0 +1,39 @@ +'use client'; + +/** + * Collapsible wrapper for the right sidebar that contains + * both the table of contents and platform SDK details + */ + +import {ReactNode, useState} from 'react'; + +import styles from './style.module.scss'; + +type CollapsibleRightSidebarProps = { + children: ReactNode; +}; + +export function CollapsibleRightSidebar({children}: CollapsibleRightSidebarProps) { + const [isExpanded, setIsExpanded] = useState(false); + + const handleToggle = () => { + setIsExpanded(!isExpanded); + }; + + return ( + + ); +} diff --git a/src/components/collapsibleRightSidebar/style.module.scss b/src/components/collapsibleRightSidebar/style.module.scss new file mode 100644 index 00000000000000..3d55a459c29417 --- /dev/null +++ b/src/components/collapsibleRightSidebar/style.module.scss @@ -0,0 +1,87 @@ +.collapsibleSidebar { + position: sticky; + margin-left: 5px; + transition: width 0.3s ease, min-width 0.3s ease; + overflow: hidden; + + // Ensure all content inside sidebar animates together + :global(.sidebar) { + transition: opacity 0.15s ease; + } + + &.expanded { + width: 250px; + min-width: 250px; + + :global(.sidebar) { + opacity: 1; + visibility: visible; + transition-delay: 0.2s; // Fade in after width expands + } + + // Prevent individual child animations + :global(.sidebar) * { + animation: none !important; + } + } + + &.collapsed { + width: 3rem; + min-width: 3rem; + + :global(.sidebar) { + opacity: 0; + visibility: hidden; + transition-delay: 0s; // Fade out immediately + } + } +} + +.collapseToggle { + position: absolute; + top: 2.5rem; + left: 0.5rem; + background: var(--gray-a3); + border: 1px solid var(--gray-a5); + border-radius: 4px; + width: 2rem; + height: 2rem; + display: flex; + align-items: center; + justify-content: center; + cursor: pointer; + font-size: 1.2rem; + color: var(--gray-11); + transition: background 0.2s ease, color 0.2s ease; + z-index: 100; + box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); + + &:hover { + background: var(--gray-a4); + color: var(--gray-12); + } + + &:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; + } + + &.active { + background: var(--accent-a3); + border-color: var(--accent-a6); + + &:hover { + background: var(--accent-a4); + } + } +} + +// Keep button in consistent position to avoid jerky animation +.collapsed, +.expanded { + .collapseToggle { + right: 0.5rem; + left: auto; + } +} + diff --git a/src/components/docPage/index.tsx b/src/components/docPage/index.tsx index 51e1c7fb995dab..d8f84a4d89412d 100644 --- a/src/components/docPage/index.tsx +++ b/src/components/docPage/index.tsx @@ -12,6 +12,7 @@ import './type.scss'; import {Banner} from '../banner'; import {Breadcrumbs} from '../breadcrumbs'; import {CodeContextProvider} from '../codeContext'; +import {CollapsibleRightSidebar} from '../collapsibleRightSidebar'; import {CopyMarkdownButton} from '../copyMarkdownButton'; import {DocFeedback} from '../docFeedback'; import {GitHubCTA} from '../githubCTA'; @@ -67,10 +68,10 @@ export function DocPage({ {sidebar ?? ( )} -
+
{hasToc && ( - + + + + )} - +