diff --git a/ui/components/app/confirm-gas-display/__snapshots__/confirm-gas-display.test.js.snap b/ui/components/app/confirm-gas-display/__snapshots__/confirm-gas-display.test.js.snap index 94e7f77da..32e18b8ab 100644 --- a/ui/components/app/confirm-gas-display/__snapshots__/confirm-gas-display.test.js.snap +++ b/ui/components/app/confirm-gas-display/__snapshots__/confirm-gas-display.test.js.snap @@ -64,14 +64,11 @@ exports[`ConfirmGasDisplay should match snapshot 1`] = ` class="gas-details-item__currency-container" >
- 0 @@ -85,19 +82,16 @@ exports[`ConfirmGasDisplay should match snapshot 1`] = ` class="gas-details-item__currency-container" >
- 0 ETH @@ -133,19 +127,16 @@ exports[`ConfirmGasDisplay should match snapshot 1`] = ` class="gas-details-item__currency-container" >
- 0 ETH diff --git a/ui/components/app/confirm-gas-display/confirm-legacy-gas-display/__snapshots__/confirm-legacy-gas-display.test.js.snap b/ui/components/app/confirm-gas-display/confirm-legacy-gas-display/__snapshots__/confirm-legacy-gas-display.test.js.snap index 06740da63..a380323e7 100644 --- a/ui/components/app/confirm-gas-display/confirm-legacy-gas-display/__snapshots__/confirm-legacy-gas-display.test.js.snap +++ b/ui/components/app/confirm-gas-display/confirm-legacy-gas-display/__snapshots__/confirm-legacy-gas-display.test.js.snap @@ -46,14 +46,11 @@ exports[`ConfirmLegacyGasDisplay should match snapshot 1`] = ` >
- 0.000021 @@ -65,19 +62,16 @@ exports[`ConfirmLegacyGasDisplay should match snapshot 1`] = ` >
- 0.000021 ETH @@ -98,19 +92,16 @@ exports[`ConfirmLegacyGasDisplay should match snapshot 1`] = `
- 0.000021 ETH diff --git a/ui/components/app/confirm-page-container/confirm-detail-row/__snapshots__/confirm-detail-row.component.test.js.snap b/ui/components/app/confirm-page-container/confirm-detail-row/__snapshots__/confirm-detail-row.component.test.js.snap index 880b74bcd..68086ec61 100644 --- a/ui/components/app/confirm-page-container/confirm-detail-row/__snapshots__/confirm-detail-row.component.test.js.snap +++ b/ui/components/app/confirm-page-container/confirm-detail-row/__snapshots__/confirm-detail-row.component.test.js.snap @@ -12,37 +12,39 @@ exports[`Confirm Detail Row Component should match snapshot 1`] = ` class="confirm-detail-row__details" >
- - +
0
- - +
0 diff --git a/ui/components/app/currency-input/__snapshots__/currency-input.test.js.snap b/ui/components/app/currency-input/__snapshots__/currency-input.test.js.snap index de6f2afcc..339ef4441 100644 --- a/ui/components/app/currency-input/__snapshots__/currency-input.test.js.snap +++ b/ui/components/app/currency-input/__snapshots__/currency-input.test.js.snap @@ -27,19 +27,16 @@ exports[`CurrencyInput Component rendering should render properly with a fiat va
- 0.00432788 ETH @@ -128,19 +125,16 @@ exports[`CurrencyInput Component rendering should render properly with an ETH va
- $231.06 USD @@ -185,19 +179,16 @@ exports[`CurrencyInput Component rendering should render properly without a suff
- $0.00 USD diff --git a/ui/components/app/modals/cancel-transaction/cancel-transaction-gas-fee/__snapshots__/cancel-transaction-gas-fee.component.test.js.snap b/ui/components/app/modals/cancel-transaction/cancel-transaction-gas-fee/__snapshots__/cancel-transaction-gas-fee.component.test.js.snap index c23cca668..83e638ca1 100644 --- a/ui/components/app/modals/cancel-transaction/cancel-transaction-gas-fee/__snapshots__/cancel-transaction-gas-fee.component.test.js.snap +++ b/ui/components/app/modals/cancel-transaction/cancel-transaction-gas-fee/__snapshots__/cancel-transaction-gas-fee.component.test.js.snap @@ -6,37 +6,31 @@ exports[`CancelTransactionGasFee Component should render 1`] = ` class="cancel-transaction-gas-fee" >
- 0 ETH
- 0 ETH diff --git a/ui/components/app/multilayer-fee-message/__snapshots__/multi-layer-fee-message.test.js.snap b/ui/components/app/multilayer-fee-message/__snapshots__/multi-layer-fee-message.test.js.snap index d8a2ca837..13bc77081 100644 --- a/ui/components/app/multilayer-fee-message/__snapshots__/multi-layer-fee-message.test.js.snap +++ b/ui/components/app/multilayer-fee-message/__snapshots__/multi-layer-fee-message.test.js.snap @@ -135,14 +135,11 @@ exports[`Multi layer fee message when balance and token price checker is enabled class="mm-box mm-text mm-text--body-md mm-box--color-text-alternative" >
- $0.56 diff --git a/ui/components/app/user-preferenced-currency-display/__snapshots__/user-preferenced-currency-display.test.js.snap b/ui/components/app/user-preferenced-currency-display/__snapshots__/user-preferenced-currency-display.test.js.snap index 61224fdb0..b29efce54 100644 --- a/ui/components/app/user-preferenced-currency-display/__snapshots__/user-preferenced-currency-display.test.js.snap +++ b/ui/components/app/user-preferenced-currency-display/__snapshots__/user-preferenced-currency-display.test.js.snap @@ -3,19 +3,16 @@ exports[`UserPreferencedCurrencyDisplay Component rendering should match snapshot 1`] = `
- 0 ETH diff --git a/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap b/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap index e15f761c4..a3d8ef3e5 100644 --- a/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap +++ b/ui/components/multichain/account-list-item/__snapshots__/account-list-item.test.js.snap @@ -70,19 +70,16 @@ exports[`AccountListItem renders AccountListItem component and shows account nam class="mm-box mm-text multichain-account-list-item__asset mm-text--body-md mm-text--ellipsis mm-text--text-align-end mm-box--display-flex mm-box--flex-direction-row mm-box--justify-content-flex-end mm-box--align-items-center mm-box--color-text-default" >
- 0.006 ETH @@ -106,19 +103,16 @@ exports[`AccountListItem renders AccountListItem component and shows account nam class="mm-box mm-text mm-text--body-sm mm-text--text-align-end mm-box--color-text-alternative" >
- 0.006 ETH diff --git a/ui/components/ui/currency-display/__snapshots__/currency-display.component.test.js.snap b/ui/components/ui/currency-display/__snapshots__/currency-display.component.test.js.snap index 6e898fc29..44ba7be60 100644 --- a/ui/components/ui/currency-display/__snapshots__/currency-display.component.test.js.snap +++ b/ui/components/ui/currency-display/__snapshots__/currency-display.component.test.js.snap @@ -3,14 +3,11 @@ exports[`CurrencyDisplay Component should match default snapshot 1`] = `
-
@@ -19,14 +16,11 @@ exports[`CurrencyDisplay Component should match default snapshot 1`] = ` exports[`CurrencyDisplay Component should render text with a className 1`] = `
- $123.45 @@ -37,14 +31,11 @@ exports[`CurrencyDisplay Component should render text with a className 1`] = ` exports[`CurrencyDisplay Component should render text with a prefix 1`] = `
- - $123.45 diff --git a/ui/components/ui/currency-display/currency-display.component.js b/ui/components/ui/currency-display/currency-display.component.js index 73f32a2eb..26a80b45d 100644 --- a/ui/components/ui/currency-display/currency-display.component.js +++ b/ui/components/ui/currency-display/currency-display.component.js @@ -3,6 +3,13 @@ import PropTypes from 'prop-types'; import classnames from 'classnames'; import { useCurrencyDisplay } from '../../../hooks/useCurrencyDisplay'; import { EtherDenomination } from '../../../../shared/constants/common'; +import { Text, Box } from '../../component-library'; +import { + AlignItems, + Display, + FlexWrap, + TextVariant, +} from '../../../helpers/constants/design-system'; export default function CurrencyDisplay({ value, @@ -18,6 +25,10 @@ export default function CurrencyDisplay({ denomination, currency, suffix, + prefixComponentWrapperProps = {}, + textProps = {}, + suffixProps = {}, + ...props }) { const [title, parts] = useCurrencyDisplay(value, { displayValue, @@ -28,26 +39,50 @@ export default function CurrencyDisplay({ currency, suffix, }); + return ( -
- - {prefixComponent} - - + {prefixComponent ? ( + + {prefixComponent} + + ) : null} + {parts.prefix} {parts.value} - - {parts.suffix && ( - + + {parts.suffix ? ( + {parts.suffix} - - )} -
+ + ) : null} + ); } @@ -68,4 +103,7 @@ CurrencyDisplay.propTypes = { style: PropTypes.object, suffix: PropTypes.oneOfType([PropTypes.string, PropTypes.bool]), value: PropTypes.string, + prefixComponentWrapperProps: PropTypes.object, + textProps: PropTypes.object, + suffixProps: PropTypes.object, }; diff --git a/ui/components/ui/currency-display/currency-display.stories.js b/ui/components/ui/currency-display/currency-display.stories.js new file mode 100644 index 000000000..4e23fca27 --- /dev/null +++ b/ui/components/ui/currency-display/currency-display.stories.js @@ -0,0 +1,77 @@ +import React from 'react'; +import { decimalToHex } from '../../../../shared/modules/conversion.utils'; +import { EtherDenomination } from '../../../../shared/constants/common'; +import CurrencyDisplay from '.'; + +export default { + title: 'Components/UI/CurrencyDisplay', + argTypes: { + className: { + control: 'text', + }, + currency: { + control: 'text', + }, + 'data-testid': { + control: 'text', + }, + denomination: { + control: 'select', + options: [EtherDenomination.ETH, EtherDenomination.GWEI], + }, + displayValue: { + control: 'text', + }, + hideLabel: { + control: 'boolean', + }, + hideTitle: { + control: 'boolean', + }, + numberOfDecimals: { + control: 'number', + }, + prefix: { + control: 'text', + }, + prefixComponent: { + control: 'text', + }, + style: { + control: 'object', + }, + suffix: { + control: 'text', + }, + value: { + control: 'text', + }, + prefixComponentWrapperProps: { + control: 'object', + }, + textProps: { + control: 'object', + }, + suffixProps: { + control: 'object', + }, + boxProps: { + control: 'object', + }, + }, + args: { + denomination: EtherDenomination.ETH, + value: decimalToHex('123.45'), + numberOfDecimals: '2', + currency: 'USD', + prefix: '$', + }, +}; + +export const DefaultStory = (args) => ; +DefaultStory.storyName = 'Default'; + +export const DisplayValueStory = (args) => ( + +); +DefaultStory.storyName = 'Display Value'; diff --git a/ui/components/ui/currency-display/index.scss b/ui/components/ui/currency-display/index.scss deleted file mode 100644 index 933554b0d..000000000 --- a/ui/components/ui/currency-display/index.scss +++ /dev/null @@ -1,21 +0,0 @@ -.currency-display-component { - display: flex; - align-items: center; - flex-wrap: wrap; - - &__text { - /*rtl:ignore*/ - direction: ltr; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - } - - &__prefix { - padding-right: 4px; - } - - &__suffix { - padding-left: 4px; - } -} diff --git a/ui/components/ui/ui-components.scss b/ui/components/ui/ui-components.scss index 7ac0d578b..aef0ae38c 100644 --- a/ui/components/ui/ui-components.scss +++ b/ui/components/ui/ui-components.scss @@ -12,7 +12,6 @@ @import 'chip/chip'; @import 'color-indicator/color-indicator'; @import 'confusable/index'; -@import 'currency-display/index'; @import 'definition-list/definition-list'; @import 'dialog/dialog'; @import 'dropdown/dropdown'; diff --git a/ui/pages/confirm-send-ether/__snapshots__/confirm-send-ether.test.js.snap b/ui/pages/confirm-send-ether/__snapshots__/confirm-send-ether.test.js.snap index 6590df11c..c889ab296 100644 --- a/ui/pages/confirm-send-ether/__snapshots__/confirm-send-ether.test.js.snap +++ b/ui/pages/confirm-send-ether/__snapshots__/confirm-send-ether.test.js.snap @@ -287,19 +287,20 @@ exports[`ConfirmSendEther should render correct information for for confirm send class="mm-box mm-text mm-text--heading-md mm-text--font-weight-normal mm-text--ellipsis mm-box--color-text-default" >
- - +
0 @@ -448,14 +449,11 @@ exports[`ConfirmSendEther should render correct information for for confirm send class="gas-details-item__currency-container" >
- 0.00021 @@ -469,19 +467,16 @@ exports[`ConfirmSendEther should render correct information for for confirm send class="gas-details-item__currency-container" >
- 0.00021 ETH @@ -517,19 +512,16 @@ exports[`ConfirmSendEther should render correct information for for confirm send class="gas-details-item__currency-container" >
- 0.00021 ETH @@ -560,14 +552,11 @@ exports[`ConfirmSendEther should render correct information for for confirm send class="confirm-page-container-content__total-value" >
- 0.00021 @@ -581,19 +570,16 @@ exports[`ConfirmSendEther should render correct information for for confirm send class="confirm-page-container-content__total-value" >
- 0.00021 ETH @@ -621,19 +607,16 @@ exports[`ConfirmSendEther should render correct information for for confirm send
- 0.00021 ETH diff --git a/ui/pages/confirm-transaction-base/__snapshots__/confirm-transaction-base.test.js.snap b/ui/pages/confirm-transaction-base/__snapshots__/confirm-transaction-base.test.js.snap index 4d89d32e2..7386530bf 100644 --- a/ui/pages/confirm-transaction-base/__snapshots__/confirm-transaction-base.test.js.snap +++ b/ui/pages/confirm-transaction-base/__snapshots__/confirm-transaction-base.test.js.snap @@ -257,19 +257,20 @@ exports[`Confirm Transaction Base should match snapshot 1`] = ` class="mm-box mm-text mm-text--heading-md mm-text--font-weight-normal mm-text--ellipsis mm-box--color-text-default" >
- - +
0.0001 @@ -378,14 +379,11 @@ exports[`Confirm Transaction Base should match snapshot 1`] = ` >
- 0.000021 @@ -406,14 +404,11 @@ exports[`Confirm Transaction Base should match snapshot 1`] = `
- 0.000021 @@ -443,14 +438,11 @@ exports[`Confirm Transaction Base should match snapshot 1`] = ` class="confirm-page-container-content__total-value" >
- 0.000121 @@ -478,14 +470,11 @@ exports[`Confirm Transaction Base should match snapshot 1`] = `
- 0.000121 diff --git a/ui/pages/send/send-content/__snapshots__/send-content.component.test.js.snap b/ui/pages/send/send-content/__snapshots__/send-content.component.test.js.snap index 23bc6eaa9..df70522a2 100644 --- a/ui/pages/send/send-content/__snapshots__/send-content.component.test.js.snap +++ b/ui/pages/send/send-content/__snapshots__/send-content.component.test.js.snap @@ -51,19 +51,16 @@ exports[`SendContent Component render should match snapshot 1`] = ` Balance:
- 0 ETH @@ -241,19 +238,16 @@ exports[`SendContent Component render should match snapshot 1`] = ` class="gas-details-item__currency-container" >
- 0.0000315 ETH @@ -289,19 +283,16 @@ exports[`SendContent Component render should match snapshot 1`] = ` class="gas-details-item__currency-container" >
- 0.0000315 ETH