feat: add support for custom target prop value in cta link

This commit is contained in:
Hossein Mehrabi
2023-06-02 17:50:12 +03:30
parent 9106e1a21f
commit 9bcbaab1f9
2 changed files with 20 additions and 6 deletions
@@ -1,10 +1,15 @@
import { Button, ButtonProps, Typography } from '@acid-info/lsd-react'
import {
Button,
ButtonProps,
Typography,
TypographyProps,
} from '@acid-info/lsd-react'
import clsx from 'clsx'
import React from 'react'
import './CallToActionButton.scss'
export type CallToActionButtonProps = Omit<
React.HTMLAttributes<HTMLDivElement>,
React.AnchorHTMLAttributes<HTMLAnchorElement>,
'title'
> & {
href?: string
@@ -12,6 +17,8 @@ export type CallToActionButtonProps = Omit<
variant?: ButtonProps['variant']
}
const LinkElement = Typography as React.FC<TypographyProps & { component: 'a' }>
export const CallToActionButton: React.FC<CallToActionButtonProps> = ({
href,
className,
@@ -21,16 +28,17 @@ export const CallToActionButton: React.FC<CallToActionButtonProps> = ({
...props
}) => {
return (
<Typography
<LinkElement
className={clsx('mdx-cta-button', className)}
variant="body1"
component="a"
href={href}
target="_blank"
target={'_blank'}
{...(props as any)}
>
<Button size={size} variant={variant}>
{children}
</Button>
</Typography>
</LinkElement>
)
}
@@ -13,6 +13,7 @@ export type CallToActionSectionProps = Omit<
columns?: 1 | 2
href?: string
label?: string
target?: React.AnchorHTMLAttributes<HTMLAnchorElement>['target']
}
export const CallToActionSection: React.FC<CallToActionSectionProps> = ({
@@ -21,6 +22,7 @@ export const CallToActionSection: React.FC<CallToActionSectionProps> = ({
title = '',
columns = 1,
description,
target,
className,
children,
...props
@@ -53,7 +55,11 @@ export const CallToActionSection: React.FC<CallToActionSectionProps> = ({
{description}
</Typography>
)}
<CallToActionButton href={href} className="mdx-cta-section__link">
<CallToActionButton
target={target}
href={href}
className="mdx-cta-section__link"
>
{label}
</CallToActionButton>
</div>