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 promo tile links #1919 #1920

Merged
merged 2 commits into from
Oct 5, 2023
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
6 changes: 4 additions & 2 deletions web/pageComponents/shared/ButtonLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import NextLink, { LinkProps } from 'next/link'
import { getUrlFromAction } from '../../common/helpers/getUrlFromAction'
import { getLocaleFromName } from '../../lib/localization'
import type { LinkData } from '../../types/types'
import { cloneElement } from 'react'

type Props = {
action: LinkData
children?: React.ReactNode
children?: React.ReactElement
} & (ButtonLinkProps | LinkProps)

export const ButtonLink = ({ action, children, ...rest }: Props) => {
Expand All @@ -21,9 +22,10 @@ export const ButtonLink = ({ action, children, ...rest }: Props) => {
// If the URL is a static AEM page it should behave as an internal link in the web
if (type === 'internalUrl') {
const locale = getLocaleFromName(action.link?.lang)
const child = children ? cloneElement(children, { href: url, locale: locale, ariaLabel: ariaLabel }) : undefined
return (
<>
{children || (
{child || (
<Link locale={locale} href={url} aria-label={ariaLabel} {...(rest as ButtonLinkProps)}>
{label}
</Link>
Expand Down
33 changes: 19 additions & 14 deletions web/pageComponents/topicPages/PromoTileButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LinkData } from '../../types/types'
import { ButtonLink } from '../shared/ButtonLink'
import { Card } from '@components'
import { Card, Link } from '@components'
import { CSSProperties } from 'react'
import styled from 'styled-components'

Expand All @@ -10,29 +10,34 @@ type Props = {
template?: 'default' | 'icon'
}

const StyledButtonLink = styled(ButtonLink)`
text-decoration: none;
const StyledLink = styled(Link)`
gap: var(--space-medium);
border-bottom: none;
`

const StyledButtonLink = styled(ButtonLink)`
text-decoration: none;
`
const Wrapper = styled.div`
padding: 0 var(--space-medium);
`

const IconButtonLink = ({ action, hasImage }: { action: LinkData; hasImage: boolean }) => {
return (
<Wrapper>
<StyledButtonLink legacyBehavior action={action} aria-label={action.ariaLabel}>
<Card.Title
style={
{
'--card-title-fontSize': hasImage ? 'var(--typeScale-2)' : 'var(--typeScale-4)',
'--card-title-fontWeight': hasImage ? '450' : '400',
} as CSSProperties
}
>
{action.label}
</Card.Title>
<StyledButtonLink action={action}>
<StyledLink variant="contentLink" underline={false} aria-label={action.ariaLabel}>
<Card.Title
style={
{
'--card-title-fontSize': hasImage ? 'var(--typeScale-2)' : 'var(--typeScale-4)',
'--card-title-fontWeight': hasImage ? '450' : '400',
} as CSSProperties
}
>
{action.label}
</Card.Title>
</StyledLink>
</StyledButtonLink>
</Wrapper>
)
Expand Down
Loading