1
1
import React from 'react' ;
2
2
import styled from 'styled-components' ;
3
- import { Link , LinkProps } from 'react-router-dom' ;
3
+ import { Link } from 'react-router-dom' ;
4
4
import { remSize , prop } from '../theme' ;
5
5
6
6
enum Kinds {
@@ -18,13 +18,7 @@ enum ButtonTypes {
18
18
submit = 'submit'
19
19
}
20
20
21
- type StyledButtonProps = {
22
- kind : ButtonTypes ;
23
- display : Displays ;
24
- type ?: ButtonTypes ;
25
- } & React . ButtonHTMLAttributes < HTMLButtonElement > ;
26
-
27
- interface SharedButtonProps {
21
+ export interface ButtonProps extends React . HTMLAttributes < HTMLElement > {
28
22
/**
29
23
* The visible part of the button, telling the user what
30
24
* the action is
@@ -66,6 +60,10 @@ interface SharedButtonProps {
66
60
* Specifying a to URL will use a react-router Link
67
61
*/
68
62
to ?: string ;
63
+ /**
64
+ * If using a native button, specifies on an onClick action
65
+ */
66
+ onClick ?: ( ) => void ;
69
67
/**
70
68
* If using a button, then type is defines the type of button
71
69
*/
@@ -77,10 +75,10 @@ interface SharedButtonProps {
77
75
focusable ?: boolean | 'true' | 'false' ;
78
76
}
79
77
80
- export type ButtonProps = SharedButtonProps &
81
- React . ButtonHTMLAttributes < HTMLButtonElement > &
82
- React . AnchorHTMLAttributes < HTMLAnchorElement > &
83
- Partial < LinkProps > ;
78
+ interface StyledButtonProps extends ButtonProps {
79
+ kind : Kinds ;
80
+ display : Displays ;
81
+ }
84
82
85
83
// The '&&&' will increase the specificity of the
86
84
// component's CSS so that it overrides the more
@@ -203,6 +201,7 @@ export const Button = ({
203
201
? StyledInlineButton
204
202
: StyledButton ;
205
203
204
+ // Anchor Link
206
205
if ( href ) {
207
206
return (
208
207
< StyledComponent
@@ -218,6 +217,7 @@ export const Button = ({
218
217
) ;
219
218
}
220
219
220
+ // Internal React Router Link
221
221
if ( to ) {
222
222
return (
223
223
< StyledComponent
@@ -233,6 +233,7 @@ export const Button = ({
233
233
) ;
234
234
}
235
235
236
+ // Native Button
236
237
return (
237
238
< StyledComponent
238
239
kind = { kind }
0 commit comments