11import React from 'react' ;
22import styled from 'styled-components' ;
3- import { Link , LinkProps } from 'react-router-dom' ;
3+ import { Link } from 'react-router-dom' ;
44import { remSize , prop } from '../theme' ;
55
66enum Kinds {
@@ -18,13 +18,7 @@ enum ButtonTypes {
1818 submit = 'submit'
1919}
2020
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 > {
2822 /**
2923 * The visible part of the button, telling the user what
3024 * the action is
@@ -66,6 +60,10 @@ interface SharedButtonProps {
6660 * Specifying a to URL will use a react-router Link
6761 */
6862 to ?: string ;
63+ /**
64+ * If using a native button, specifies on an onClick action
65+ */
66+ onClick ?: ( ) => void ;
6967 /**
7068 * If using a button, then type is defines the type of button
7169 */
@@ -77,10 +75,10 @@ interface SharedButtonProps {
7775 focusable ?: boolean | 'true' | 'false' ;
7876}
7977
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+ }
8482
8583// The '&&&' will increase the specificity of the
8684// component's CSS so that it overrides the more
@@ -203,6 +201,7 @@ export const Button = ({
203201 ? StyledInlineButton
204202 : StyledButton ;
205203
204+ // Anchor Link
206205 if ( href ) {
207206 return (
208207 < StyledComponent
@@ -218,6 +217,7 @@ export const Button = ({
218217 ) ;
219218 }
220219
220+ // Internal React Router Link
221221 if ( to ) {
222222 return (
223223 < StyledComponent
@@ -233,6 +233,7 @@ export const Button = ({
233233 ) ;
234234 }
235235
236+ // Native Button
236237 return (
237238 < StyledComponent
238239 kind = { kind }
0 commit comments