diff --git a/src-web/components/Button.tsx b/src-web/components/Button.tsx index 6f97d6a9..1aae05de 100644 --- a/src-web/components/Button.tsx +++ b/src-web/components/Button.tsx @@ -1,6 +1,6 @@ import classnames from 'classnames'; import type { ComponentChildren } from 'preact'; -import type { ForwardedRef } from 'preact/compat'; +import { Link } from 'preact-router'; import { forwardRef } from 'preact/compat'; import { Icon } from './Icon'; @@ -15,11 +15,15 @@ const colorStyles = { }; export type ButtonProps = { + href?: string; color?: keyof typeof colorStyles; size?: 'sm' | 'md'; justify?: 'start' | 'center'; type?: 'button' | 'submit'; onClick?: (event: MouseEvent) => void; + onDoubleClick?: (event: MouseEvent) => void; + contentEditable?: boolean; + onKeyDown?: (event: KeyboardEvent) => void; forDropdown?: boolean; className?: string; children?: ComponentChildren; @@ -28,21 +32,17 @@ export type ButtonProps = { tabIndex?: number; }; -export const Button = forwardRef(function Button( - { - className, - children, - forDropdown, - color, - justify = 'center', - size = 'md', - ...props - }: ButtonProps, - ref: ForwardedRef, +// eslint-disable-next-line @typescript-eslint/no-explicit-any +export const Button = forwardRef(function Button( + { href, className, children, forDropdown, color, justify = 'center', size = 'md', ...props }, + ref, ) { + // const Component = 'button'; + const Component = typeof href === 'string' ? Link : 'button'; return ( - + ); }); diff --git a/src-web/components/ButtonLink.tsx b/src-web/components/ButtonLink.tsx index 4d924a9e..2a112b5b 100644 --- a/src-web/components/ButtonLink.tsx +++ b/src-web/components/ButtonLink.tsx @@ -1,5 +1,4 @@ import classnames from 'classnames'; -import { Link } from 'preact-router'; import type { ButtonProps } from './Button'; import { Button } from './Button'; @@ -8,10 +7,12 @@ type Props = ButtonProps & { }; export function ButtonLink({ href, className, ...buttonProps }: Props) { - const linkProps = { href }; return ( - -