mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-26 17:35:10 +00:00
Co-authored-by: Dan Abramov <dan.abramov@me.com> Co-authored-by: Sylwia Vargas <sylwia.vargas@gmail.com> Co-authored-by: Dan Lebowitz <dan.lebo@me.com> Co-authored-by: Razvan Gradinar <grazvan@fb.com> Co-authored-by: Jared Palmer <jared@palmer.net> Co-authored-by: Dane Grant <danecando@gmail.com> Co-authored-by: Dustin Goodman <dustin.s.goodman@gmail.com> Co-authored-by: Rick Hanlon <rickhanlonii@gmail.com> Co-authored-by: Maggie Appleton <maggie.fm.appleton@gmail.com> Co-authored-by: Alex Moldovan <alex.n.moldovan@gmail.com> Co-authored-by: Ives van Hoorne <ives.v.h@gmail.com> Co-authored-by: Brian Vaughn <bvaughn@fb.com> Co-authored-by: Dmitri Pavlutin <dpavlutin@gmail.com>
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*/
|
|
|
|
import * as React from 'react';
|
|
import cn from 'classnames';
|
|
import NextLink from 'next/link';
|
|
|
|
interface ButtonLinkProps {
|
|
size?: 'md' | 'lg';
|
|
type?: 'primary' | 'secondary';
|
|
label?: string;
|
|
target?: '_self' | '_blank';
|
|
}
|
|
|
|
function ButtonLink({
|
|
href,
|
|
className,
|
|
children,
|
|
type = 'primary',
|
|
size = 'md',
|
|
label,
|
|
target = '_self',
|
|
...props
|
|
}: JSX.IntrinsicElements['a'] & ButtonLinkProps) {
|
|
const classes = cn(
|
|
className,
|
|
'inline-flex font-bold items-center border-2 border-transparent outline-none focus:ring-1 focus:ring-offset-2 focus:ring-link active:bg-link active:text-white active:ring-0 active:ring-offset-0 leading-normal',
|
|
{
|
|
'bg-link text-white hover:bg-opacity-80': type === 'primary',
|
|
'bg-secondary-button dark:bg-secondary-button-dark text-primary dark:text-primary-dark hover:text-link focus:bg-link focus:text-white focus:border-link focus:border-2':
|
|
type === 'secondary',
|
|
'text-lg rounded-lg p-4': size === 'lg',
|
|
'text-base rounded-lg px-4 py-1.5': size === 'md',
|
|
}
|
|
);
|
|
return (
|
|
<NextLink href={href as string}>
|
|
<a className={classes} {...props} aria-label={label} target={target}>
|
|
{children}
|
|
</a>
|
|
</NextLink>
|
|
);
|
|
}
|
|
|
|
export default ButtonLink;
|