Files
Trilium/apps/website/src/components/Button.tsx

45 lines
1.1 KiB
TypeScript
Raw Normal View History

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