Skip to content

Commit

Permalink
refac: check label before passing to the component
Browse files Browse the repository at this point in the history
  • Loading branch information
Henrique Caúla committed Dec 20, 2023
1 parent 8e06157 commit 6a79bd6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
7 changes: 3 additions & 4 deletions react/ProductSummaryCustom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,9 @@ function ProductSummaryCustom({
>
<Link className={linkClasses} {...linkProps}>
<article className={summaryClasses}>
<SponsoredBadge
label={sponsoredBadge?.label}
showLabel={showSponsoredBadge}
/>
{showSponsoredBadge ? (
<SponsoredBadge label={sponsoredBadge?.label} />
) : null}
{children}
</article>
</Link>
Expand Down
8 changes: 0 additions & 8 deletions react/components/SponsoredBadge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,13 @@ type Props = {
* The message ID or string for the sponsored label.
*/
label?: string

/**
* Whether to show the sponsored label text.
*/
showLabel?: boolean
}

export const SponsoredBadge = ({
label = 'store/sponsoredBadge.title',
showLabel = false,
}: Props) => {
const { handles } = useCssHandles(CSS_HANDLES)

if (!showLabel) return null

const containerClasses = classNames(
handles.sponsoredBadgeContainer,
'absolute z-1'
Expand Down

0 comments on commit 6a79bd6

Please sign in to comment.