-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathindex.tsx
99 lines (93 loc) · 2.57 KB
/
index.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/** @format */
/**
* External dependencies
*/
import React from 'react';
import HelpOutlineIcon from 'gridicons/dist/help-outline';
import ArrowUpIcon from 'gridicons/dist/arrow-up';
import ArrowDownIcon from 'gridicons/dist/arrow-down';
import { __ } from '@wordpress/i18n';
import { VisuallyHidden } from '@wordpress/components';
import { Link } from '@woocommerce/components';
import { recordEvent } from 'tracks';
/**
* Internal dependencies
*/
import { ClickTooltip } from 'components/tooltip';
import './styles.scss';
const PaymentChangeFlow: React.FunctionComponent< {
change: number;
} > = ( { change } ): JSX.Element => {
if ( change < 0 ) {
return (
<div className="payment-data-highlight__amount-change-arrow-down">
<span className="payment-data-highlight__amount-change-icon">
<ArrowDownIcon size={ 12 } />
</span>
<span className="payment-data-highlight__amount-change-percentage">
{ Math.abs( change ) }%
</span>
</div>
);
}
return (
<div className="payment-data-highlight__amount-change-arrow-up">
<span className="payment-data-highlight__amount-change-icon">
<ArrowUpIcon size={ 12 } />
</span>
<span className="payment-data-highlight__amount-change-arrow-up-percentage">
{ Math.abs( change ) }%
</span>
</div>
);
};
const PaymentDataHighlight: React.FunctionComponent< {
label: string;
amount: string;
change: number;
reportUrl: string;
tooltip?: string;
} > = ( { label, amount, change, reportUrl, tooltip } ): JSX.Element => {
return (
<div className="payment-data-highlight__wrapper">
<div className="payment-data-highlight__visible">
<div className="payment-data-highlight__label">
<span>{ label }</span>
{ tooltip && (
<ClickTooltip
buttonIcon={ <HelpOutlineIcon /> }
isVisible={ false }
content={ tooltip }
>
<VisuallyHidden>{ tooltip }</VisuallyHidden>
</ClickTooltip>
) }
</div>
<div className="payment-data-highlight__amount">
<div className="payment-data-highlight__amount-number">
{ amount }
</div>
<div className="payment-data-highlight__amount-change">
<PaymentChangeFlow change={ change } />
</div>
</div>
</div>
<div className="payment-data-highlight__view-report">
<Link
href={ reportUrl }
onClick={ () =>
recordEvent(
'wcpay_overview_widget_data_highlight_view_report_click',
{
url: reportUrl,
}
)
}
>
{ __( 'View report', 'woocommerce-paymnets' ) }
</Link>
</div>
</div>
);
};
export default PaymentDataHighlight;