import { RefObject } from "preact"; import { useRef } from "preact/hooks"; interface ButtonProps { /** Reference to the button element. Mostly useful for requesting focus. */ buttonRef: RefObject; text: string; className?: string; keyboardShortcut?: string; /** Called when the button is clicked. If not set, the button will submit the form (if any). */ onClick?: () => void; } export default function Button({ buttonRef: _buttonRef, className, text, onClick, keyboardShortcut }: ButtonProps) { const classes: string[] = ["btn"]; classes.push("btn-primary"); if (className) { classes.push(className); } const buttonRef = _buttonRef ?? useRef(null); const splitShortcut = (keyboardShortcut ?? "").split("+"); return ( ); }