@@ -15,7 +15,7 @@ import ShortcutTitle from './ShortcutTitle';
1515import { styled } from '@mui/material/styles' ;
1616
1717
18- const StyledButton = styled ( Button ) ( ( { theme} ) => ( {
18+ const StyledButton = styled ( Button ) ( ( { theme, color } ) => ( {
1919 '&.Buttons-primaryButton' : {
2020 border : '1px solid ' + theme . palette . primary . main ,
2121 '&.Mui-disabled' : {
@@ -37,18 +37,19 @@ const StyledButton = styled(Button)(({theme}) => ({
3737 }
3838 } ,
3939 '&.Buttons-defaultButton' : {
40- backgroundColor : theme . palette . default . main ,
41- color : theme . palette . default . contrastText ,
42- border : '1px solid ' + theme . palette . default . borderColor ,
40+ // Use the color prop to determine the background color and text color.
41+ backgroundColor : theme . palette [ color ] ?. main || theme . palette . default . main ,
42+ border : '1px solid ' + theme . palette . default . borderColor ,
43+ color : theme . palette [ color ] ?. contrastText || theme . palette . default . contrastText ,
4344 whiteSpace : 'nowrap' ,
4445 '&.Mui-disabled' : {
4546 color : [ theme . palette . default . disabledContrastText , '!important' ] ,
4647 borderColor : theme . palette . default . disabledBorderColor
4748 } ,
4849 '&:hover' : {
49- backgroundColor : theme . palette . default . hoverMain ,
50- color : theme . palette . default . hoverContrastText ,
51- borderColor : theme . palette . default . hoverBorderColor ,
50+ backgroundColor : theme . palette [ color ] ?. hoverMain || theme . palette . default . hoverMain ,
51+ color : theme . palette [ color ] ?. contrastText || theme . palette . default . hoverContrastText ,
52+ borderColor : theme . palette [ color ] ?. hoverBorderColor || theme . palette . default . hoverBorderColor ,
5253 } ,
5354 '&.Buttons-noBorder' : {
5455 border : 0 ,
@@ -143,16 +144,19 @@ PrimaryButton.propTypes = {
143144
144145/* pgAdmin default button */
145146export const DefaultButton = forwardRef ( ( props , ref ) => {
146- let { children, className, size, noBorder, ...otherProps } = props ;
147+ let { children, className, size, noBorder, color, ...otherProps } = props ;
148+ let variant = 'outlined' ;
147149 let allClassName = [ 'Buttons-defaultButton' , className ] ;
148150 if ( size == 'xs' ) {
149151 size = undefined ;
150152 allClassName . push ( 'Buttons-xsButton' ) ;
153+ } else if ( color ) {
154+ variant = 'contained' ;
151155 }
152156 noBorder && allClassName . push ( 'Buttons-noBorder' ) ;
153157 const dataLabel = typeof ( children ) == 'string' ? children : undefined ;
154158 return (
155- < StyledButton variant = "outlined" ref = { ref } size = { size } className = { allClassName . join ( ' ' ) } data-label = { dataLabel } color = "default" { ...otherProps } > { children } </ StyledButton >
159+ < StyledButton variant = { variant } ref = { ref } size = { size } className = { allClassName . join ( ' ' ) } data-label = { dataLabel } { ...otherProps } color = { color } > { children } </ StyledButton >
156160 ) ;
157161} ) ;
158162DefaultButton . displayName = 'DefaultButton' ;
@@ -161,6 +165,7 @@ DefaultButton.propTypes = {
161165 noBorder : PropTypes . bool ,
162166 children : CustomPropTypes . children ,
163167 className : PropTypes . oneOfType ( [ PropTypes . string , PropTypes . object ] ) ,
168+ color : PropTypes . string ,
164169} ;
165170
166171
0 commit comments