Skip to content

Commit 906d1ee

Browse files
committed
fix: add tooltip to transaction summary
1 parent 19be67e commit 906d1ee

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

src/design-system/transaction-summary/transaction-summary-other.component.tsx

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
import React from 'react';
22

3+
import InfoIcon from '@icons/InfoComponent';
4+
import classNames from 'classnames';
5+
6+
import { Box } from '../box';
37
import { Flex } from '../flex';
48
import { Grid, Cell } from '../grid';
59
import { Text } from '../text';
10+
import { Tooltip } from '../tooltip';
611

712
import * as cx from './transaction-summary.css';
813

@@ -11,21 +16,48 @@ import type { OmitClassName } from '../../types';
1116
type Props = OmitClassName<'div'> & {
1217
label: string;
1318
text: string;
19+
tooltip?: string;
20+
'data-testid'?: string;
21+
textAlignRight?: boolean;
22+
};
23+
24+
const makeTestId = (namespace = '', path = ''): string | undefined => {
25+
return namespace === '' ? undefined : `tx-other-${namespace}-${path}`;
1426
};
1527

1628
export const Other = ({
1729
label,
1830
text,
31+
tooltip,
32+
textAlignRight = false,
1933
...props
2034
}: Readonly<Props>): JSX.Element => {
35+
const testId = props['data-testid'];
36+
2137
return (
2238
<Grid {...props} columns="$2">
2339
<Cell>
24-
<Text.Body.Normal weight="$semibold">{label}</Text.Body.Normal>
40+
<Flex>
41+
<Text.Body.Normal weight="$semibold">{label}</Text.Body.Normal>
42+
{tooltip !== undefined && (
43+
<Box ml="$8">
44+
<Tooltip label={tooltip}>
45+
<div data-testid={makeTestId(testId, 'tooltip-icon')}>
46+
<InfoIcon className={cx.tooltipIcon} />
47+
</div>
48+
</Tooltip>
49+
</Box>
50+
)}
51+
</Flex>
2552
</Cell>
2653
<Cell>
2754
<Flex justifyContent="flex-end" h="$fill">
28-
<Text.Body.Normal weight="$medium" className={cx.text}>
55+
<Text.Body.Normal
56+
weight="$medium"
57+
className={classNames(cx.text, {
58+
[cx.textAlignRight]: textAlignRight,
59+
})}
60+
>
2961
{text}
3062
</Text.Body.Normal>
3163
</Flex>

src/design-system/transaction-summary/transaction-summary.css.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export const secondaryText = style({
88
wordBreak: 'break-all',
99
});
1010

11+
export const textAlignRight = style({
12+
textAlign: 'right',
13+
});
14+
1115
export const tooltipIcon = style([
1216
sx({
1317
color: '$text_primary',

src/design-system/transaction-summary/transaction-summary.stories.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,17 @@ const MainComponents = (): JSX.Element => (
105105
</Layout>
106106
</Variants.Cell>
107107
</Variants.Row>
108+
<Variants.Row>
109+
<Variants.Cell>
110+
<Layout>
111+
<Other
112+
label="Label with tooltip"
113+
text="Ut condimentum enim pulvinar, consequat nunc vitae, feugiat nisl. Vestibulum elementum condiment congue et nam quis ipsum diam."
114+
tooltip="Ut condimentum enim pulvinar, consequat nunc vitae, feugiat nisl"
115+
/>
116+
</Layout>
117+
</Variants.Cell>
118+
</Variants.Row>
108119
<Variants.Row>
109120
<Variants.Cell>
110121
<Layout>

0 commit comments

Comments
 (0)