Skip to content

Commit 4f567b5

Browse files
committed
feat: Constructo page improvements
1 parent 30554ec commit 4f567b5

File tree

7 files changed

+68
-64
lines changed

7 files changed

+68
-64
lines changed

src/components/CodeBlock.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ interface CodeBlockProps {
1919
const CodeBlock = ({
2020
children,
2121
language = "php",
22-
size = "md",
22+
size,
2323
showCopy = true,
2424
className,
2525
}: CodeBlockProps) => {
@@ -56,7 +56,7 @@ const CodeBlock = ({
5656
return (
5757
<Card
5858
className={cn(
59-
"overflow-hidden relative bg-background brightness-100 dark:brightness-125",
59+
"overflow-hidden relative bg-background brightness-100 dark:brightness-150",
6060
className,
6161
)}
6262
>
@@ -89,7 +89,7 @@ const CodeBlock = ({
8989
}}
9090
className={cn(
9191
"!bg-transparent overflow-x-auto p-6 [&_span]:!bg-transparent",
92-
sizeClasses[size],
92+
size ? sizeClasses[size] : "text-xs md:text-sm",
9393
showCopy && "pr-16",
9494
)}
9595
>

src/components/packages/BenefitItem.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ interface BenefitItemProps {
77

88
const BenefitItem = ({ title, description }: BenefitItemProps) => {
99
return (
10-
<div className="flex items-start space-x-4">
11-
<CheckCircle className="w-6 h-6 text-success mt-1 flex-shrink-0" />
12-
<div>
10+
<div className="flex space-x-4">
11+
<div className="flex-shrink-0">
12+
<CheckCircle className="w-6 h-6 text-success mt-1" />
13+
</div>
14+
<div className="text-left">
1315
<h3 className="font-semibold mb-2">{title}</h3>
1416
<p className="text-muted-foreground">{description}</p>
1517
</div>

src/components/packages/CodeExamples.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface CodeExamplesProps {
1414

1515
const CodeExamples = ({ examples }: CodeExamplesProps) => {
1616
return (
17-
<section className="py-20 px-6 bg-card/30">
17+
<section className="py-20 bg-card/30">
1818
<div className="container mx-auto">
1919
<div className="text-center mb-12">
2020
<h2 className="text-3xl font-bold mb-4">Exemplos Práticos</h2>

src/components/packages/CodeTab.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1+
import CodeBlock from "@/components/CodeBlock.tsx";
12
import {
23
Card,
34
CardContent,
45
CardDescription,
56
CardHeader,
67
CardTitle,
78
} from "@/components/ui/card.tsx";
8-
import CodeBlock from "@/components/CodeBlock.tsx";
9-
import { ReactNode } from "react";
109

1110
interface CodeTabProps {
1211
title: string;
@@ -18,11 +17,11 @@ interface CodeTabProps {
1817
const CodeTab = ({ title, description, code, language = "php" }: CodeTabProps) => {
1918
return (
2019
<Card>
21-
<CardHeader>
20+
<CardHeader className="px-3 pt-4 pb-2 lg:px-6 lg:pt-6">
2221
<CardTitle>{title}</CardTitle>
2322
<CardDescription>{description}</CardDescription>
2423
</CardHeader>
25-
<CardContent>
24+
<CardContent className="px-3 pt-2 pb-4 lg:px-6 lg:pt-3 lg:pb-6">
2625
<CodeBlock language={language}>{code}</CodeBlock>
2726
</CardContent>
2827
</Card>

src/components/packages/Features.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface FeaturesProps {
1414

1515
const Features = ({ features }: FeaturesProps) => {
1616
return (
17-
<section className="py-20 px-6">
17+
<section className="py-20">
1818
<div className="container mx-auto">
1919
<div className="text-center mb-16">
2020
<h2 className="text-4xl font-bold mb-4">Recursos Principais</h2>

src/components/packages/Installation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface InstallationProps {
99

1010
const Installation = ({ onPackagistClick, onDocsClick }: InstallationProps) => {
1111
return (
12-
<section id="installation" className="py-16 px-6 bg-card/30">
12+
<section id="installation" className="py-16 bg-card/30">
1313
<div className="container mx-auto">
1414
<div className="text-center mb-12">
1515
<h2 className="text-3xl font-bold mb-4">Instalação Rápida</h2>

src/pages/Constructo.tsx

Lines changed: 54 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ import { scrollTo } from "@/lib/utils.ts";
1313
import {
1414
Blocks,
1515
Cog,
16+
Command,
1617
Database,
1718
Download,
1819
Github,
20+
Network,
1921
Package,
2022
Server,
2123
Shield,
@@ -78,44 +80,44 @@ const Constructo = () => {
7880
const useCases = [
7981
{
8082
icon: <Server className="w-8 h-8 text-constructo-foreground" />,
81-
title: "APIs REST/GraphQL",
83+
title: "Endpoints e Workers",
8284
description:
8385
"Ideal para construção de APIs modernas com serialização automática e validação robusta",
8486
benefits: ["Serialização automática", "Validação de entrada", "Configuração flexível"],
8587
},
8688
{
8789
icon: <Users className="w-8 h-8 text-constructo-foreground" />,
88-
title: "Aplicações Enterprise",
90+
title: "Sistemas de gestão",
8991
description:
90-
"Perfeito para sistemas complexos que precisam de arquitetura sólida e manutenível",
92+
"Perfeito para usar a própria estrutura do projeto para poder testar os limites da aplicação",
9193
benefits: ["Injeção de dependências", "Configuração centralizada", "Testes facilitados"],
9294
},
9395
{
94-
icon: <Zap className="w-8 h-8 text-constructo-foreground" />,
95-
title: "Microserviços",
96+
icon: <Network className="w-8 h-8 text-constructo-foreground" />,
97+
title: "Microsserviços",
9698
description:
97-
"Construa microserviços PHP com configuração padronizada e comunicação eficiente",
98-
benefits: ["Configuração unificada", "Serialização consistente", "Performance otimizada"],
99+
"Construa microsserviços PHP com configuração padronizada e comunicação eficiente",
100+
benefits: ["Configuração unificada", "Serialização consistente", "Desempenho otimizado"],
99101
},
100102
];
101103

102104
const codeExamples = [
103105
{
104-
id: "container",
106+
id: "serialization",
105107
title: "Serialização",
106108
description:
107109
"Apenas defina os tipos dos argumentos do construtor que sua classe deve receber e deixa o resto com o Builder",
108110
code: `use Constructo\\Core\\Serialize\\Builder;
109111
use Constructo\\Support\\Set;
110-
use Constructo\\Type\\Timestamp;
112+
use DateTime;
111113
112114
// Defina sua entidade informando os valores das propriedades no construtor
113115
readonly class User
114116
{
115117
public function __construct(
116118
public int $id,
117119
public string $name,
118-
public Timestamp $birthDate,
120+
public DateTime $birthDate,
119121
public bool $isActive = true,
120122
public array $tags = [],
121123
) {}
@@ -148,22 +150,20 @@ echo sprintf(" Data de Nascimento: %s\\n", $user->birthDate->format('Y-m-d'));
148150
# Data de Nascimento: 1981-08-13`,
149151
},
150152
{
151-
id: "serialization",
153+
id: "deserialization",
152154
title: "Desserialização",
153155
description:
154156
"Passe uma instância de objeto e converta-a em um objeto facilmente convertível para em array associativo ou JSON",
155-
code: `
156-
use Constructo\\Core\\Deserialize\\Demolisher;
157-
use Constructo\\Support\\Set;
158-
use Constructo\\Type\\Timestamp;
157+
code: `use Constructo\\Core\\Deserialize\\Demolisher;
158+
use DateTime;
159159
160160
// Defina sua entidade informando os valores das propriedades no construtor
161161
readonly class User
162162
{
163163
public function __construct(
164164
public int $id,
165165
public string $name,
166-
public Timestamp $birthDate,
166+
public DateTime $birthDate,
167167
public bool $isActive = true,
168168
public array $tags = [],
169169
) {}
@@ -173,21 +173,20 @@ readonly class User
173173
$user = new User(
174174
id: 1,
175175
name: 'João Silva',
176-
birthDate: new Timestamp('1981-08-13'),
176+
birthDate: new DateTime('1981-08-13'),
177177
isActive: true,
178178
tags: ['nice', 'welcome'],
179179
);
180180
181181
// Crie um novo demolisher e use-o para destruir o objeto
182182
$object = (new Demolisher())->demolish($user);
183183
184-
$set = Set::createFrom((array) $object);
185184
echo "# Usuário: \\n";
186-
echo sprintf("# ID: %s\\n", $set->get('id'));
187-
echo sprintf("# Nome: %s\\n", $set->get('name'));
188-
echo sprintf("# Ativo: %s\\n", $set->get('is_active') ? 'Sim' : 'Não');
189-
echo sprintf("# Tags: %s\\n", implode(', ', $set->get('tags')));
190-
echo sprintf("# Data de Nascimento: %s\\n", $set->get('birth_date'));
185+
echo sprintf("# ID: %s\\n", $object->id);
186+
echo sprintf("# Nome: %s\\n", $object->name);
187+
echo sprintf("# Ativo: %s\\n", $object->is_active ? 'Sim' : 'Não');
188+
echo sprintf("# Tags: %s\\n", implode(', ', $object->tags));
189+
echo sprintf("# Data de Nascimento: %s\\n", $object->birth_date);
191190
192191
# Usuário:
193192
# ID: 1
@@ -202,7 +201,7 @@ echo sprintf("# Data de Nascimento: %s\\n", $set->get('birth_date'));
202201
description:
203202
"Simplesmente utilize as propriedades da classe que receberá os dados para gerar as regras de validação para sua `action`",
204203
code: `use Constructo\\Factory\\ReflectorFactory;
205-
use Constructo\\Type\\Timestamp;
204+
use DateTime;
206205
207206
use function array_export;
208207
@@ -212,7 +211,7 @@ readonly class User
212211
public function __construct(
213212
public int $id,
214213
public string $name,
215-
public Timestamp $birthDate,
214+
public DateTime $birthDate,
216215
public bool $isActive = true,
217216
public array $tags = [],
218217
) {
@@ -226,7 +225,7 @@ echo "# Regras de validação \\n";
226225
echo array_export($schema->rules(), 1);
227226
echo "\\n";
228227
229-
# Regras de validação
228+
# Regras de validação geradas:
230229
[
231230
'id' => ['required', 'integer'],
232231
'name' => ['required', 'string'],
@@ -239,32 +238,36 @@ echo "\\n";
239238
{
240239
id: "testing",
241240
title: "Testes",
242-
description: "Use Faker para gerar dados realistas baseados nas suas classes",
243-
code: `<?php
244-
use Devitools\\Constructo\\Testing\\Factory;
245-
246-
class UserFactory extends Factory
241+
description:
242+
"Combine alguns recursos para gerar dados de forma dinâmica a partir da estrutura das classes envolvidas na rotina de teste",
243+
code: `use App\\Domain\\Entity\\User;
244+
use App\\Infrastructure\\Persistence\\Postgres\\PostgresUserRepository;
245+
use Constructo\\Testing\\BuilderExtension;
246+
use Constructo\\Testing\\FakerExtension;
247+
use Constructo\\Testing\\MakeExtension;
248+
use Illuminate\\Foundation\\Testing\\TestCase;
249+
250+
class UserRepositoryTest extends TestCase
247251
{
248-
protected string $model = User::class;
249-
250-
public function definition(): array
251-
{
252-
return [
253-
'name' => $this->faker->name(),
254-
'email' => $this->faker->email(),
255-
'createdAt' => $this->faker->dateTime()
256-
];
257-
}
258-
}
252+
use MakeExtension;
253+
use FakerExtension;
254+
use BuilderExtension;
259255
260-
// Gerar um usuário fake
261-
$user = UserFactory::make();
256+
final public function test_create_user_successfully(): void
257+
{
258+
// Assert
259+
$values = $this->faker()->fake(User::class);
260+
$user = $this->builder()->build(User::class, $values);
261+
$userRepository = $this->make(PostgresUserRepository::class);
262262
263-
// Gerar múltiplos usuários
264-
$users = UserFactory::times(10)->make();
263+
// Act
264+
$result = $this->userRepository->create($user);
265265
266-
// Persistir no banco (se configurado)
267-
$user = UserFactory::create();`,
266+
// Assert
267+
$this->assertNotNull($result);
268+
$this->assertDatabaseHas('users', ['email' => $user->email]);
269+
}
270+
}`,
268271
},
269272
];
270273

@@ -274,12 +277,12 @@ $user = UserFactory::create();`,
274277
description: "Totalmente compatível com PSR-11, PSR-4 e outros padrões",
275278
},
276279
{
277-
title: "Type Safety",
278-
description: "Aproveite ao máximo o PHP 8.0+ com tipagem forte",
280+
title: "Tipagem Forte",
281+
description: "Aproveite ao máximo o PHP 8.0+ os recursos de tipagem forte",
279282
},
280283
{
281284
title: "Performance",
282-
description: "Otimizado para alta performance em produção",
285+
description: "Otimizado para alto desempenho em produção",
283286
},
284287
{
285288
title: "Flexibilidade",

0 commit comments

Comments
 (0)