@oanda/labs-currency-power-balance-widget 1.0.110 → 1.0.112
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 +900 -0
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js +3 -4
- package/dist/main/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +12 -17
- package/dist/main/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/Main.js +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/Main.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +3 -4
- package/dist/main/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js +3 -3
- package/dist/module/CurrencyPowerBalanceWidget/ChartWithData.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js +14 -19
- package/dist/module/CurrencyPowerBalanceWidget/CurrencyPowerBalance.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/Main.js +3 -3
- package/dist/module/CurrencyPowerBalanceWidget/Main.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js +3 -3
- package/dist/module/CurrencyPowerBalanceWidget/components/Chart/Chart.js.map +1 -1
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js +3 -3
- package/dist/module/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.js.map +1 -1
- package/package.json +3 -3
- package/src/CurrencyPowerBalanceWidget/ChartWithData.tsx +3 -3
- package/src/CurrencyPowerBalanceWidget/CurrencyPowerBalance.tsx +16 -20
- package/src/CurrencyPowerBalanceWidget/Main.tsx +3 -3
- package/src/CurrencyPowerBalanceWidget/components/Chart/Chart.tsx +3 -3
- package/src/CurrencyPowerBalanceWidget/components/TimeUnitSwitch/TimeUnitSwitch.tsx +3 -3
- package/test/Main.test.tsx +11 -11
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ApolloClient, InMemoryCache
|
|
3
|
-
import {
|
|
4
|
-
ChartError, ThemeProvider, getLocale, renderComponent,
|
|
5
|
-
} from '@oanda/labs-widget-common';
|
|
6
|
-
import { LocaleProvider } from '@oanda/mono-i18n';
|
|
2
|
+
import { ApolloClient, InMemoryCache } from '@apollo/client';
|
|
3
|
+
import { WidgetProvider, WidgetWrapper } from '@oanda/labs-widget-common';
|
|
7
4
|
import { Main } from './Main';
|
|
8
5
|
import { CurrencyPowerBalanceConfig } from './types';
|
|
9
6
|
import { translations } from '../translations';
|
|
@@ -17,21 +14,20 @@ const CurrencyPowerBalance = ({
|
|
|
17
14
|
});
|
|
18
15
|
|
|
19
16
|
return (
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
</ThemeProvider>
|
|
17
|
+
<WidgetProvider
|
|
18
|
+
locale={locale}
|
|
19
|
+
translations={translations}
|
|
20
|
+
client={client}
|
|
21
|
+
theme={theme}
|
|
22
|
+
>
|
|
23
|
+
<WidgetWrapper
|
|
24
|
+
logoLink={logoLink}
|
|
25
|
+
linkArea="logo"
|
|
26
|
+
isParamError={isParamError}
|
|
27
|
+
>
|
|
28
|
+
<Main timeUnit={timeUnit} currencies={currencies} />
|
|
29
|
+
</WidgetWrapper>
|
|
30
|
+
</WidgetProvider>
|
|
35
31
|
);
|
|
36
32
|
};
|
|
37
33
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
import {
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { useLayoutProvider } from '@oanda/labs-widget-common';
|
|
3
3
|
import { useLocale } from '@oanda/mono-i18n';
|
|
4
4
|
import { CurrencyPowerBalanceTimeUnit } from '../gql/types/graphql';
|
|
5
5
|
import { TimeUnitSwitch } from './components/TimeUnitSwitch';
|
|
@@ -8,7 +8,7 @@ import { ChartWithData } from './ChartWithData';
|
|
|
8
8
|
import { MainProps } from './types';
|
|
9
9
|
|
|
10
10
|
const Main = ({ timeUnit, currencies }: MainProps) => {
|
|
11
|
-
const { size } =
|
|
11
|
+
const { size } = useLayoutProvider();
|
|
12
12
|
const { lang } = useLocale();
|
|
13
13
|
const [selectedTimeUnit, setSelectedTimeUnit] = useState(
|
|
14
14
|
timeUnit || CurrencyPowerBalanceTimeUnit.CurrentDay,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useRef, useEffect
|
|
1
|
+
import React, { useRef, useEffect } from 'react';
|
|
2
2
|
import ReactEChartsCore from 'echarts-for-react/lib/core';
|
|
3
3
|
import * as echarts from 'echarts/core';
|
|
4
4
|
import { LineChart } from 'echarts/charts';
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
GridSimpleComponent, GraphicComponent, TooltipComponent, LegendPlainComponent, MarkLineComponent,
|
|
8
8
|
} from 'echarts/components';
|
|
9
9
|
import {
|
|
10
|
-
Theme,
|
|
10
|
+
Theme, useLayoutProvider, getChartTheme, Size,
|
|
11
11
|
} from '@oanda/labs-widget-common';
|
|
12
12
|
import { useLocale } from '@oanda/mono-i18n';
|
|
13
13
|
import {
|
|
@@ -31,7 +31,7 @@ echarts.registerTheme('light_theme', getChartTheme(Theme.Light));
|
|
|
31
31
|
|
|
32
32
|
const Chart = ({ values, timeUnit, currencies }: ChartProps) => {
|
|
33
33
|
const { lang } = useLocale();
|
|
34
|
-
const { isDark, size } =
|
|
34
|
+
const { isDark, size } = useLayoutProvider();
|
|
35
35
|
const isDesktop = size === Size.DESKTOP;
|
|
36
36
|
const isMobile = size === Size.MOBILE;
|
|
37
37
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import {
|
|
3
|
-
Button, ButtonSize, ButtonVariant,
|
|
3
|
+
Button, ButtonSize, ButtonVariant, useLayoutProvider, Size,
|
|
4
4
|
} from '@oanda/labs-widget-common';
|
|
5
5
|
import { useLocale } from '@oanda/mono-i18n';
|
|
6
6
|
import { TimeUnitSwitchProps } from './types';
|
|
@@ -12,7 +12,7 @@ const TimeUnitSwitch = ({
|
|
|
12
12
|
selected, options, callback,
|
|
13
13
|
}: TimeUnitSwitchProps) => {
|
|
14
14
|
const { lang } = useLocale();
|
|
15
|
-
const { size } =
|
|
15
|
+
const { size } = useLayoutProvider();
|
|
16
16
|
const isDesktop = size === Size.DESKTOP;
|
|
17
17
|
|
|
18
18
|
const handleButtonClick = (e: React.SyntheticEvent<HTMLButtonElement>) => {
|
package/test/Main.test.tsx
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { render } from '@testing-library/react';
|
|
6
6
|
import { MockedProvider } from '@apollo/client/testing';
|
|
7
|
-
import {
|
|
7
|
+
import { MockLayoutProvider, Size } from '@oanda/labs-widget-common';
|
|
8
8
|
import { Main } from '../src/CurrencyPowerBalanceWidget/Main';
|
|
9
9
|
import { mockResponse } from './responsesMocks';
|
|
10
10
|
import { CurrencyPowerBalanceTimeUnit } from '../src/gql/types/graphql';
|
|
@@ -13,9 +13,9 @@ describe('Main component', () => {
|
|
|
13
13
|
it('should render tool desktop view', async () => {
|
|
14
14
|
const { findByTestId, getByTestId, queryByTestId } = render(
|
|
15
15
|
<MockedProvider mocks={mockResponse}>
|
|
16
|
-
<
|
|
16
|
+
<MockLayoutProvider>
|
|
17
17
|
<Main />
|
|
18
|
-
</
|
|
18
|
+
</MockLayoutProvider>
|
|
19
19
|
</MockedProvider>,
|
|
20
20
|
);
|
|
21
21
|
|
|
@@ -26,9 +26,9 @@ describe('Main component', () => {
|
|
|
26
26
|
it('should render widget desktop view', async () => {
|
|
27
27
|
const { findByTestId, getByTestId, queryByTestId } = render(
|
|
28
28
|
<MockedProvider mocks={mockResponse}>
|
|
29
|
-
<
|
|
29
|
+
<MockLayoutProvider>
|
|
30
30
|
<Main timeUnit={CurrencyPowerBalanceTimeUnit.CurrentDay} currencies={['USD', 'EUR']} />
|
|
31
|
-
</
|
|
31
|
+
</MockLayoutProvider>
|
|
32
32
|
</MockedProvider>,
|
|
33
33
|
);
|
|
34
34
|
|
|
@@ -39,9 +39,9 @@ describe('Main component', () => {
|
|
|
39
39
|
it('should render tool desktop view when timeUnit missing for widget', async () => {
|
|
40
40
|
const { findByTestId, getByTestId, queryByTestId } = render(
|
|
41
41
|
<MockedProvider mocks={mockResponse}>
|
|
42
|
-
<
|
|
42
|
+
<MockLayoutProvider>
|
|
43
43
|
<Main currencies={['USD', 'EUR']} />
|
|
44
|
-
</
|
|
44
|
+
</MockLayoutProvider>
|
|
45
45
|
</MockedProvider>,
|
|
46
46
|
);
|
|
47
47
|
|
|
@@ -52,9 +52,9 @@ describe('Main component', () => {
|
|
|
52
52
|
it('should render tool desktop view when currencies missing for widget', async () => {
|
|
53
53
|
const { findByTestId, getByTestId, queryByTestId } = render(
|
|
54
54
|
<MockedProvider mocks={mockResponse}>
|
|
55
|
-
<
|
|
55
|
+
<MockLayoutProvider>
|
|
56
56
|
<Main timeUnit={CurrencyPowerBalanceTimeUnit.CurrentDay} />
|
|
57
|
-
</
|
|
57
|
+
</MockLayoutProvider>
|
|
58
58
|
</MockedProvider>,
|
|
59
59
|
);
|
|
60
60
|
|
|
@@ -65,9 +65,9 @@ describe('Main component', () => {
|
|
|
65
65
|
it('should render tool mobile view', async () => {
|
|
66
66
|
const { findByTestId, getByTestId, queryByTestId } = render(
|
|
67
67
|
<MockedProvider mocks={mockResponse}>
|
|
68
|
-
<
|
|
68
|
+
<MockLayoutProvider size={Size.MOBILE}>
|
|
69
69
|
<Main />
|
|
70
|
-
</
|
|
70
|
+
</MockLayoutProvider>
|
|
71
71
|
</MockedProvider>,
|
|
72
72
|
);
|
|
73
73
|
|