-
Notifications
You must be signed in to change notification settings - Fork 36
/
dapp-transaction-summary.component.tsx
64 lines (58 loc) · 1.86 KB
/
dapp-transaction-summary.component.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/* eslint-disable @typescript-eslint/prefer-optional-chain */
import React from 'react';
import { ReactComponent as CardanoLogoComponent } from '@lace/icons/dist/CardanoLogoComponent';
import classNames from 'classnames';
import { Flex } from '../flex';
import { Grid, Cell } from '../grid';
import { Tooltip } from '../tooltip';
import * as Typography from '../typography';
import * as styles from './dapp-transaction-summary.css';
import type { OmitClassName } from '../../types';
type Props = OmitClassName<'div'> & {
testId?: string;
transactionAmount: string;
adaTooltip: string;
title?: string;
cardanoSymbol?: string;
};
export const TransactionSummary = ({
testId,
transactionAmount,
adaTooltip,
title,
cardanoSymbol,
...props
}: Readonly<Props>): JSX.Element => (
<div className={styles.txSummaryContainer}>
{title !== undefined && (
<Flex justifyContent="flex-start">
<Typography.Body.Large className={styles.txSummaryTitle}>
{title}
</Typography.Body.Large>
</Flex>
)}
<div className={styles.txAmountContainer} data-testid={testId}>
<Grid {...props} alignItems="$center" columns="$2">
<Cell>
<Tooltip label={adaTooltip}>
<CardanoLogoComponent className={styles.cardanoIcon} />
</Tooltip>
</Cell>
<Cell>
<Flex justifyContent="flex-end">
<Tooltip label={adaTooltip}>
<Typography.Body.Small
className={classNames(styles.label, {
[styles.positiveBalance]: !transactionAmount.includes('-'),
[styles.negativeBalance]: transactionAmount.includes('-'),
})}
>
{transactionAmount} {cardanoSymbol}
</Typography.Body.Small>
</Tooltip>
</Flex>
</Cell>
</Grid>
</div>
</div>
);