1+ /* eslint-disable @typescript-eslint/no-explicit-any */
2+ // NEED to allow any in order to support intrinisic element types
13import { FC , SVGProps } from 'react'
24import { Link } from 'react-router-dom'
35import classNames from 'classnames'
@@ -32,9 +34,15 @@ export interface ButtonProps {
3234
3335const Button : FC < ButtonProps > = ( props : ButtonProps ) => {
3436
35- const classes : string = getButtonClasses ( props )
36- const clickHandler : ( event ?: any ) => void = getClickHandler ( props )
37- const content : JSX . Element = getButtonContent ( props )
37+ const classes : string = getButtonClasses (
38+ props . className ,
39+ props . buttonStyle ,
40+ props . size ,
41+ props . disable ,
42+ props . hidden ,
43+ )
44+ const clickHandler : ( event ?: any ) => void = getClickHandler ( props . onClick )
45+ const content : JSX . Element = getButtonContent ( props . buttonStyle , props . icon , props . label )
3846
3947 // if there is a url, this is a link button
4048 if ( ! ! props . url ) {
@@ -79,6 +87,7 @@ const Button: FC<ButtonProps> = (props: ButtonProps) => {
7987 onClick = { clickHandler }
8088 tabIndex = { props . tabIndex }
8189 title = { props . title }
90+ // eslint-disable-next-line react/button-has-type
8291 type = { props . type || 'button' }
8392 id = { props . id }
8493 value = { props . id }
@@ -105,9 +114,9 @@ const Button: FC<ButtonProps> = (props: ButtonProps) => {
105114}
106115
107116function getButtonClasses (
108- className : string ,
109- buttonStyle : ButtonStyle ,
110- size : ButtonSize ,
117+ className ? : string ,
118+ buttonStyle ? : ButtonStyle ,
119+ size ? : ButtonSize ,
111120 disable ?: boolean ,
112121 hidden ?: boolean ,
113122) : string {
@@ -122,29 +131,34 @@ function getButtonClasses(
122131 return classes
123132}
124133
125- function getButtonContent ( props : ButtonProps ) : JSX . Element {
134+ function getButtonContent (
135+ buttonStyle ?: ButtonStyle ,
136+ icon ?: FC < SVGProps < SVGSVGElement > > ,
137+ label ?: string ,
138+ ) : JSX . Element {
126139
127140 // if this is a link, just add the label and the arrow icon
128- if ( props . buttonStyle === 'link' ) {
141+ if ( buttonStyle === 'link' ) {
129142 return (
130143 < >
131- { props . label }
144+ { label }
132145 < IconOutline . ArrowRightIcon />
133146 </ >
134147 )
135148 }
136149
137- const Icon : FC < SVGProps < SVGSVGElement > > | undefined = props . icon
150+ const Icon : FC < SVGProps < SVGSVGElement > > | undefined = icon
138151 return (
139152 < >
140153 { ! ! Icon && < Icon /> }
141- { props . label }
154+ { label }
142155 </ >
143156 )
144157}
145158
146- function getClickHandler ( props : ButtonProps ) : ( event ?: any ) => void {
147- return props . onClick || ( ( ) => undefined )
159+ function getClickHandler ( onClick ?: ( event ?: any ) => void ) : ( ( event ?: any ) => void ) {
160+
161+ return onClick || ( ( ) => undefined )
148162}
149163
150164export default Button
0 commit comments