Skip to content

Commit

Permalink
Fix ButtonTrust disabled behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
louilinn committed Feb 22, 2023
1 parent 93c15c0 commit b7b1ab9
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions src/components/ButtonTrust.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ import {
} from '~/styles/icons';

const useStyles = makeStyles((theme) => ({
default: {
trustButton: {
background: 'transparent',
color: theme.palette.common.whiteAlmost,
padding: '0',
},
trustButtonNoTrust: {
'& stop:first-of-type': {
stopColor: theme.custom.colors.purpleDark,
},
Expand All @@ -31,7 +33,7 @@ const useStyles = makeStyles((theme) => ({
},
},
},
oneWayTrust: {
trustButtonOneWay: {
'& stop:first-of-type': {
stopColor: theme.custom.colors.violet,
},
Expand All @@ -47,7 +49,7 @@ const useStyles = makeStyles((theme) => ({
},
},
},
mutualTrust: {
trustButtonMutualTrust: {
'& stop:first-of-type': {
stopColor: theme.custom.colors.fountainBlue,
},
Expand All @@ -64,7 +66,12 @@ const useStyles = makeStyles((theme) => ({
},
},
trustButtonDisabled: {
background: theme.custom.gradients.gray,
'& stop:first-of-type': {
stopColor: theme.custom.colors.grayDark,
},
'& stop:last-of-type': {
stopColor: theme.custom.colors.gray,
},
},
trustButtonContainer: {
width: '55px',
Expand Down Expand Up @@ -103,27 +110,29 @@ const ButtonTrust = ({
return (
<IconButton
classes={{
root: clsx(classes.default, {
[classes.oneWayTrust]:
root: clsx(classes.trustButton, {
[classes.trustButtonDisabled]: trustStatus.isPending || !isReady,
[classes.trustButtonNoTrust]:
!trustStatus.isMeTrusting && !trustStatus.isTrustingMe,
[classes.trustButtonOneWay]:
trustStatus.isMeTrusting || trustStatus.isTrustingMe,
[classes.mutualTrust]:
[classes.trustButtonMutualTrust]:
trustStatus.isMeTrusting && trustStatus.isTrustingMe,
}),
disabled: classes.trustButtonDisabled,
}}
disabled={trustStatus.isPending || !isReady}
onClick={
trustStatus.isMeTrusting ? handleRevokeTrustOpen : handleTrustOpen
}
>
{trustStatus.isPending ? (
<CircularProgress size={24} />
) : (
<Box className={classes.trustButtonContainer}>
<IconWobblyCircle className={classes.trustButtonIconBackground} />
<Box className={classes.trustButtonContainer}>
<IconWobblyCircle className={classes.trustButtonIconBackground} />
{trustStatus.isPending ? (
<CircularProgress size={24} />
) : (
<TrustIcon className={classes.trustButtonIcon} />
</Box>
)}
)}
</Box>
</IconButton>
);
};
Expand Down

0 comments on commit b7b1ab9

Please sign in to comment.