feat(BOOK-743): Replaced deprecated Button component
Approved-by: Bianca Widstam
This commit is contained in:
@@ -8,8 +8,8 @@ import type { VariantProps } from "class-variance-authority"
|
||||
import Link from "next/link"
|
||||
import { useIntl } from "react-intl"
|
||||
import { MaterialIcon } from "../Icons/MaterialIcon"
|
||||
import { Typography } from "../Typography"
|
||||
import { MaterialIconName } from "../Icons/MaterialIcon/generated"
|
||||
import { Typography } from "../Typography"
|
||||
|
||||
export interface ButtonLinkProps
|
||||
extends
|
||||
@@ -17,6 +17,7 @@ export interface ButtonLinkProps
|
||||
VariantProps<typeof variants> {
|
||||
leadingIconName?: MaterialIconName | null
|
||||
trailingIconName?: MaterialIconName | null
|
||||
isExternal?: boolean
|
||||
}
|
||||
|
||||
export default function ButtonLink({
|
||||
@@ -28,6 +29,7 @@ export default function ButtonLink({
|
||||
className,
|
||||
href,
|
||||
target,
|
||||
isExternal,
|
||||
leadingIconName,
|
||||
trailingIconName,
|
||||
children,
|
||||
@@ -48,6 +50,8 @@ export default function ButtonLink({
|
||||
defaultMessage: "Opens in a new tab/window",
|
||||
})
|
||||
|
||||
const LinkComponent = isExternal ? "a" : Link
|
||||
|
||||
return (
|
||||
<Typography
|
||||
variant={
|
||||
@@ -56,9 +60,9 @@ export default function ButtonLink({
|
||||
: "Body/Paragraph/mdBold"
|
||||
}
|
||||
>
|
||||
<Link
|
||||
<LinkComponent
|
||||
className={classNames}
|
||||
href={href}
|
||||
href={href.toString()}
|
||||
target={target}
|
||||
title={target === "_blank" ? newTabText : ""}
|
||||
{...props}
|
||||
@@ -78,7 +82,7 @@ export default function ButtonLink({
|
||||
size={size === "sm" ? 20 : 24}
|
||||
/>
|
||||
) : null}
|
||||
</Link>
|
||||
</LinkComponent>
|
||||
</Typography>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user