Adds message forwarding

This commit is contained in:
Josh Perez 2021-04-27 15:35:35 -07:00 committed by GitHub
parent cd489a35fd
commit d203f125c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 1638 additions and 139 deletions

View file

@ -15,7 +15,6 @@ export enum ButtonVariant {
}
type PropsType = {
children: ReactNode;
className?: string;
disabled?: boolean;
variant?: ButtonVariant;
@ -26,7 +25,21 @@ type PropsType = {
| {
type: 'submit';
}
);
) &
(
| {
'aria-label': string;
children: ReactNode;
}
| {
'aria-label'?: string;
children: ReactNode;
}
| {
'aria-label': string;
children?: ReactNode;
}
);
const VARIANT_CLASS_NAMES = new Map<ButtonVariant, string>([
[ButtonVariant.Primary, 'module-Button--primary'],
@ -50,6 +63,7 @@ export const Button = React.forwardRef<HTMLButtonElement, PropsType>(
disabled = false,
variant = ButtonVariant.Primary,
} = props;
const ariaLabel = props['aria-label'];
let onClick: undefined | MouseEventHandler<HTMLButtonElement>;
let type: 'button' | 'submit';
@ -66,6 +80,7 @@ export const Button = React.forwardRef<HTMLButtonElement, PropsType>(
return (
<button
aria-label={ariaLabel}
className={classNames('module-Button', variantClassName, className)}
disabled={disabled}
onClick={onClick}