From 24cd36b2bebac69e95d89a494af0e0f17fc462d3 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 30 Oct 2020 14:10:21 +0100 Subject: [PATCH] price display tweaks --- .../atoms/Price/PriceUnit.module.css | 11 ++++++- src/components/atoms/Price/PriceUnit.tsx | 29 ++++++++++++------- src/components/atoms/Price/index.module.css | 5 ---- src/components/atoms/Price/index.tsx | 19 +++++------- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/src/components/atoms/Price/PriceUnit.module.css b/src/components/atoms/Price/PriceUnit.module.css index 9957c1fad..5211d991a 100644 --- a/src/components/atoms/Price/PriceUnit.module.css +++ b/src/components/atoms/Price/PriceUnit.module.css @@ -3,7 +3,11 @@ font-weight: var(--font-weight-bold); font-size: var(--font-size-large); color: var(--brand-grey-dark); - line-height: 1; + line-height: 1.2; +} + +.price > div:firt-child { + white-space: nowrap; } .price span:first-child { @@ -20,3 +24,8 @@ .price.small span:first-child { font-size: var(--font-size-small); } + +.badge { + vertical-align: middle; + margin-left: calc(var(--spacer) / 6); +} diff --git a/src/components/atoms/Price/PriceUnit.tsx b/src/components/atoms/Price/PriceUnit.tsx index 5297bbefc..490cab444 100644 --- a/src/components/atoms/Price/PriceUnit.tsx +++ b/src/components/atoms/Price/PriceUnit.tsx @@ -4,6 +4,7 @@ import classNames from 'classnames/bind' import Conversion from './Conversion' import styles from './PriceUnit.module.css' import { useUserPreferences } from '../../../providers/UserPreferences' +import Badge from '../Badge' const cx = classNames.bind(styles) @@ -12,9 +13,11 @@ export default function PriceUnit({ className, small, conversion, - symbol + symbol, + type }: { price: string + type?: string className?: string small?: boolean conversion?: boolean @@ -30,15 +33,21 @@ export default function PriceUnit({ return (
- {Number.isNaN(Number(price)) - ? '-' - : formatCurrency(Number(price), '', locale, false, { - // Not exactly clear what `significant figures` are for this library, - // but setting this seems to give us the formatting we want. - // See https://github.com/oceanprotocol/market/issues/70 - significantFigures: 4 - })}{' '} - {symbol || 'OCEAN'} +
+ {Number.isNaN(Number(price)) + ? '-' + : formatCurrency(Number(price), '', locale, false, { + // Not exactly clear what `significant figures` are for this library, + // but setting this seems to give us the formatting we want. + // See https://github.com/oceanprotocol/market/issues/70 + significantFigures: 4 + })}{' '} + {symbol || 'OCEAN'} + {type && type === 'pool' && ( + + )} +
+ {conversion && }
) diff --git a/src/components/atoms/Price/index.module.css b/src/components/atoms/Price/index.module.css index a878b4f1c..7b0cb4b4e 100644 --- a/src/components/atoms/Price/index.module.css +++ b/src/components/atoms/Price/index.module.css @@ -2,8 +2,3 @@ color: var(--color-secondary); font-weight: var(--font-weight-bold); } - -.badge { - vertical-align: middle; - margin-left: calc(var(--spacer) / 6); -} diff --git a/src/components/atoms/Price/index.tsx b/src/components/atoms/Price/index.tsx index a2d4c630d..3b50951c1 100644 --- a/src/components/atoms/Price/index.tsx +++ b/src/components/atoms/Price/index.tsx @@ -5,7 +5,6 @@ import { DDO } from '@oceanprotocol/lib' import Loader from '../Loader' import Tooltip from '../Tooltip' import PriceUnit from './PriceUnit' -import Badge from '../Badge' export default function Price({ ddo, @@ -21,17 +20,13 @@ export default function Price({ const { price } = useMetadata(ddo) return price?.value ? ( - <> - - {price?.type === 'pool' && ( - - )} - + ) : !price || price?.value === 0 ? (
No price found{' '}