mirror of
https://github.com/aljazceru/landscape-template.git
synced 2025-12-27 11:14:33 +01:00
fix: wrapping link around button
This commit is contained in:
@@ -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>
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
/* Track */
|
||||
::-webkit-scrollbar-track {
|
||||
background: inherit;
|
||||
background: #e5e5e5;
|
||||
}
|
||||
|
||||
/* Handle */
|
||||
|
||||
Reference in New Issue
Block a user