@@ -30,6 +30,8 @@ const GluuButton: React.FC<GluuButtonProps> = (props) => {
3030 minHeight,
3131 style,
3232 className,
33+ useOpacityOnHover = false ,
34+ hoverOpacity,
3335 onClick,
3436 type = 'button' ,
3537 title,
@@ -48,6 +50,8 @@ const GluuButton: React.FC<GluuButtonProps> = (props) => {
4850 const text = textColor ?? themeColors . fontColor
4951 const border = borderColor ?? ( isDark ? 'transparent' : themeColors . borderColor )
5052 const hoverBg = isDark ? themeColors . lightBackground : themeColors . borderColor
53+ const keepBgOnHover = useOpacityOnHover && isHovered && ! isDisabled
54+ const opacityOnHover = hoverOpacity ?? 0.5
5155
5256 return {
5357 display : 'inline-flex' ,
@@ -62,18 +66,20 @@ const GluuButton: React.FC<GluuButtonProps> = (props) => {
6266 minHeight : minHeight ?? sizeConfig . minHeight ,
6367 borderRadius : borderRadius ?? '6px' ,
6468 border : `1px solid ${ border } ` ,
65- backgroundColor : outlined
66- ? isHovered && ! isDisabled
67- ? `${ bg } 15`
68- : 'transparent'
69- : isHovered && ! isDisabled
70- ? hoverBg
71- : bg ,
69+ backgroundColor : keepBgOnHover
70+ ? bg
71+ : outlined
72+ ? isHovered && ! isDisabled
73+ ? `${ bg } 15`
74+ : 'transparent'
75+ : isHovered && ! isDisabled
76+ ? hoverBg
77+ : bg ,
7278 color : outlined ? themeColors . fontColor : text ,
7379 cursor : isDisabled ? 'not-allowed' : 'pointer' ,
74- opacity : isDisabled ? 0.65 : 1 ,
80+ opacity : isDisabled ? 0.65 : keepBgOnHover ? opacityOnHover : 1 ,
7581 width : block ? '100%' : 'auto' ,
76- transition : 'background-color 0.15s ease-in-out' ,
82+ transition : 'background-color 0.15s ease-in-out, opacity 0.15s ease-in-out ' ,
7783 ...style ,
7884 }
7985 } , [
@@ -92,6 +98,8 @@ const GluuButton: React.FC<GluuButtonProps> = (props) => {
9298 fontWeight ,
9399 padding ,
94100 minHeight ,
101+ useOpacityOnHover ,
102+ hoverOpacity ,
95103 style ,
96104 ] )
97105
0 commit comments