mirror of
https://github.com/wavetermdev/docusaurus-og.git
synced 2026-08-05 13:46:35 -07:00
feat: add support for custom target prop value in cta link
This commit is contained in:
+13
-5
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
+7
-1
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user