-
-
Notifications
You must be signed in to change notification settings - Fork 175
/
Copy pathButtonLink.tsx
56 lines (49 loc) · 1.36 KB
/
ButtonLink.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import classNames from 'classnames'
import Link from 'next/link'
import { AnchorHTMLAttributes, DetailedHTMLProps } from 'react'
type ButtonLinkProps = DetailedHTMLProps<
AnchorHTMLAttributes<HTMLAnchorElement>,
HTMLAnchorElement
>
const ButtonLink: React.FC<ButtonLinkProps> = ({
children,
className,
href,
target,
}) => {
const isExternal = href?.indexOf('//') !== -1
const inner = (
<a
href={isExternal ? href : undefined}
className={classNames(
'inline-block py-2 px-4 md:px-8 md:py-4 font-bold text-indigo-800 border-2 border-indigo-800 rounded-full hover:bg-indigo-800 dark:hover:bg-indigo-400 hover:text-white dark:text-indigo-400 dark:border-indigo-400',
className
)}
target={target}
rel={target === '_blank' ? 'noopener noreferrer' : ''}
>
{children}
</a>
)
if (isExternal || !href) {
return inner
}
return (
<Link href={href} passHref>
{inner}
</Link>
)
}
export const ButtonLinkPatreon: React.FC = ({ children }) => {
return (
<ButtonLink
href="https://www.patreon.com/oppnaskolplattformen"
className="!text-white bg-red-500 !border-transparent rounded-full hover:!bg-transparent hover:!border-red-500 hover:!text-red-500"
target="_blank"
rel="noopener noreferrer"
>
{children}
</ButtonLink>
)
}
export default ButtonLink