Last active
June 6, 2025 17:48
-
-
Save d3vlopes/cdd8b154ceaa1a8de6ef0d0bf8e037a3 to your computer and use it in GitHub Desktop.
Exemplo aplicando Partial pattern em React
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { FeatureModel } from '@/domain/models/Feature'; | |
export const FeaturePartial = (feature: FeatureModel, index?: number) => { | |
return ( | |
<div | |
key={feature.id} | |
className="rounded-lg p-0.5" | |
> | |
<div className="flex flex-col items-center"> | |
<img src={feature.icon.src} alt={feature.icon.alt} /> | |
<h3 className="font-inter font-bold text-center"> | |
{feature.name} | |
</h3> | |
<p className="font-inter text-center"> | |
{feature.description} | |
</p> | |
</div> | |
</div> | |
); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Sem partial --> | |
export const FeatureCards = ({ features }: FeatureCardsProps) => { | |
return ( | |
<div className="flex flex-col gap-4"> | |
{features.map((feature, index) => { | |
return ( | |
<div | |
key={feature.id} | |
className="rounded-lg p-0.5" | |
> | |
<div className="flex flex-col items-center"> | |
<img src={feature.icon.src} alt={feature.icon.alt} /> | |
<h3 className="font-inter font-bold text-center"> | |
{feature.name} | |
</h3> | |
<p className="font-inter text-center"> | |
{feature.description} | |
</p> | |
</div> | |
</div> | |
); | |
})} | |
</div> | |
); | |
}; | |
import { FeaturePartial } from './partials/FeaturePartial'; | |
<!-- Com partial --> | |
export const FeatureCards = ({ features }: FeatureCardsProps) => { | |
return ( | |
<div className="flex flex-col gap-4"> | |
{features.map(FeaturePartial)} | |
</div> | |
); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment