Allow rendering Button component as <a> or <button>
[MAILPOET-2784]
This commit is contained in:
@@ -12,6 +12,7 @@ type Props = {
|
|||||||
iconEnd?: JSX.Element,
|
iconEnd?: JSX.Element,
|
||||||
onClick?: () => void,
|
onClick?: () => void,
|
||||||
href?: string,
|
href?: string,
|
||||||
|
type?: string,
|
||||||
target?: '_blank' | '_self' | '_parent' | '_top' | string,
|
target?: '_blank' | '_self' | '_parent' | '_top' | string,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -27,8 +28,10 @@ const Button = ({
|
|||||||
onClick,
|
onClick,
|
||||||
href,
|
href,
|
||||||
target,
|
target,
|
||||||
}: Props) => (
|
}: Props) => {
|
||||||
<a
|
const Element = href ? 'a' : 'button';
|
||||||
|
return (
|
||||||
|
<Element
|
||||||
href={href}
|
href={href}
|
||||||
onClick={onClick}
|
onClick={onClick}
|
||||||
target={target}
|
target={target}
|
||||||
@@ -48,7 +51,8 @@ const Button = ({
|
|||||||
{iconStart}
|
{iconStart}
|
||||||
{children && <span>{children}</span>}
|
{children && <span>{children}</span>}
|
||||||
{iconEnd}
|
{iconEnd}
|
||||||
</a>
|
</Element>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export default Button;
|
export default Button;
|
||||||
|
Reference in New Issue
Block a user