2025-09-27 12:14:16 +03:00
|
|
|
import { ComponentChildren } from "preact";
|
|
|
|
|
import Icon from "./Icon";
|
|
|
|
|
import "./Button.css";
|
|
|
|
|
|
2025-09-27 14:02:49 +03:00
|
|
|
interface LinkProps {
|
|
|
|
|
className?: string;
|
|
|
|
|
href?: string;
|
|
|
|
|
openExternally?: boolean;
|
|
|
|
|
children: ComponentChildren;
|
|
|
|
|
title?: string;
|
2025-09-27 17:22:34 +03:00
|
|
|
onClick?: (e: MouseEvent) => void;
|
2025-09-27 14:02:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ButtonProps extends Omit<LinkProps, "children"> {
|
2025-09-27 12:14:16 +03:00
|
|
|
href?: string;
|
|
|
|
|
iconSvg?: string;
|
|
|
|
|
text: ComponentChildren;
|
|
|
|
|
openExternally?: boolean;
|
2025-09-27 12:46:16 +03:00
|
|
|
outline?: boolean;
|
2025-09-27 12:14:16 +03:00
|
|
|
}
|
|
|
|
|
|
2025-09-27 14:02:49 +03:00
|
|
|
export default function Button({ iconSvg, text, className, outline, ...restProps }: ButtonProps) {
|
2025-09-27 12:14:16 +03:00
|
|
|
return (
|
2025-09-27 14:02:49 +03:00
|
|
|
<Link
|
2025-09-27 12:46:16 +03:00
|
|
|
className={`button ${className} ${outline ? "outline" : ""}`}
|
2025-09-27 14:02:49 +03:00
|
|
|
{...restProps}
|
2025-09-27 12:14:16 +03:00
|
|
|
>
|
|
|
|
|
{iconSvg && <><Icon svg={iconSvg} />{" "}</>}
|
|
|
|
|
{text}
|
2025-09-27 14:02:49 +03:00
|
|
|
</Link>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function Link({ openExternally, children, ...restProps }: LinkProps) {
|
|
|
|
|
return (
|
|
|
|
|
<a
|
|
|
|
|
{...restProps}
|
|
|
|
|
target={openExternally ? "_blank" : undefined}
|
|
|
|
|
rel={openExternally ? "noopener noreferrer" : undefined}
|
|
|
|
|
>
|
|
|
|
|
{children}
|
2025-09-27 12:14:16 +03:00
|
|
|
</a>
|
|
|
|
|
)
|
|
|
|
|
}
|