@ -1,5 +1,6 @@
import React , { useContext } from 'react'
import React , { useContext } from 'react'
import { gitPluginContext } from '../gitui'
import { gitPluginContext } from '../gitui'
import { CustomTooltip } from '@remix-ui/helper' ;
interface ButtonWithContextProps {
interface ButtonWithContextProps {
onClick : React.MouseEventHandler < HTMLButtonElement > ;
onClick : React.MouseEventHandler < HTMLButtonElement > ;
@ -7,18 +8,31 @@ interface ButtonWithContextProps {
disabledCondition? : boolean ; // Optional additional disabling condition
disabledCondition? : boolean ; // Optional additional disabling condition
// You can add other props if needed, like 'type', 'className', etc.
// You can add other props if needed, like 'type', 'className', etc.
[ key : string ] : any ; // Allow additional props to be passed
[ key : string ] : any ; // Allow additional props to be passed
tooltip? : string ;
}
}
// This component extends a button, disabling it when loading is true
// This component extends a button, disabling it when loading is true
const GitUIButton = ( { children , disabledCondition = false , . . . rest } : ButtonWithContextProps ) = > {
const GitUIButton = ( { children , disabledCondition = false , . . . rest } : ButtonWithContextProps ) = > {
const { loading } = React . useContext ( gitPluginContext )
const { loading } = React . useContext ( gitPluginContext )
const isDisabled = loading || disabledCondition
const isDisabled = loading || disabledCondition
return (
< button disabled = { isDisabled } { ...rest } >
if ( rest . tooltip ) {
{ children }
< / button >
return (
) ;
< CustomTooltip tooltipText = { rest . tooltip } placement = "top" >
< button disabled = { isDisabled } { ...rest } >
{ children }
< / button >
< / CustomTooltip >
) ;
} else {
return (
< button disabled = { isDisabled } { ...rest } >
{ children }
< / button >
) ;
}
} ;
} ;
export default GitUIButton ;
export default GitUIButton ;