fix: wrapping link around button

This commit is contained in:
MTG2000
2022-05-05 12:38:20 +03:00
parent 75b0de4c90
commit b018754e29
2 changed files with 31 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
import { ComponentProps, ReactNode } from 'react';
import { wrapLink } from 'src/utils/hoc';
import { ReactNode } from 'react';
import { UnionToObjectKeys } from 'src/utils/types/utils';
import { Link } from 'react-router-dom'
// import Loading from '../Loading/Loading';
interface Props {
@@ -86,22 +86,37 @@ export default function Button({ color = 'white',
const handleClick = () => {
if (isLoading && disableOnLoading) return;
if (onClick) onClick();
}
if (href)
if (newTab)
return <a
href={href}
className={`${classes} ${className}`}
target="_blank" rel="noopener noreferrer"
{...props}
>
{children}
</a>
else
return <Link
to={href}
className={`${classes} ${className}`} >
{children}
</Link>
return (
wrapLink(
<button
type='button'
className={`${classes} ${className}`}
onClick={() => handleClick()}
{...props}
>
{/* {isLoading ? <Loading color={loadingColor[color]} /> : children} */}
{children}
</button>
, href, {
newTab
})
<button
type='button'
className={`${classes} ${className}`}
onClick={() => handleClick()}
{...props}
>
{/* {isLoading ? <Loading color={loadingColor[color]} /> : children} */}
{children}
</button>
)
}

View File

@@ -13,7 +13,7 @@
/* Track */
::-webkit-scrollbar-track {
background: inherit;
background: #e5e5e5;
}
/* Handle */