@oanda/labs-instrument-live-rate-widget 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/main/InstrumentLiveRateWidget/Main.js +4 -4
- package/dist/main/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +46 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/index.js +4 -4
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +6 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +7 -5
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/index.js +11 -0
- package/dist/main/InstrumentLiveRateWidget/components/index.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/types.js.map +1 -1
- package/dist/main/InstrumentLiveRateWidget/utils.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/Main.js +4 -4
- package/dist/module/InstrumentLiveRateWidget/Main.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js +38 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js +3 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js +2 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithChart/utils.js.map +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js +8 -6
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/components/LineChartWithData/types.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/components/index.js +1 -0
- package/dist/module/InstrumentLiveRateWidget/components/index.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/types.js.map +1 -1
- package/dist/module/InstrumentLiveRateWidget/utils.js.map +1 -1
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.d.ts +4 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.d.ts +2 -0
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.d.ts +9 -0
- package/dist/types/InstrumentLiveRateWidget/components/LineChartWithData/types.d.ts +1 -2
- package/dist/types/InstrumentLiveRateWidget/components/index.d.ts +1 -0
- package/dist/types/InstrumentLiveRateWidget/types.d.ts +0 -22
- package/dist/types/InstrumentLiveRateWidget/utils.d.ts +2 -3
- package/package.json +3 -3
- package/src/InstrumentLiveRateWidget/Main.tsx +6 -5
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/InstrumentRateWithChart.tsx +43 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/index.ts +2 -0
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithChart/types.ts +10 -0
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/LineChartWithData.tsx +14 -15
- package/src/InstrumentLiveRateWidget/components/LineChartWithData/types.tsx +1 -2
- package/src/InstrumentLiveRateWidget/components/index.ts +1 -0
- package/src/InstrumentLiveRateWidget/types.tsx +0 -26
- package/src/InstrumentLiveRateWidget/utils.ts +2 -3
- package/test/components/{InstrumentRateWithData.test.tsx → InstrumentRateWithChart.test.tsx} +7 -7
- package/test/components/utils.test.ts +1 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +0 -83
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +0 -1
- package/dist/main/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js +0 -74
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js +0 -3
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.js.map +0 -1
- package/dist/module/InstrumentLiveRateWidget/components/InstrumentRateWithData/utils.js.map +0 -1
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.d.ts +0 -4
- package/dist/types/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.d.ts +0 -2
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx +0 -92
- package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/index.ts +0 -2
- /package/dist/main/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.js +0 -0
- /package/dist/module/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.js +0 -0
- /package/dist/types/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.d.ts +0 -0
- /package/src/InstrumentLiveRateWidget/components/{InstrumentRateWithData → InstrumentRateWithChart}/utils.ts +0 -0
package/src/InstrumentLiveRateWidget/components/InstrumentRateWithData/InstrumentRateWithData.tsx
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
LabelWrapper, Price, ThemeContext, Truncate,
|
|
4
|
-
} from '@oanda/labs-widget-common';
|
|
5
|
-
import classNames from 'classnames';
|
|
6
|
-
import { InstrumentRateWithDataProps } from '../../types';
|
|
7
|
-
import { LineChartWithData } from '../LineChartWithData';
|
|
8
|
-
import { useRecords } from '../../utils';
|
|
9
|
-
import { INSTRUMENT_TOOLTIP_ID } from '../../constant';
|
|
10
|
-
import { getChartColor, getColorIndicator } from './utils';
|
|
11
|
-
|
|
12
|
-
const InstrumentRateWithData = ({
|
|
13
|
-
loading,
|
|
14
|
-
record,
|
|
15
|
-
target,
|
|
16
|
-
division,
|
|
17
|
-
size = 'fullWithChart',
|
|
18
|
-
}: InstrumentRateWithDataProps) => {
|
|
19
|
-
const { isDark } = useContext(ThemeContext);
|
|
20
|
-
const { updatedRecord, error } = useRecords(record, record.instrument ? target : null);
|
|
21
|
-
|
|
22
|
-
const checkLoading = (id: string) => loading || (!error && updatedRecord?.[id] === undefined);
|
|
23
|
-
|
|
24
|
-
const indicator = getColorIndicator(updatedRecord.dailyPercentChange);
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<div className="lw-flex lw-flex-col lw-px-4 lw-pb-1 lw-pt-2">
|
|
28
|
-
<div className="lw-flex lw-items-center lw-gap-x-2">
|
|
29
|
-
<LabelWrapper
|
|
30
|
-
isLoading={checkLoading('instrument')}
|
|
31
|
-
isError={!!error}
|
|
32
|
-
>
|
|
33
|
-
<span className="lw-text-xl lw-font-bold">
|
|
34
|
-
<Truncate maxWidth={130} text={record.displayName} tooltipId={INSTRUMENT_TOOLTIP_ID} />
|
|
35
|
-
</span>
|
|
36
|
-
</LabelWrapper>
|
|
37
|
-
<LabelWrapper
|
|
38
|
-
isLoading={checkLoading('buy')}
|
|
39
|
-
isError={!!error}
|
|
40
|
-
>
|
|
41
|
-
<div className="lw-text-xl lw-font-bold">
|
|
42
|
-
<Price priceMovement={updatedRecord.buyPriceMovement} withoutArrow>
|
|
43
|
-
<span>{updatedRecord.buy?.toFixed(updatedRecord.displayPrecision)}</span>
|
|
44
|
-
</Price>
|
|
45
|
-
</div>
|
|
46
|
-
</LabelWrapper>
|
|
47
|
-
</div>
|
|
48
|
-
{size !== 'compact'
|
|
49
|
-
&& (
|
|
50
|
-
<div className="lw-mt-1 lw-flex lw-items-center lw-gap-x-2">
|
|
51
|
-
<LabelWrapper
|
|
52
|
-
isLoading={checkLoading('dailyPercentChange')}
|
|
53
|
-
isError={!!error}
|
|
54
|
-
>
|
|
55
|
-
<span className={classNames('lw-font-bold', {
|
|
56
|
-
'lw-text-text-ok': indicator > 0,
|
|
57
|
-
'lw-text-text-danger': indicator < 0,
|
|
58
|
-
'lw-text-text-disabled': indicator === 0,
|
|
59
|
-
})}
|
|
60
|
-
>
|
|
61
|
-
{updatedRecord.dailyPercentChange}
|
|
62
|
-
</span>
|
|
63
|
-
|
|
64
|
-
</LabelWrapper>
|
|
65
|
-
<LabelWrapper
|
|
66
|
-
isLoading={checkLoading('dailyPipsChange')}
|
|
67
|
-
isError={!!error}
|
|
68
|
-
>
|
|
69
|
-
<span className={classNames('lw-font-bold', {
|
|
70
|
-
'lw-text-text-ok': indicator > 0,
|
|
71
|
-
'lw-text-text-danger': indicator < 0,
|
|
72
|
-
'lw-text-text-disabled': indicator === 0,
|
|
73
|
-
})}
|
|
74
|
-
>
|
|
75
|
-
{`(${updatedRecord.dailyPipsChange})`}
|
|
76
|
-
</span>
|
|
77
|
-
</LabelWrapper>
|
|
78
|
-
{size === 'fullWithChart' && (
|
|
79
|
-
<LineChartWithData
|
|
80
|
-
record={updatedRecord}
|
|
81
|
-
isLoading={checkLoading('instrument')}
|
|
82
|
-
division={division}
|
|
83
|
-
color={getChartColor(indicator, isDark)}
|
|
84
|
-
/>
|
|
85
|
-
)}
|
|
86
|
-
</div>
|
|
87
|
-
)}
|
|
88
|
-
</div>
|
|
89
|
-
);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
export { InstrumentRateWithData };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|