Skip to content

Commit 5a734fe

Browse files
committed
feat(components): enhance CodeExamplePackage with feature descriptions
- Add support for detailed feature descriptions in CodeExamplePackage - Implement toggle functionality for multi-line feature descriptions - Update CodeExamples to include more detailed feature information
1 parent 3628923 commit 5a734fe

File tree

2 files changed

+90
-13
lines changed

2 files changed

+90
-13
lines changed

src/components/CodeExamplePackage.tsx

Lines changed: 73 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useState } from "react";
12
import { Button } from "@/components/ui/button";
23
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
34
import CodeBlock from "@/components/CodeBlock";
@@ -14,7 +15,7 @@ interface PackageExampleProps {
1415
name: string;
1516
subtitle: string;
1617
description: string;
17-
features: string[];
18+
features: (FeatureItem | string)[];
1819
icon: React.ReactNode;
1920
gradientClass: string;
2021
shadowClass: string;
@@ -24,6 +25,15 @@ interface PackageExampleProps {
2425
soon?: boolean;
2526
}
2627

28+
interface FeatureItem {
29+
title: string;
30+
description?: string;
31+
}
32+
33+
function normalizeFeature(feature: FeatureItem | string): FeatureItem {
34+
return typeof feature === "string" ? { title: feature } : feature;
35+
}
36+
2737
const CodeExamplePackage = ({
2838
name,
2939
subtitle,
@@ -37,10 +47,18 @@ const CodeExamplePackage = ({
3747
reversed = false,
3848
soon = false,
3949
}: PackageExampleProps) => {
50+
const [openFeature, setOpenFeature] = useState<number | null>(null);
51+
52+
const toggleFeature = (index: number) => {
53+
setOpenFeature(openFeature === index ? null : index);
54+
};
55+
4056
const descriptionContent = (
4157
<div className="space-y-6 lg:col-span-1">
4258
<div className="flex items-center space-x-3">
43-
<div className={`w-12 h-12 ${gradientClass} rounded-xl flex items-center justify-center ${shadowClass}`}>
59+
<div
60+
className={`w-12 h-12 ${gradientClass} rounded-xl flex items-center justify-center ${shadowClass}`}
61+
>
4462
{icon}
4563
</div>
4664
<div>
@@ -60,12 +78,51 @@ const CodeExamplePackage = ({
6078
</div>
6179

6280
<div className="space-y-3 pl-6">
63-
{features.map((feature, index) => (
64-
<div key={index} className="flex items-center space-x-3">
65-
<div className={`w-2 h-2 rounded-full ${colorClass.replace("text-", "bg-")}`}></div>
66-
<span className="text-muted-foreground">{feature}</span>
67-
</div>
68-
))}
81+
{features.map((feature, index) => {
82+
const { title, description } = normalizeFeature(feature);
83+
84+
const isOpen = openFeature === index;
85+
86+
return (
87+
<div key={index} className="flex flex-col">
88+
{description ? (
89+
<>
90+
<button
91+
type="button"
92+
onClick={() => toggleFeature(index)}
93+
className="flex items-center space-x-3 cursor-pointer group focus:outline-none"
94+
>
95+
<div
96+
className={`w-2 h-2 rounded-full ${colorClass.replace(
97+
"text-",
98+
"bg-"
99+
)} group-hover:scale-125 transition-transform`}
100+
/>
101+
<span className="text-muted-foreground group-hover:text-foreground transition-colors">
102+
{title}
103+
</span>
104+
</button>
105+
106+
{isOpen && (
107+
<div className="mt-2 pl-5 pr-2 py-2 bg-background border rounded-md shadow-sm transition-all">
108+
{description}
109+
</div>
110+
)}
111+
</>
112+
) : (
113+
<div className="flex items-center space-x-3">
114+
<div
115+
className={`w-2 h-2 rounded-full ${colorClass.replace(
116+
"text-",
117+
"bg-"
118+
)}`}
119+
/>
120+
<span className="text-muted-foreground">{title}</span>
121+
</div>
122+
)}
123+
</div>
124+
);
125+
})}
69126
</div>
70127

71128
<div className="pl-6">
@@ -84,8 +141,12 @@ const CodeExamplePackage = ({
84141
<div className="lg:col-span-2">
85142
<Tabs defaultValue={tabs[0]?.value} className="w-full">
86143
<TabsList single={tabs.length === 1}>
87-
{tabs.map(tab => (
88-
<TabsTrigger single={tabs.length === 1} key={tab.value} value={tab.value}>
144+
{tabs.map((tab) => (
145+
<TabsTrigger
146+
single={tabs.length === 1}
147+
key={tab.value}
148+
value={tab.value}
149+
>
89150
{tab.label}
90151
</TabsTrigger>
91152
))}
@@ -106,10 +167,10 @@ const CodeExamplePackage = ({
106167
return (
107168
<div className="grid grid-cols-1 lg:grid-cols-3 gap-12 items-start">
108169
<div className="space-y-6 lg:col-start-3 lg:col-span-1">
109-
{descriptionContent.props.children}
170+
{descriptionContent}
110171
</div>
111172
<div className="lg:col-start-1 lg:col-span-2 lg:row-start-1">
112-
{codeContent.props.children}
173+
{codeContent}
113174
</div>
114175
</div>
115176
);

src/components/CodeExamples.tsx

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,23 @@ const CodeExamples = () => {
8686
name="Constructo"
8787
subtitle="Serialização Inteligente"
8888
description="Transforme dados em objetos tipados com validação automática. Classes que se serializam e se validam de forma elegante e eficiente."
89-
features={["Serialização automática", "Validação integrada", "Type safety nativo"]}
89+
features={[
90+
{
91+
title: "Serialização automática",
92+
description:
93+
"Serialização avançada de objetos, permitindo a desconstrução de classes com objetos alinhados e realizando a tradução de tipos."
94+
},
95+
{
96+
title: "Validação integrada",
97+
description:
98+
"Junto com a serialização avançada e graças as tratativas internas, conseguimos realizar a validação de estruturas complexas por meio de processos encandeados com chains."
99+
},
100+
{
101+
title: "Type safety nativo",
102+
description:
103+
"Leva a tipagem da sua aplicação para outro nível!! Com o nosso sistema de tipagem, conseguimos ir além dos tipos nativos da linguagem, permitindo o uso de *attributes* personalizados, passando uma maior segurança e coesão na sua aplicação."
104+
}
105+
]}
90106
icon={<Blocks className="w-6 h-6 text-constructo-foreground" />}
91107
gradientClass="bg-gradient-constructo"
92108
shadowClass="shadow-constructo"

0 commit comments

Comments
 (0)