Skip to content

Commit 67bb312

Browse files
authored
Merge pull request #116 from input-output-hk/fix/improve-transaction-summary
fix: add tooltip to transaction summary
2 parents 19be67e + 002525f commit 67bb312

File tree

5 files changed

+60
-8
lines changed

5 files changed

+60
-8
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>

src/icons/EditComponent.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
import * as React from 'react';
22
import type { SVGProps } from 'react';
3-
4-
const SvgEditComponent = (props: SVGProps<SVGSVGElement>) => (
5-
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
3+
const SvgEditcomponent = (props: SVGProps<SVGSVGElement>) => (
4+
<svg
5+
xmlns="http://www.w3.org/2000/svg"
6+
width={16}
7+
height={16}
8+
fill="none"
9+
{...props}
10+
>
611
<path
7-
d="M12.5932 3.4068L13.0351 2.96486V2.96486L12.5932 3.4068ZM4.94445 13.0197V13.6447C5.11021 13.6447 5.26918 13.5789 5.38639 13.4617L4.94445 13.0197ZM3 13.0197H2.375C2.375 13.3649 2.65482 13.6447 3 13.6447V13.0197ZM3 11.0358L2.55806 10.5939C2.44085 10.7111 2.375 10.87 2.375 11.0358H3ZM11.071 3.84874C11.3693 3.55042 11.8529 3.55042 12.1513 3.84874L13.0351 2.96486C12.2487 2.17838 10.9735 2.17838 10.1871 2.96486L11.071 3.84874ZM12.1513 3.84874C12.4496 4.14706 12.4496 4.63073 12.1513 4.92905L13.0351 5.81293C13.8216 5.02646 13.8216 3.75133 13.0351 2.96486L12.1513 3.84874ZM12.1513 4.92905L4.50251 12.5778L5.38639 13.4617L13.0351 5.81293L12.1513 4.92905ZM4.94445 12.3947H3V13.6447H4.94445V12.3947ZM10.1871 2.96486L2.55806 10.5939L3.44194 11.4777L11.071 3.84874L10.1871 2.96486ZM2.375 11.0358V13.0197H3.625V11.0358H2.375ZM9.35373 4.68208L11.3179 6.64627L12.2018 5.76238L10.2376 3.79819L9.35373 4.68208Z"
812
fill="currentColor"
13+
d="m12.593 3.407.442-.442zM4.944 13.02v.625a.63.63 0 0 0 .442-.183zM3 13.02h-.625c0 .345.28.625.625.625zm0-1.984-.442-.442a.63.63 0 0 0-.183.442zm8.071-7.187a.764.764 0 0 1 1.08 0l.884-.884a2.014 2.014 0 0 0-2.848 0zm1.08 0a.764.764 0 0 1 0 1.08l.884.884a2.014 2.014 0 0 0 0-2.848zm0 1.08-7.648 7.649.883.884 7.65-7.65zm-7.207 7.466H3v1.25h1.944zm5.243-9.43-7.629 7.629.884.884 7.629-7.63zm-7.812 8.07v1.985h1.25v-1.984zm6.979-6.353 1.964 1.964.884-.884-1.964-1.964z"
914
/>
1015
</svg>
1116
);
12-
export default SvgEditComponent;
17+
export default SvgEditcomponent;

src/icons/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export { default as DocumentDownload } from './DocumentDownload';
2222
export { default as DocumentTextGradientComponent } from './DocumentTextGradientComponent';
2323
export { default as DocumentComponent } from './DocumentComponent';
2424
export { default as DownloadComponent } from './DownloadComponent';
25+
export { default as EditComponent } from './EditComponent';
2526
export { default as ExclamationCircleComponent } from './ExclamationCircleComponent';
2627
export { default as EyeCloseComponent } from './EyeCloseComponent';
2728
export { default as EyeGradientComponent } from './EyeGradientComponent';
@@ -78,4 +79,3 @@ export { default as WalletComponent } from './WalletComponent';
7879
export { default as WarningIconCircleComponent } from './WarningIconCircleComponent';
7980
export { default as WarningIconTriangleSolidComponent } from './WarningIconTriangleSolidComponent';
8081
export { default as WarningIconTriangleComponent } from './WarningIconTriangleComponent';
81-
export { default as EditComponent } from './EditComponent';

0 commit comments

Comments
 (0)