Skip to content

Commit 56b52f8

Browse files
committed
feat: implements new ResponsiveLayout component
1 parent e6032c9 commit 56b52f8

File tree

8 files changed

+36
-169
lines changed

8 files changed

+36
-169
lines changed

src/components/ResponsiveLayout.tsx

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { cn } from "@/lib/utils.ts";
2-
import React, { forwardRef, useImperativeHandle, useRef } from "react";
32
import { Menu, X } from "lucide-react";
3+
import React, { forwardRef, useImperativeHandle, useRef } from "react";
44

55
interface ResponsiveLayoutProps {
66
leftContent: React.ReactNode;
@@ -12,6 +12,13 @@ interface ResponsiveLayoutRef {
1212
closeSidebar: () => void;
1313
}
1414

15+
const ResponsiveLayoutWrapper = forwardRef<HTMLDivElement, React.HTMLAttributes<HTMLDivElement>>(
16+
(args: React.HTMLAttributes<HTMLDivElement>, ref) => {
17+
const { className, ...props } = args;
18+
return <div ref={ref} className={cn('p-5 lg:px-6"', className)} {...props} />;
19+
},
20+
);
21+
1522
const ResponsiveLayout = forwardRef<ResponsiveLayoutRef, ResponsiveLayoutProps>((props, ref) => {
1623
const { leftContent, rightContent, title } = props;
1724
const sidebarRef = useRef<HTMLDivElement>(null);
@@ -56,12 +63,13 @@ const ResponsiveLayout = forwardRef<ResponsiveLayoutRef, ResponsiveLayoutProps>(
5663
className="absolute inset-0 bg-black opacity-0 pointer-events-none transition-opacity duration-100 z-[5] lg:hidden"
5764
/>
5865

59-
<div
66+
<ResponsiveLayoutWrapper
6067
ref={sidebarRef}
6168
className={cn(
62-
"h-full w-3/12 min-w-[240px] -translate-x-full transition-transform duration-100",
63-
"absolute top-0 left-0 z-10 bg-background p-5",
64-
"lg:relative lg:block lg:bg-transparent lg:translate-x-0 lg:px-6",
69+
"h-full w-3/12 lg:w-2/12 min-w-[240px] md:min-w-fit -translate-x-full transition-transform duration-100",
70+
"absolute top-0 left-0 z-10 bg-background",
71+
"lg:relative lg:block lg:bg-transparent lg:translate-x-0",
72+
"p-5 lg:px-6",
6573
)}
6674
>
6775
<div className="flex justify-end lg:hidden">
@@ -70,9 +78,9 @@ const ResponsiveLayout = forwardRef<ResponsiveLayoutRef, ResponsiveLayoutProps>(
7078
</button>
7179
</div>
7280
<div>{leftContent}</div>
73-
</div>
81+
</ResponsiveLayoutWrapper>
7482

75-
<div className="w-full lg:w-9/12 p-5 lg:px-6">
83+
<ResponsiveLayoutWrapper className="w-full lg:10/12">
7684
<div className="flex items-center gap-3 mb-4">
7785
<button
7886
onClick={handleToggle}
@@ -87,12 +95,13 @@ const ResponsiveLayout = forwardRef<ResponsiveLayoutRef, ResponsiveLayoutProps>(
8795
)}
8896
</div>
8997
<div>{rightContent}</div>
90-
</div>
98+
</ResponsiveLayoutWrapper>
9199
</div>
92100
);
93101
});
94102

95103
ResponsiveLayout.displayName = "ResponsiveLayout";
104+
ResponsiveLayoutWrapper.displayName = "ResponsiveLayoutWrapper";
96105

97-
export default ResponsiveLayout;
106+
export { ResponsiveLayout, ResponsiveLayoutWrapper };
98107
export type { ResponsiveLayoutRef };

src/components/ResponsiveLayoutSidebar.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ const ResponsiveLayoutSidebar = (props: ResponsiveLayoutSidebarProps) => {
2727
onClick={() => onItemClick(item.id)}
2828
className={cn(
2929
"block w-full text-left transition-colors py-1 hover:text-primary",
30-
item.level === 1 ? "ml-3 text-xs text-muted-foreground" : "text-sm",
30+
item.level === 1
31+
? "ml-3 text-xs md:text-sm text-muted-foreground"
32+
: "text-sm md:text-base",
3133
)}
3234
>
3335
{item.level === 1 ? `• ${item.label}` : item.label}
@@ -38,5 +40,5 @@ const ResponsiveLayoutSidebar = (props: ResponsiveLayoutSidebarProps) => {
3840
};
3941

4042
ResponsiveLayoutSidebar.displayName = "ResponsiveLayout";
41-
export default ResponsiveLayoutSidebar;
43+
export { ResponsiveLayoutSidebar };
4244
export type { ResponsiveLayoutSidebarItem };

src/pages/Docs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ const Docs = () => {
8989

9090
<div className="flex-1 relative">
9191
<div className="absolute inset-0 bg-gradient-hero opacity-5"></div>
92-
<div>
92+
<div className="container p-0">
9393
<Outlet />
9494
</div>
9595
</div>

src/pages/Docs/About.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
1+
import { ResponsiveLayoutWrapper } from "@/components/ResponsiveLayout.tsx";
22
import { Badge } from "@/components/ui/badge";
3+
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
34
import { Code, Heart, Target, Users } from "lucide-react";
45

56
const About = () => {
67
return (
7-
<div className="mx-auto space-y-8">
8+
<ResponsiveLayoutWrapper className="mx-auto space-y-8">
89
<div className="space-y-4">
910
<h1 className="text-4xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
1011
Sobre o Devitools
@@ -149,7 +150,7 @@ const About = () => {
149150
</div>
150151
</div>
151152
</div>
152-
</div>
153+
</ResponsiveLayoutWrapper>
153154
);
154155
};
155156

src/pages/Docs/Ecosystem.tsx

Lines changed: 0 additions & 148 deletions
This file was deleted.

src/pages/Docs/Guides.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { ResponsiveLayoutWrapper } from "@/components/ResponsiveLayout.tsx";
12
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
23
import { Badge } from "@/components/ui/badge";
34
import { BookOpen, Code, FileText, Zap } from "lucide-react";
45

56
const Guides = () => {
67
return (
7-
<div className="space-y-8">
8+
<ResponsiveLayoutWrapper className="space-y-8">
89
<div className="space-y-4">
910
<h1 className="text-4xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
1011
Guias de Desenvolvimento
@@ -109,7 +110,7 @@ const Guides = () => {
109110
</div>
110111
</div>
111112
</div>
112-
</div>
113+
</ResponsiveLayoutWrapper>
113114
);
114115
};
115116

src/pages/Docs/Introduction.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import ResponsiveLayout, { ResponsiveLayoutRef } from "@/components/ResponsiveLayout.tsx";
2-
import ResponsiveLayoutSidebar, {
1+
import { ResponsiveLayout, ResponsiveLayoutRef } from "@/components/ResponsiveLayout.tsx";
2+
import {
3+
ResponsiveLayoutSidebar,
34
ResponsiveLayoutSidebarItem,
45
} from "@/components/ResponsiveLayoutSidebar.tsx";
56
import { Badge } from "@/components/ui/badge";

src/pages/Docs/Reference.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import ResponsiveLayout, { ResponsiveLayoutRef } from "@/components/ResponsiveLayout.tsx";
2-
import ResponsiveLayoutSidebar, {
1+
import { ResponsiveLayout, ResponsiveLayoutRef } from "@/components/ResponsiveLayout.tsx";
2+
import {
3+
ResponsiveLayoutSidebar,
34
ResponsiveLayoutSidebarItem,
45
} from "@/components/ResponsiveLayoutSidebar.tsx";
56
import React, { useRef } from "react";

0 commit comments

Comments
 (0)