Skip to content

Instantly share code, notes, and snippets.

@d3vlopes
Last active June 6, 2025 17:48
Show Gist options
  • Save d3vlopes/cdd8b154ceaa1a8de6ef0d0bf8e037a3 to your computer and use it in GitHub Desktop.
Save d3vlopes/cdd8b154ceaa1a8de6ef0d0bf8e037a3 to your computer and use it in GitHub Desktop.
Exemplo aplicando Partial pattern em React
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>
);
};
<!-- 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