Skip to content

Commit f3a3881

Browse files
committed
feat: implements new ResponsiveLayout component
1 parent 166619d commit f3a3881

4 files changed

Lines changed: 24 additions & 55 deletions

File tree

src/components/docs/ResponsiveLayoutSidebar.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface ResponsiveLayoutSidebarItem {
99

1010
interface ResponsiveLayoutSidebarProps {
1111
items: ResponsiveLayoutSidebarItem[];
12-
onItemClick: (id: string) => void;
12+
onItemClick: (item: ResponsiveLayoutSidebarItem) => void;
1313
title?: string;
1414
description?: string;
1515
}
@@ -24,7 +24,7 @@ const ResponsiveLayoutSidebar = (props: ResponsiveLayoutSidebarProps) => {
2424
{items.map(item => (
2525
<button
2626
key={item.id}
27-
onClick={() => onItemClick(item.id)}
27+
onClick={() => onItemClick(item)}
2828
className={cn(
2929
"block w-full text-left transition-colors py-1 hover:text-primary",
3030
item.level === 1

src/pages/Docs/Examples.tsx

Lines changed: 18 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
2-
import { Clock, Code } from "lucide-react";
3-
import { DocsResponsiveSidebar, SidebarItem } from "@/components/DocsResponsiveSidebar";
1+
import { ResponsiveLayout, ResponsiveLayoutRef } from "@/components/docs/ResponsiveLayout.tsx";
2+
import {
3+
ResponsiveLayoutSidebar,
4+
ResponsiveLayoutSidebarItem,
5+
} from "@/components/docs/ResponsiveLayoutSidebar.tsx";
6+
import React, { useRef } from "react";
7+
import { Outlet, useNavigate } from "react-router-dom";
48

59
const Examples = () => {
6-
const sidebarItems: SidebarItem[] = [
10+
const layoutRef = useRef<ResponsiveLayoutRef>(null);
11+
const navigate = useNavigate();
12+
const sidebarItems: ResponsiveLayoutSidebarItem[] = [
713
{ id: "constructo", label: "Constructo" },
814
{ id: "validacao-forms", label: "Validação de Forms", level: 1 },
915
{ id: "gerenciamento-estado", label: "Gerenciamento de Estado", level: 1 },
@@ -15,54 +21,17 @@ const Examples = () => {
1521
{ id: "testes-automatizados", label: "Testes Automatizados", level: 1 },
1622
];
1723

18-
const handleItemClick = (id: string) => {
19-
const element = document.getElementById(id);
20-
element?.scrollIntoView({ behavior: "smooth" });
24+
const handleItemClick = (item: ResponsiveLayoutSidebarItem) => {
25+
navigate(`/docs/example/${item.id}`);
2126
};
2227

2328
return (
24-
<div className="flex gap-8">
25-
<DocsResponsiveSidebar
26-
items={sidebarItems}
27-
onItemClick={handleItemClick}
28-
title="Exemplos"
29-
description="Navegue pelos exemplos práticos"
30-
/>
31-
32-
{/* Conteúdo Principal - Coluna Direita */}
33-
<div className="flex-1 space-y-8 lg:border-l lg:pl-8 pt-[16px]">
34-
<div className="space-y-4">
35-
<h1 className="text-4xl font-bold bg-gradient-to-r from-primary to-accent bg-clip-text text-transparent">
36-
Exemplos Práticos
37-
</h1>
38-
<p className="text-xl text-muted-foreground">
39-
Exemplos práticos e casos de uso dos pacotes Devitools.
40-
</p>
41-
</div>
42-
43-
<Card className="text-center py-12">
44-
<CardHeader className="pb-4">
45-
<div className="flex justify-center mb-4">
46-
<div className="relative">
47-
<Code className="h-12 w-12 text-muted-foreground" />
48-
<Clock className="h-6 w-6 text-amber-500 absolute -top-1 -right-1" />
49-
</div>
50-
</div>
51-
<CardTitle className="text-2xl">Exemplos em Desenvolvimento</CardTitle>
52-
<CardDescription className="text-base">
53-
Estamos preparando exemplos práticos e detalhados para cada pacote
54-
</CardDescription>
55-
</CardHeader>
56-
<CardContent>
57-
<p className="text-muted-foreground">
58-
Em breve você encontrará aqui exemplos completos de uso dos pacotes Devitools,
59-
incluindo casos de uso comuns, implementações de referência e código de exemplo pronto
60-
para usar.
61-
</p>
62-
</CardContent>
63-
</Card>
64-
</div>
65-
</div>
29+
<ResponsiveLayout
30+
ref={layoutRef}
31+
title={"Aprendendo com Exemplos"}
32+
leftContent={<ResponsiveLayoutSidebar items={sidebarItems} onItemClick={handleItemClick} />}
33+
rightContent={<Outlet />}
34+
/>
6635
);
6736
};
6837

src/pages/Docs/Introduction.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import React, { useRef } from "react";
1010

1111
const Introduction = () => {
1212
const layoutRef = useRef<ResponsiveLayoutRef>(null);
13-
const scrollToSection = (id: string) => {
14-
const element = document.getElementById(id);
13+
const scrollToSection = (item: ResponsiveLayoutSidebarItem) => {
14+
const element = document.getElementById(item.id);
1515
if (element) {
1616
element.scrollIntoView({ behavior: "smooth" });
1717
}

src/pages/Docs/Reference.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ const Reference = () => {
5252
},
5353
];
5454

55-
const handleItemClick = (id: string) => {
56-
navigate(`/docs/reference/${id}`);
55+
const handleItemClick = (item: ResponsiveLayoutSidebarItem) => {
56+
navigate(`/docs/reference/${item.id}`);
5757
};
5858

5959
return (

0 commit comments

Comments
 (0)