Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/infocols non link should not change colour on hover #971

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,25 @@ export const FourInfoBoxes: Story = {
],
},
}

export const HoverBehaviour: Story = {
args: {
sectionIdx: 0,
title: "Highlights",
subtitle: "Some of the things that we are working on",
infoBoxes: [
{
title: "Has Link",
description: "Should change appearance on hover",
icon: "bar-chart",
buttonUrl: "/faq",
buttonLabel: "Read article",
},
{
title: "No Link",
description: "Should NOT change appearance on hover",
icon: "bar-chart",
},
],
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ const createInfoColsStyles = tv({
infoBoxesContainer:
"grid grid-cols-1 gap-x-16 gap-y-10 md:grid-cols-2 md:gap-y-12 lg:grid-cols-3",
infoBox: "group flex flex-col items-start gap-3 text-left outline-0",
infoBoxIcon:
"h-auto w-6 text-base-content-strong group-hover:text-brand-interaction",
infoBoxIcon: "h-auto w-6 text-base-content-strong",
infoBoxTitle: [
groupFocusVisibleHighlight(),
"prose-headline-lg-semibold text-base-content-strong group-hover:text-brand-interaction",
"prose-headline-lg-semibold text-base-content-strong",
],
infoBoxDescription: "prose-body-base text-base-content",
infoBoxButton:
Expand All @@ -54,6 +53,12 @@ const createInfoColsStyles = tv({
infoBoxButtonIcon: "rotate-[-45deg]",
},
},
hasLink: {
true: {
infoBoxTitle: "group-hover:text-brand-interaction",
infoBoxIcon: "group-hover:text-brand-interaction",
},
},
},
defaultVariants: {
layout: "default",
Expand All @@ -62,12 +67,24 @@ const createInfoColsStyles = tv({

const compoundStyles = createInfoColsStyles()

const InfoBoxIcon = ({ icon }: { icon?: SupportedIconName }) => {
const InfoBoxIcon = ({
icon,
hasLink,
}: {
icon?: SupportedIconName
hasLink: boolean
}) => {
if (!icon) return null

const Icon = SUPPORTED_ICONS_MAP[icon]

return <Icon className={compoundStyles.infoBoxIcon()} />
return (
<Icon
className={compoundStyles.infoBoxIcon({
hasLink,
})}
/>
)
}

const InfoBoxes = ({
Expand All @@ -79,6 +96,7 @@ const InfoBoxes = ({
<div className={compoundStyles.infoBoxesContainer()}>
{infoBoxes.map(
({ title, icon, description, buttonUrl, buttonLabel }, idx) => {
const hasLink = !!buttonUrl
const isExternalLink = isExternalUrl(buttonUrl)
return (
<Link
Expand All @@ -92,17 +110,25 @@ const InfoBoxes = ({
className={compoundStyles.infoBox()}
isExternal={isExternalLink}
>
{icon && <InfoBoxIcon icon={icon} aria-hidden="true" />}
{icon && (
<InfoBoxIcon icon={icon} hasLink={hasLink} aria-hidden="true" />
)}

<h3 className={compoundStyles.infoBoxTitle()}>{title}</h3>
<h3
className={compoundStyles.infoBoxTitle({
hasLink,
})}
>
{title}
</h3>

{description && (
<p className={compoundStyles.infoBoxDescription()}>
{description}
</p>
)}

{buttonLabel && buttonUrl && (
{buttonLabel && hasLink && (
<div className={compoundStyles.infoBoxButton()}>
{buttonLabel}
<BiRightArrowAlt
Expand Down
Loading