From 805859af4dcd0115e3a37a0f1d780cbae6ccd836 Mon Sep 17 00:00:00 2001 From: Dan J Miller Date: Mon, 16 Aug 2021 20:18:24 -0230 Subject: [PATCH] Improve flashing behaviour for loading gas estimates (on confirm screen) (#11852) * Improve flashing behaviour for loading gas estimates * Fix typo * renderHeartBeatIfInTest --- .../confirm-page-container-content/index.scss | 4 ++ .../transaction-detail.component.js | 2 - ui/components/ui/loading-heartbeat/index.scss | 8 ++-- ui/hooks/useShouldAnimateGasEstimations.js | 7 +++ .../confirm-transaction-base.component.js | 48 ++++++++++++------- 5 files changed, 46 insertions(+), 23 deletions(-) diff --git a/ui/components/app/confirm-page-container/confirm-page-container-content/index.scss b/ui/components/app/confirm-page-container/confirm-page-container-content/index.scss index c45f5d11f..c7655165b 100644 --- a/ui/components/app/confirm-page-container/confirm-page-container-content/index.scss +++ b/ui/components/app/confirm-page-container/confirm-page-container-content/index.scss @@ -88,4 +88,8 @@ .page-container__footer { margin-top: auto; } + + &__currency-container { + position: relative; + } } diff --git a/ui/components/app/transaction-detail/transaction-detail.component.js b/ui/components/app/transaction-detail/transaction-detail.component.js index 43b17074f..0829df684 100644 --- a/ui/components/app/transaction-detail/transaction-detail.component.js +++ b/ui/components/app/transaction-detail/transaction-detail.component.js @@ -4,14 +4,12 @@ import PropTypes from 'prop-types'; import { I18nContext } from '../../../contexts/i18n'; import TransactionDetailItem from '../transaction-detail-item/transaction-detail-item.component'; -import LoadingHeartBeat from '../../ui/loading-heartbeat'; export default function TransactionDetail({ rows = [], onEdit }) { const t = useContext(I18nContext); return (
- {process.env.IN_TEST === 'true' ? null : } {onEdit && (
diff --git a/ui/components/ui/loading-heartbeat/index.scss b/ui/components/ui/loading-heartbeat/index.scss index 0e3c4d19d..c6f213453 100644 --- a/ui/components/ui/loading-heartbeat/index.scss +++ b/ui/components/ui/loading-heartbeat/index.scss @@ -19,9 +19,7 @@ } @keyframes heartbeat { - 0% { opacity: 0; } - 25% { opacity: 1; } - 50% { opacity: 0.5; } - 75% { opacity: 1; } - 100% { opacity: 0; } + 0% { opacity: 0.2; } + 50% { opacity: 1; } + 100% { opacity: 0.2; } } diff --git a/ui/hooks/useShouldAnimateGasEstimations.js b/ui/hooks/useShouldAnimateGasEstimations.js index 6820b6764..882950a68 100644 --- a/ui/hooks/useShouldAnimateGasEstimations.js +++ b/ui/hooks/useShouldAnimateGasEstimations.js @@ -40,7 +40,14 @@ export function useShouldAnimateGasEstimations() { showLoadingAnimation === true ) { dispatch(toggleGasLoadingAnimation(true)); + } + }, [dispatch, isGasLoadingAnimationActive, showLoadingAnimation]); + useEffect(() => { + if ( + isGasLoadingAnimationActive === true && + showLoadingAnimation === false + ) { setTimeout(() => { dispatch(toggleGasLoadingAnimation(false)); }, 2000); diff --git a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js index 654820338..84080d842 100644 --- a/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js +++ b/ui/pages/confirm-transaction-base/confirm-transaction-base.component.js @@ -33,6 +33,7 @@ import { toBuffer } from '../../../shared/modules/buffer-utils'; import TransactionDetail from '../../components/app/transaction-detail/transaction-detail.component'; import TransactionDetailItem from '../../components/app/transaction-detail-item/transaction-detail-item.component'; import InfoTooltip from '../../components/ui/info-tooltip/info-tooltip'; +import LoadingHeartBeat from '../../components/ui/loading-heartbeat'; import GasTiming from '../../components/app/gas-timing/gas-timing.component'; import { COLORS } from '../../helpers/constants/design-system'; @@ -43,6 +44,9 @@ import { removePollingTokenFromAppState, } from '../../store/actions'; +const renderHeartBeatIfNotInTest = () => + process.env.IN_TEST === 'true' ? null : ; + export default class ConfirmTransactionBase extends Component { static contextTypes = { t: PropTypes.func, @@ -439,29 +443,41 @@ export default class ConfirmTransactionBase extends Component { txData.dappSuggestedGasFees ? COLORS.SECONDARY1 : COLORS.BLACK } detailText={ - +
+ {renderHeartBeatIfNotInTest()} + +
} detailTotal={ - +
+ {renderHeartBeatIfNotInTest()} + +
} subText={t('editGasSubTextFee', [ {t('editGasSubTextFeeLabel')} , - , +
+ {renderHeartBeatIfNotInTest()} + +
, ])} subTitle={