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 edd5c141f8e4..74ccd282e738 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 0d19b899c235..80236e500b81 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 880b74bcd951..68086ec616ff 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 de6f2afcc1cb..339ef4441814 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 c23cca668e5b..83e638ca1291 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 9131fb9450b0..ccc7f74b05aa 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="box box--margin-top-1 box--margin-bottom-1 box--flex-direction-row typography typography--h6 typography--weight-normal typography--style-normal typography--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 61224fdb0f06..b29efce542e3 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 cd5df6672682..4f1f5f323ccf 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 @@ -74,19 +74,16 @@ exports[`AccountListItem renders AccountListItem component and shows account nam class="box mm-text multichain-account-list-item__asset mm-text--body-md mm-text--ellipsis mm-text--text-align-end box--display-flex box--flex-direction-row box--align-items-center box--color-text-default" >
- 0.006 ETH @@ -110,19 +107,16 @@ exports[`AccountListItem renders AccountListItem component and shows account nam class="box mm-text mm-text--body-sm mm-text--text-align-end box--flex-direction-row 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 6e898fc29bc9..44ba7be60b6f 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 73f32a2eb7fa..26a80b45dd67 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 000000000000..4e23fca27a6a --- /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 933554b0dd41..000000000000 --- 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 7ac0d578b272..aef0ae38ce3c 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 7a2fde6ebc7f..188a23144bd7 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="box mm-text mm-text--heading-md mm-text--font-weight-normal mm-text--ellipsis box--flex-direction-row 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 a4f40b4c1d57..8231684b0929 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="box mm-text mm-text--heading-md mm-text--font-weight-normal mm-text--ellipsis box--flex-direction-row 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 dbfb1ee1e24e..f90d6521e8b7 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