Skip to content

Commit 446eb4a

Browse files
committed
feat: implements new ResponsiveLayout component
1 parent f05bc3f commit 446eb4a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/components/docs/ResponsiveLayout.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const ResponsiveLayout = forwardRef<ResponsiveLayoutRef, ResponsiveLayoutProps>(
5555
);
5656

5757
return (
58-
<div className="flex relative min-h-[400px]">
58+
<div className="flex relative min-h-[calc(100vh-140px)]">
5959
{/* Backdrop */}
6060
<div
6161
ref={backdropRef}
@@ -66,7 +66,7 @@ const ResponsiveLayout = forwardRef<ResponsiveLayoutRef, ResponsiveLayoutProps>(
6666
<ResponsiveLayoutWrapper
6767
ref={sidebarRef}
6868
className={cn(
69-
"w-3/12 lg:w-2/12 min-w-[240px] md:min-w-fit h-full -translate-x-full transition-transform duration-100",
69+
"w-3/12 lg:w-2/12 min-w-[240px] md:min-w-fit h-full overflow-auto -translate-x-full transition-transform duration-100",
7070
"absolute top-0 left-0 z-10 bg-background",
7171
"lg:relative lg:block lg:bg-transparent lg:translate-x-0",
7272
)}

src/pages/Docs/Reference.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@ import {
33
ResponsiveLayoutSidebar,
44
ResponsiveLayoutSidebarItem,
55
} from "@/components/docs/ResponsiveLayoutSidebar.tsx";
6-
import React, { useRef } from "react";
7-
import { Outlet, useNavigate } from "react-router-dom";
6+
import React, { useRef, useState } from "react";
7+
import { Outlet, useLocation, useNavigate } from "react-router-dom";
8+
9+
function formatSolutionHeader(current: ResponsiveLayoutSidebarItem | undefined) {
10+
return current ? `Nossa Solução: ${current.label}` : "Nossas Soluções";
11+
}
812

913
const Reference = () => {
1014
const layoutRef = useRef<ResponsiveLayoutRef>(null);
15+
const location = useLocation();
1116
const navigate = useNavigate();
1217
const sidebarItems: ResponsiveLayoutSidebarItem[] = [
1318
{
@@ -51,15 +56,20 @@ const Reference = () => {
5156
level: 0,
5257
},
5358
];
59+
const current = sidebarItems.find(item => location.pathname === `/docs/reference/${item.id}`);
60+
const initialTitle = formatSolutionHeader(current);
61+
const [title, setTitle] = useState(initialTitle);
5462

5563
const handleItemClick = (item: ResponsiveLayoutSidebarItem) => {
64+
setTitle(formatSolutionHeader(item));
65+
layoutRef.current?.closeSidebar();
5666
navigate(`/docs/reference/${item.id}`);
5767
};
5868

5969
return (
6070
<ResponsiveLayout
6171
ref={layoutRef}
62-
title={"Nossas Soluções"}
72+
title={title}
6373
leftContent={<ResponsiveLayoutSidebar items={sidebarItems} onItemClick={handleItemClick} />}
6474
rightContent={
6575
<div className="relative">

0 commit comments

Comments
 (0)