Skip to content

Commit 0dbd9e1

Browse files
committed
feat: implements new ResponsiveLayout component
1 parent f3a3881 commit 0dbd9e1

2 files changed

Lines changed: 77 additions & 17 deletions

File tree

src/components/docs/ResponsiveLayoutSidebar.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@ interface ResponsiveLayoutSidebarItem {
77
level?: number;
88
}
99

10-
interface ResponsiveLayoutSidebarProps {
11-
items: ResponsiveLayoutSidebarItem[];
12-
onItemClick: (item: ResponsiveLayoutSidebarItem) => void;
10+
interface ResponsiveLayoutSidebarProps<T extends ResponsiveLayoutSidebarItem> {
11+
items: T[];
12+
onItemClick: (item: T) => void;
1313
title?: string;
1414
description?: string;
1515
}
1616

17-
const ResponsiveLayoutSidebar = (props: ResponsiveLayoutSidebarProps) => {
17+
const ResponsiveLayoutSidebar = <T extends ResponsiveLayoutSidebarItem>(
18+
props: ResponsiveLayoutSidebarProps<T>,
19+
) => {
1820
const { items, onItemClick, title = "", description = "" } = props;
1921

2022
return (
@@ -41,4 +43,4 @@ const ResponsiveLayoutSidebar = (props: ResponsiveLayoutSidebarProps) => {
4143

4244
ResponsiveLayoutSidebar.displayName = "ResponsiveLayout";
4345
export { ResponsiveLayoutSidebar };
44-
export type { ResponsiveLayoutSidebarItem };
46+
export type { ResponsiveLayoutSidebarItem, ResponsiveLayoutSidebarProps };

src/pages/Docs/Examples.tsx

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,81 @@ import {
66
import React, { useRef } from "react";
77
import { Outlet, useNavigate } from "react-router-dom";
88

9+
interface Example extends ResponsiveLayoutSidebarItem {
10+
path: string;
11+
}
12+
913
const Examples = () => {
1014
const layoutRef = useRef<ResponsiveLayoutRef>(null);
1115
const navigate = useNavigate();
12-
const sidebarItems: ResponsiveLayoutSidebarItem[] = [
13-
{ id: "constructo", label: "Constructo" },
14-
{ id: "validacao-forms", label: "Validação de Forms", level: 1 },
15-
{ id: "gerenciamento-estado", label: "Gerenciamento de Estado", level: 1 },
16-
{ id: "serendipity", label: "Serendipity" },
17-
{ id: "apis-rest", label: "APIs REST", level: 1 },
18-
{ id: "cache-inteligente", label: "Cache Inteligente", level: 1 },
19-
{ id: "effulgence", label: "Effulgence" },
20-
{ id: "documentacao-api", label: "Documentação de API", level: 1 },
21-
{ id: "testes-automatizados", label: "Testes Automatizados", level: 1 },
16+
const sidebarItems: Example[] = [
17+
{
18+
id: "constructo",
19+
label: "Constructo",
20+
path: "/docs/examples/constructo",
21+
},
22+
{
23+
id: "constructo-builder",
24+
label: "Explorando o Builder",
25+
level: 1,
26+
path: "/docs/examples/constructo#builder",
27+
},
28+
{
29+
id: "constructo-demolisher",
30+
label: "Utilizando o Demolisher",
31+
level: 1,
32+
path: "/docs/examples/constructo#demolisher",
33+
},
34+
{
35+
id: "constructo-reflector",
36+
label: "Exemplos de uso do Reflector",
37+
level: 1,
38+
path: "/docs/examples/constructo#reflector",
39+
},
40+
{
41+
id: "constructo-faker",
42+
label: "Testes com Faker",
43+
level: 1,
44+
path: "/docs/examples/constructo#reflector",
45+
},
46+
{
47+
id: "serendipity",
48+
label: "Serendipity",
49+
path: "/docs/examples",
50+
},
51+
{
52+
id: "apis-rest",
53+
label: "APIs REST",
54+
level: 1,
55+
path: "/docs/examples",
56+
},
57+
{
58+
id: "cache-inteligente",
59+
label: "Cache Inteligente",
60+
level: 1,
61+
path: "/docs/examples",
62+
},
63+
{
64+
id: "effulgence",
65+
label: "Effulgence",
66+
path: "/docs/examples",
67+
},
68+
{
69+
id: "documentacao-api",
70+
label: "Documentação de API",
71+
level: 1,
72+
path: "/docs/examples",
73+
},
74+
{
75+
id: "testes-automatizados",
76+
label: "Testes Automatizados",
77+
level: 1,
78+
path: "/docs/examples",
79+
},
2280
];
2381

24-
const handleItemClick = (item: ResponsiveLayoutSidebarItem) => {
25-
navigate(`/docs/example/${item.id}`);
82+
const handleItemClick = (item: Example) => {
83+
navigate(item.path);
2684
};
2785

2886
return (

0 commit comments

Comments
 (0)