11import React , { useState } from 'react' ;
22import clsx from 'clsx' ;
33import type { ButtonProps } from './types' ;
4+ import MDBRipple from '../../methods/Ripple/Ripple' ;
45
56const MDBBtn : React . FC < ButtonProps > = React . forwardRef < HTMLAllCollection , ButtonProps > (
67 (
@@ -17,6 +18,7 @@ const MDBBtn: React.FC<ButtonProps> = React.forwardRef<HTMLAllCollection, Button
1718 block,
1819 active,
1920 toggle,
21+ noRipple,
2022 tag : Tag ,
2123 ...props
2224 } ,
@@ -25,6 +27,7 @@ const MDBBtn: React.FC<ButtonProps> = React.forwardRef<HTMLAllCollection, Button
2527 const [ isActive , setActive ] = useState ( active ? active : false ) ;
2628
2729 let btnColor ;
30+ const waveColor = ( color && [ 'light' , 'link' ] . includes ( color as string ) ) || outline ? 'dark' : 'light' ;
2831
2932 if ( color !== 'none' ) {
3033 if ( outline ) {
@@ -58,7 +61,7 @@ const MDBBtn: React.FC<ButtonProps> = React.forwardRef<HTMLAllCollection, Button
5861 Tag = 'a' ;
5962 }
6063
61- return (
64+ return [ 'hr' , 'img' , 'input' ] . includes ( Tag ) || noRipple ? (
6265 < Tag
6366 className = { classes }
6467 onClick = {
@@ -75,10 +78,29 @@ const MDBBtn: React.FC<ButtonProps> = React.forwardRef<HTMLAllCollection, Button
7578 >
7679 { children }
7780 </ Tag >
81+ ) : (
82+ < MDBRipple
83+ rippleTag = { Tag }
84+ rippleColor = { waveColor }
85+ className = { classes }
86+ onClick = {
87+ toggle
88+ ? ( ) => {
89+ setActive ( ! isActive ) ;
90+ }
91+ : undefined
92+ }
93+ disabled = { disabled && Tag === 'button' ? true : undefined }
94+ href = { href }
95+ ref = { ref }
96+ { ...props }
97+ >
98+ { children }
99+ </ MDBRipple >
78100 ) ;
79101 }
80102) ;
81103
82- MDBBtn . defaultProps = { tag : 'button' , type : 'button' , role : 'button' } ;
104+ MDBBtn . defaultProps = { tag : 'button' , type : 'button' , role : 'button' , color : 'primary' } ;
83105
84106export default MDBBtn ;
0 commit comments