* fix(BOOK-408): Updated logo aria label * fix(BOOK-408): Added title for links opening in new tab * fix(BOOK-408): Added translations handling for title Approved-by: Anton Gunnarsson Approved-by: Matilda Landström
54 lines
1.0 KiB
TypeScript
54 lines
1.0 KiB
TypeScript
'use client'
|
|
|
|
import Link from 'next/link'
|
|
import { type ComponentProps, type PropsWithChildren } from 'react'
|
|
|
|
import { variants } from './variants'
|
|
|
|
import type { VariantProps } from 'class-variance-authority'
|
|
import { useIntl } from 'react-intl'
|
|
|
|
export interface ButtonLinkProps
|
|
extends PropsWithChildren,
|
|
Omit<ComponentProps<typeof Link>, 'color'>,
|
|
VariantProps<typeof variants> {}
|
|
|
|
export default function ButtonLink({
|
|
variant,
|
|
color,
|
|
size,
|
|
typography,
|
|
wrapping,
|
|
className,
|
|
href,
|
|
target,
|
|
onClick = () => {},
|
|
...props
|
|
}: ButtonLinkProps) {
|
|
const classNames = variants({
|
|
variant,
|
|
color,
|
|
size,
|
|
wrapping,
|
|
typography,
|
|
className,
|
|
})
|
|
|
|
const intl = useIntl()
|
|
const newTabText = intl.formatMessage({
|
|
id: 'common.linkOpenInNewTab',
|
|
defaultMessage: 'Opens in a new tab/window',
|
|
})
|
|
|
|
return (
|
|
<Link
|
|
className={classNames}
|
|
href={href}
|
|
target={target}
|
|
onClick={onClick}
|
|
title={target === '_blank' ? newTabText : ''}
|
|
{...props}
|
|
/>
|
|
)
|
|
}
|