Mbonea's picture
Add F0-F1 frontend and serve static build
5e0e982
Raw
History Blame Contribute Delete
1.01 kB
/** Primary action button with press-scale feedback. */
import type { ComponentChildren, JSX } from "preact";
import { Pressable } from "./Pressable";
type Variant = "primary" | "secondary" | "destructive" | "plain";
type ButtonProps = {
children: ComponentChildren;
variant?: Variant;
disabled?: boolean;
type?: "button" | "submit";
onClick?: JSX.MouseEventHandler<HTMLElement>;
className?: string;
ariaLabel?: string;
};
const variantClass: Record<Variant, string> = {
primary: "btn btn-primary",
secondary: "btn btn-secondary",
destructive: "btn btn-destructive",
plain: "btn btn-plain",
};
export function Button({
children,
variant = "primary",
disabled = false,
type = "button",
onClick,
className = "",
ariaLabel,
}: ButtonProps) {
return (
<Pressable
type={type}
disabled={disabled}
onClick={onClick}
ariaLabel={ariaLabel}
className={`${variantClass[variant]} ${className}`.trim()}
>
{children}
</Pressable>
);
}