Skip to content

Commit

Permalink
frontend: modify fiat historical value placeholder in tx
Browse files Browse the repository at this point in the history
Fiat historical value is shown in tx detail. If the transaction is
recent the value could be not available. The placeholder we used was
'---' which led to poorly readable results for incoming/outgoing txs
('+---' or '----'). Now, if the amount is not available the placeholder
is shown without the sign, which should be more readable.

In the future it would be nice to refactor the FiatConversion component
and limit the `sign` prop to '+' | '-'.
  • Loading branch information
Beerosagos committed Oct 5, 2022
1 parent 92c30d0 commit e730b19
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions frontends/web/src/components/rates/rates.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
right: 2px;
}

.notAvailable {
color: var(--color-default);
}

@media (max-width: 880px) {
.fiatRow {
bottom: 0;
Expand Down
10 changes: 7 additions & 3 deletions frontends/web/src/components/rates/rates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ interface ProvidedProps {
unstyled?: boolean;
skipUnit?: boolean;
noAction?: boolean;
sign?: string;

}

type Props = ProvidedProps & SharedProps;
Expand All @@ -110,13 +112,15 @@ function Conversion({
skipUnit,
active,
noAction,
children,
sign,
}: PropsWithChildren<Props>): JSX.Element | null {

let formattedValue = '---';
let isAvailable = false;

// amount.conversions[active] can be empty in recent transactions.
if (amount && amount.conversions[active] !== '') {
isAvailable = true;
formattedValue = amount.conversions[active];
}

Expand All @@ -138,8 +142,8 @@ function Conversion({
);
}
return (
<span className={style.rates}>
{children}
<span className={ `${style.rates} ${!isAvailable ? style.notAvailable : ''}`}>
{isAvailable ? sign : ''}
{formattedValue}
{' '}
{
Expand Down
10 changes: 5 additions & 5 deletions frontends/web/src/components/transactions/transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class Transaction extends Component<Props, State> {
) : (
<ArrowSelf />
);
const sign = ((type === 'send') && '−') || ((type === 'receive') && '+') || null;
const sign = ((type === 'send') && '−') || ((type === 'receive') && '+') || '';
const typeClassName = (type === 'send' && style.send) || (type === 'receive' && style.receive) || '';
const sDate = time ? this.parseTimeShort(time) : '---';
const statusText = {
Expand Down Expand Up @@ -204,7 +204,7 @@ class Transaction extends Component<Props, State> {
</div>
<div className={parentStyle.fiat}>
<span className={`${style.fiat} ${typeClassName}`}>
<FiatConversion amount={amount} noAction>{sign}</FiatConversion>
<FiatConversion amount={amount} sign={sign} noAction />
</span>
</div>
<div className={parentStyle.currency}>
Expand Down Expand Up @@ -284,7 +284,7 @@ class Transaction extends Component<Props, State> {
<label>{t('transaction.details.fiat')}</label>
<p>
<span className={`${style.fiat} ${typeClassName}`}>
<FiatConversion amount={amount} noAction>{sign}</FiatConversion>
<FiatConversion amount={amount} sign={sign} noAction />
</span>
</p>
</div>
Expand All @@ -293,9 +293,9 @@ class Transaction extends Component<Props, State> {
<p>
<span className={`${style.fiat} ${typeClassName}`}>
{ transactionInfo.amountAtTime ?
<FiatConversion amount={transactionInfo.amountAtTime} noAction>{sign}</FiatConversion>
<FiatConversion amount={transactionInfo.amountAtTime} sign={sign} noAction />
:
<FiatConversion noAction>{sign}</FiatConversion>
<FiatConversion noAction />
}
</span>
</p>
Expand Down

0 comments on commit e730b19

Please sign in to comment.