Skip to content

Commit 315cbf5

Browse files
authored
Fix circular progress animation styles (#3302)
Signed-off-by: Emre Bogazliyanlioglu <emre@wormholelabs.xyz>
1 parent 25228a7 commit 315cbf5

File tree

1 file changed

+10
-23
lines changed
  • wormhole-connect/src/views/v2/Redeem

1 file changed

+10
-23
lines changed

wormhole-connect/src/views/v2/Redeem/index.tsx

+10-23
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,7 @@ import TxReadyForClaim from 'icons/TxReadyForClaim';
6666
import { useGetRedeemTokens } from 'hooks/useGetTokens';
6767
import { tokenIdFromTuple } from 'config/tokens';
6868

69-
type StyleProps = {
70-
transitionDuration?: string | undefined;
71-
};
72-
73-
const useStyles = makeStyles<StyleProps>()((theme, { transitionDuration }) => ({
69+
const useStyles = makeStyles()((theme: any) => ({
7470
spacer: {
7571
display: 'flex',
7672
flexDirection: 'column',
@@ -117,7 +113,7 @@ const useStyles = makeStyles<StyleProps>()((theme, { transitionDuration }) => ({
117113
},
118114
circularProgressCircleDeterminite: {
119115
strokeLinecap: 'round',
120-
transitionDuration,
116+
transitionDuration: '1s',
121117
transitionProperty: 'all',
122118
transitionTimingFunction: 'linear',
123119
},
@@ -139,6 +135,7 @@ const useStyles = makeStyles<StyleProps>()((theme, { transitionDuration }) => ({
139135
const Redeem = () => {
140136
const dispatch = useDispatch();
141137
const theme = useTheme();
138+
const { classes } = useStyles();
142139

143140
const [claimError, setClaimError] = useState('');
144141
const [isClaimInProgress, setIsClaimInProgress] = useState(false);
@@ -370,11 +367,9 @@ const Redeem = () => {
370367
}
371368

372369
return 0;
373-
}, [txTimestamp, eta]);
374-
375-
const { classes } = useStyles({
376-
transitionDuration: `${remainingEta}ms`,
377-
});
370+
// We need to update the remaining ETA every second, that's why we have seconds in the deps array
371+
// eslint-disable-next-line react-hooks/exhaustive-deps
372+
}, [txTimestamp, eta, etaExpired, seconds]);
378373

379374
const header = useMemo(() => {
380375
const defaults: { text: string; align: Alignment } = {
@@ -465,23 +460,14 @@ const Redeem = () => {
465460
// Value for determinate circular progress bar
466461
const etaProgressValue = useMemo(() => {
467462
if (eta) {
468-
if (isRunning || remainingEta === 0) {
469-
// We return the full bar value when the ETA timer is running
470-
// and simulate the progress by setting transitionDuration (see useStyles above)
471-
return 100;
472-
}
473-
474-
// This happens during Redeem view's initial loading before the ETA timer starts
475-
// We calculate progress bar's initial value from completed eta
476-
// This value should be between 0-100
477463
const completedEta = eta - remainingEta;
478464
const percentRatio = completedEta / eta;
479-
return Math.floor(percentRatio * 100);
465+
return percentRatio * 100; // Circular progress value range is 0-100
480466
}
481467

482468
// Set initial value to zero if we don't have an ETA
483469
return 0;
484-
}, [eta, remainingEta, isRunning]);
470+
}, [eta, remainingEta]);
485471

486472
// In-progress circular progress bar
487473
const etaCircularProgress = useMemo(() => {
@@ -778,12 +764,13 @@ const Redeem = () => {
778764
fromChain,
779765
isConnectedToReceivingWallet,
780766
isTxDestQueued,
767+
receivedToken,
781768
receivingWallet.address,
782-
token,
783769
routeContext.receipt,
784770
routeContext.route,
785771
routeName,
786772
toChain,
773+
token,
787774
]);
788775

789776
// Main CTA button which has separate states for automatic and manual claims

0 commit comments

Comments
 (0)