Skip to content

Commit

Permalink
Fix - infobar additional div when there's no CTA (#935)
Browse files Browse the repository at this point in the history
* fix - not render CTA parent div when there's no CTA

* add stories
  • Loading branch information
adriangohjw authored Dec 13, 2024
1 parent 76e70f1 commit f111a0e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,13 @@ export const LongText: Story = {
secondaryButtonUrl: "https://google.com",
},
}

export const NoCTA: Story = {
args: {
sectionIdx: 0,
title:
"Longer title here that spans multiple lines and is quite long and verbose and takes up a lot of space",
description:
"About a sentence worth of description here About a sentence worth of description here About a sentence worth of description here",
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const Infobar = ({
LinkComponent,
}: InfobarProps) => {
const simplifiedLayout = getTailwindVariantLayout(layout)
const hasPrimaryCTA = !!buttonLabel && !!buttonUrl
const hasSecondaryCTA = !!secondaryButtonLabel && !!secondaryButtonUrl

return (
<section>
Expand Down Expand Up @@ -83,42 +85,44 @@ const Infobar = ({
)}
</div>

<div
className={compoundStyles.buttonContainer({
layout: simplifiedLayout,
})}
>
{buttonLabel && buttonUrl && (
<LinkButton
href={getReferenceLinkHref(
buttonUrl,
site.siteMap,
site.assetsBaseUrl,
)}
size={simplifiedLayout === "homepage" ? "lg" : "base"}
LinkComponent={LinkComponent}
isWithFocusVisibleHighlight
>
{buttonLabel}
</LinkButton>
)}
{(hasPrimaryCTA || hasSecondaryCTA) && (
<div
className={compoundStyles.buttonContainer({
layout: simplifiedLayout,
})}
>
{hasPrimaryCTA && (
<LinkButton
href={getReferenceLinkHref(
buttonUrl,
site.siteMap,
site.assetsBaseUrl,
)}
size={simplifiedLayout === "homepage" ? "lg" : "base"}
LinkComponent={LinkComponent}
isWithFocusVisibleHighlight
>
{buttonLabel}
</LinkButton>
)}

{secondaryButtonLabel && secondaryButtonUrl && (
<LinkButton
href={getReferenceLinkHref(
secondaryButtonUrl,
site.siteMap,
site.assetsBaseUrl,
)}
size={simplifiedLayout === "homepage" ? "lg" : "base"}
variant="outline"
LinkComponent={LinkComponent}
isWithFocusVisibleHighlight
>
{secondaryButtonLabel}
</LinkButton>
)}
</div>
{hasSecondaryCTA && (
<LinkButton
href={getReferenceLinkHref(
secondaryButtonUrl,
site.siteMap,
site.assetsBaseUrl,
)}
size={simplifiedLayout === "homepage" ? "lg" : "base"}
variant="outline"
LinkComponent={LinkComponent}
isWithFocusVisibleHighlight
>
{secondaryButtonLabel}
</LinkButton>
)}
</div>
)}
</div>
</div>
</section>
Expand Down

0 comments on commit f111a0e

Please sign in to comment.