b0ab6cc729
React/Vite landing with RU/EN i18n, live USD pricing, download links to updates.mailib.ru, and donate.stream checkout. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
829 B
TypeScript
44 lines
829 B
TypeScript
import type { ReactNode } from "react";
|
|
|
|
import styles from "./Button.module.css";
|
|
|
|
type ButtonVariant = "primary" | "secondary" | "ghost" | "gold";
|
|
|
|
type ButtonProps = {
|
|
children: ReactNode;
|
|
href?: string;
|
|
variant?: ButtonVariant;
|
|
className?: string;
|
|
onClick?: () => void;
|
|
type?: "button" | "submit";
|
|
};
|
|
|
|
function join(...parts: (string | undefined)[]): string {
|
|
return parts.filter(Boolean).join(" ");
|
|
}
|
|
|
|
export function Button({
|
|
children,
|
|
href,
|
|
variant = "primary",
|
|
className,
|
|
onClick,
|
|
type = "button",
|
|
}: ButtonProps) {
|
|
const cls = join(styles.button, styles[variant], className);
|
|
|
|
if (href) {
|
|
return (
|
|
<a className={cls} href={href}>
|
|
{children}
|
|
</a>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<button className={cls} type={type} onClick={onClick}>
|
|
{children}
|
|
</button>
|
|
);
|
|
}
|