|
| 1 | +import { Button } from "@/components/ui/button"; |
| 2 | +import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; |
| 3 | +import CodeBlock from "@/components/CodeBlock"; |
| 4 | +import { ArrowRight } from "lucide-react"; |
| 5 | + |
| 6 | +interface TabContent { |
| 7 | + value: string; |
| 8 | + label: string; |
| 9 | + code: string; |
| 10 | +} |
| 11 | + |
| 12 | +interface PackageExampleProps { |
| 13 | + name: string; |
| 14 | + subtitle: string; |
| 15 | + description: string; |
| 16 | + features: string[]; |
| 17 | + icon: React.ReactNode; |
| 18 | + gradientClass: string; |
| 19 | + shadowClass: string; |
| 20 | + colorClass: string; |
| 21 | + tabs: TabContent[]; |
| 22 | + reversed?: boolean; |
| 23 | +} |
| 24 | + |
| 25 | +const CodeExamplePackage = ({ |
| 26 | + name, |
| 27 | + subtitle, |
| 28 | + description, |
| 29 | + features, |
| 30 | + icon, |
| 31 | + gradientClass, |
| 32 | + shadowClass, |
| 33 | + colorClass, |
| 34 | + tabs, |
| 35 | + reversed = false |
| 36 | +}: PackageExampleProps) => { |
| 37 | + const descriptionContent = ( |
| 38 | + <div className="space-y-6 lg:col-span-1"> |
| 39 | + <div className="flex items-center space-x-3"> |
| 40 | + <div className={`w-12 h-12 ${gradientClass} rounded-xl flex items-center justify-center ${shadowClass}`}> |
| 41 | + {icon} |
| 42 | + </div> |
| 43 | + <div> |
| 44 | + <h3 className={`text-2xl font-bold ${colorClass}`}>{name}</h3> |
| 45 | + <p className="text-muted-foreground">{subtitle}</p> |
| 46 | + </div> |
| 47 | + </div> |
| 48 | + |
| 49 | + <div className="relative"> |
| 50 | + <div className={`absolute -left-1 w-1 h-full bg-gradient-to-b from-${colorClass.replace('text-', '')}/50 to-transparent rounded-full`}></div> |
| 51 | + <p className="text-lg text-foreground pl-6"> |
| 52 | + {description} |
| 53 | + </p> |
| 54 | + </div> |
| 55 | + |
| 56 | + <div className="space-y-3 pl-6"> |
| 57 | + {features.map((feature, index) => ( |
| 58 | + <div key={index} className="flex items-center space-x-3"> |
| 59 | + <div className={`w-2 h-2 rounded-full ${colorClass.replace('text-', 'bg-')}`}></div> |
| 60 | + <span className="text-muted-foreground">{feature}</span> |
| 61 | + </div> |
| 62 | + ))} |
| 63 | + </div> |
| 64 | + |
| 65 | + <div className="pl-6"> |
| 66 | + <Button |
| 67 | + variant="outline" |
| 68 | + className={`group border-${colorClass.replace('text-', '')}/30 hover:border-${colorClass.replace('text-', '')} hover:text-${colorClass.replace('text-', '')}-foreground hover:bg-${colorClass.replace('text-', '')}`} |
| 69 | + > |
| 70 | + Explorar {name} |
| 71 | + <ArrowRight className="w-4 h-4 ml-2 group-hover:translate-x-1 transition-transform" /> |
| 72 | + </Button> |
| 73 | + </div> |
| 74 | + </div> |
| 75 | + ); |
| 76 | + |
| 77 | + const codeContent = ( |
| 78 | + <div className="lg:col-span-2"> |
| 79 | + <Tabs defaultValue={tabs[0]?.value} className="w-full"> |
| 80 | + <TabsList className={`grid w-full grid-cols-${tabs.length} mb-4`}> |
| 81 | + {tabs.map((tab) => ( |
| 82 | + <TabsTrigger key={tab.value} value={tab.value}> |
| 83 | + {tab.label} |
| 84 | + </TabsTrigger> |
| 85 | + ))} |
| 86 | + </TabsList> |
| 87 | + |
| 88 | + {tabs.map((tab) => ( |
| 89 | + <TabsContent key={tab.value} value={tab.value}> |
| 90 | + <CodeBlock language="php" size="md" className={shadowClass}> |
| 91 | + {tab.code} |
| 92 | + </CodeBlock> |
| 93 | + </TabsContent> |
| 94 | + ))} |
| 95 | + </Tabs> |
| 96 | + </div> |
| 97 | + ); |
| 98 | + |
| 99 | + if (reversed) { |
| 100 | + return ( |
| 101 | + <div className="grid grid-cols-1 lg:grid-cols-3 gap-12 items-start"> |
| 102 | + <div className="space-y-6 lg:col-start-3 lg:col-span-1"> |
| 103 | + {descriptionContent.props.children} |
| 104 | + </div> |
| 105 | + <div className="lg:col-start-1 lg:col-span-2 lg:row-start-1"> |
| 106 | + {codeContent.props.children} |
| 107 | + </div> |
| 108 | + </div> |
| 109 | + ); |
| 110 | + } |
| 111 | + |
| 112 | + return ( |
| 113 | + <div className="grid grid-cols-1 lg:grid-cols-3 gap-12 items-start"> |
| 114 | + {descriptionContent} |
| 115 | + {codeContent} |
| 116 | + </div> |
| 117 | + ); |
| 118 | +}; |
| 119 | + |
| 120 | +export default CodeExamplePackage; |
0 commit comments