Skip to content

Commit 8ab676b

Browse files
authored
Merge pull request #30 from getinapp/chore/button
[BUGFIX] - Button typing
2 parents e516b1f + 32e8d37 commit 8ab676b

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/components/Button/index.tsx

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import React, { AnchorHTMLAttributes, ButtonHTMLAttributes } from 'react';
1+
import React, { ButtonHTMLAttributes, DetailedHTMLProps } from 'react';
22
import Loading from '../Loading';
33
import * as S from './styles';
44

5-
type ButtonDefaultHTMLTypes =
6-
| Pick<ButtonHTMLAttributes<HTMLButtonElement>, 'className'>
7-
| Pick<AnchorHTMLAttributes<HTMLAnchorElement>, 'target' | 'href'>;
8-
95
type ButtonSizesType = 'small' | 'regular' | 'large';
106

117
type ButtonVariantsType =
@@ -32,14 +28,6 @@ export type ButtonProps = {
3228
* In the case of the button, have the maximum size of the container
3329
*/
3430
isFullWidth?: boolean;
35-
/**
36-
* Optional click handler
37-
*/
38-
onClick?: (event?: React.MouseEvent<HTMLButtonElement>) => void;
39-
/**
40-
* Disabled state of button
41-
*/
42-
disabled?: boolean;
4331
/**
4432
* Set the loading status of button
4533
*/
@@ -48,7 +36,10 @@ export type ButtonProps = {
4836
* Change component to another element type
4937
*/
5038
as?: React.ElementType;
51-
} & ButtonDefaultHTMLTypes;
39+
} & DetailedHTMLProps<
40+
ButtonHTMLAttributes<HTMLButtonElement>,
41+
HTMLButtonElement
42+
>;
5243

5344
/**
5445
* API documentation for the React Button component. Learn about the available props, and the CSS API.
@@ -60,7 +51,6 @@ export const Button = ({
6051
size = 'regular',
6152
disabled = false,
6253
loading = false,
63-
onClick,
6454
...props
6555
}: ButtonProps) => {
6656
return (
@@ -69,7 +59,6 @@ export const Button = ({
6959
size={size}
7060
isFullWidth={isFullWidth}
7161
disabled={disabled || loading}
72-
onClick={onClick}
7362
{...props}
7463
>
7564
{loading && <Loading />}

0 commit comments

Comments
 (0)