From 6fa3cce7abe6d20609d923f425fb1e7585d3b559 Mon Sep 17 00:00:00 2001 From: David Walsh Date: Fri, 2 Jul 2021 14:12:13 -0500 Subject: [PATCH] Create Gas Timing component for EIP-1559 (#11405) --- ui/components/app/app-components.scss | 1 + .../app/gas-timing/gas-timing.component.js | 32 ++++++++++++ .../app/gas-timing/gas-timing.stories.js | 49 +++++++++++++++++++ ui/components/app/gas-timing/index.js | 1 + ui/components/app/gas-timing/index.scss | 20 ++++++++ .../transaction-detail-item.component.js | 6 ++- .../transaction-detail-item.stories.js | 3 +- .../transaction-detail.stories.js | 3 +- .../transaction-total-banner.component.js | 12 ++--- 9 files changed, 115 insertions(+), 12 deletions(-) create mode 100644 ui/components/app/gas-timing/gas-timing.component.js create mode 100644 ui/components/app/gas-timing/gas-timing.stories.js create mode 100644 ui/components/app/gas-timing/index.js create mode 100644 ui/components/app/gas-timing/index.scss diff --git a/ui/components/app/app-components.scss b/ui/components/app/app-components.scss index ab36b4b96..b579de073 100644 --- a/ui/components/app/app-components.scss +++ b/ui/components/app/app-components.scss @@ -16,6 +16,7 @@ @import 'gas-customization/gas-modal-page-container/index'; @import 'gas-customization/gas-price-button-group/index'; @import 'gas-customization/index'; +@import 'gas-timing/index'; @import 'home-notification/index'; @import 'info-box/index'; @import 'menu-bar/index'; diff --git a/ui/components/app/gas-timing/gas-timing.component.js b/ui/components/app/gas-timing/gas-timing.component.js new file mode 100644 index 000000000..3b34be488 --- /dev/null +++ b/ui/components/app/gas-timing/gas-timing.component.js @@ -0,0 +1,32 @@ +import React from 'react'; +import PropTypes from 'prop-types'; +import classNames from 'classnames'; + +import Typography from '../../ui/typography/typography'; +import { TYPOGRAPHY } from '../../../helpers/constants/design-system'; +import InfoTooltip from '../../ui/info-tooltip'; + +export default function GasTiming({ text, tooltipText, attitude }) { + return ( + + {text} + {tooltipText && } + + ); +} + +GasTiming.propTypes = { + text: PropTypes.string.isRequired, + tooltipText: PropTypes.string, + attitude: PropTypes.oneOf(['positive', 'negative', 'warning', '']), +}; + +GasTiming.defaultProps = { + tooltipText: '', + attitude: '', +}; diff --git a/ui/components/app/gas-timing/gas-timing.stories.js b/ui/components/app/gas-timing/gas-timing.stories.js new file mode 100644 index 000000000..639cd9718 --- /dev/null +++ b/ui/components/app/gas-timing/gas-timing.stories.js @@ -0,0 +1,49 @@ +import React from 'react'; + +import GasTiming from '.'; + +export default { + title: 'Gas Timing', +}; + +export const simple = () => { + return ( +
+ +
+ ); +}; + +export const withTooltip = () => { + return ( +
+ +
+ ); +}; + +export const withAttitudes = () => { + return ( +
+ + + + +
+ ); +}; diff --git a/ui/components/app/gas-timing/index.js b/ui/components/app/gas-timing/index.js new file mode 100644 index 000000000..35e38614a --- /dev/null +++ b/ui/components/app/gas-timing/index.js @@ -0,0 +1 @@ +export { default } from './gas-timing.component'; diff --git a/ui/components/app/gas-timing/index.scss b/ui/components/app/gas-timing/index.scss new file mode 100644 index 000000000..b8174b982 --- /dev/null +++ b/ui/components/app/gas-timing/index.scss @@ -0,0 +1,20 @@ +.typography.gas-timing { + color: $ui-4; + + &--positive { + color: $success-3; + } + + &--warning { + color: $alert-3; + } + + &--negative { + color: $error-1; + } + + .info-tooltip { + display: inline-block; + margin-inline-start: 4px; + } +} diff --git a/ui/components/app/transaction-detail-item/transaction-detail-item.component.js b/ui/components/app/transaction-detail-item/transaction-detail-item.component.js index c9bc72b32..0e3039987 100644 --- a/ui/components/app/transaction-detail-item/transaction-detail-item.component.js +++ b/ui/components/app/transaction-detail-item/transaction-detail-item.component.js @@ -30,6 +30,7 @@ export default function TransactionDetailItem({ {detailText} @@ -48,11 +49,14 @@ export default function TransactionDetailItem({ {subTitle} )} - {subText} + + {subText} + ); diff --git a/ui/components/app/transaction-detail-item/transaction-detail-item.stories.js b/ui/components/app/transaction-detail-item/transaction-detail-item.stories.js index a7d81e70a..6565eea5a 100644 --- a/ui/components/app/transaction-detail-item/transaction-detail-item.stories.js +++ b/ui/components/app/transaction-detail-item/transaction-detail-item.stories.js @@ -1,5 +1,6 @@ import React from 'react'; import InfoTooltip from '../../ui/info-tooltip/info-tooltip'; +import GasTiming from '../gas-timing/gas-timing.component'; import TransactionDetailItem from '.'; export default { @@ -20,7 +21,7 @@ export const basic = () => { } detailText="16565.30" detailTotal="0.0089 ETH" - subTitle="Very likely in < 15 seconds" + subTitle={} subText={ <> From $16565 - $19000 diff --git a/ui/components/app/transaction-detail/transaction-detail.stories.js b/ui/components/app/transaction-detail/transaction-detail.stories.js index 1cfc6e8fe..e20fbd64a 100644 --- a/ui/components/app/transaction-detail/transaction-detail.stories.js +++ b/ui/components/app/transaction-detail/transaction-detail.stories.js @@ -1,6 +1,7 @@ import React from 'react'; import InfoTooltip from '../../ui/info-tooltip/info-tooltip'; import TransactionDetailItem from '../transaction-detail-item/transaction-detail-item.component'; +import GasTiming from '../gas-timing/gas-timing.component'; import TransactionDetail from '.'; export default { @@ -20,7 +21,7 @@ const rows = [ } detailText="0.00896 ETH" detailTotal="$15.73" - subTitle="Very likely in < 15 seconds" + subTitle={} subText={ <> From $15.73 - $19.81 diff --git a/ui/components/app/transaction-total-banner/transaction-total-banner.component.js b/ui/components/app/transaction-total-banner/transaction-total-banner.component.js index 40731186a..f267155ca 100644 --- a/ui/components/app/transaction-total-banner/transaction-total-banner.component.js +++ b/ui/components/app/transaction-total-banner/transaction-total-banner.component.js @@ -4,6 +4,8 @@ import PropTypes from 'prop-types'; import Typography from '../../ui/typography/typography'; import { COLORS, TYPOGRAPHY } from '../../../helpers/constants/design-system'; +import GasTiming from '../gas-timing/gas-timing.component'; + export default function TransactionTotalBanner({ total, detail, timing }) { return (
@@ -19,15 +21,7 @@ export default function TransactionTotalBanner({ total, detail, timing }) { {detail} )} - {timing && ( - - {timing} - - )} + {timing && }
); }