@oanda/labs-crowd-view-widget 1.0.47 → 1.0.49
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 +396 -0
- package/dist/main/CrowdViewWidget/Main.js +4 -2
- package/dist/main/CrowdViewWidget/Main.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js +8 -3
- package/dist/main/CrowdViewWidget/components/Chart/chartOptions.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js +3 -2
- package/dist/main/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js +4 -1
- package/dist/main/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js +4 -1
- package/dist/main/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js +4 -2
- package/dist/main/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/main/CrowdViewWidget/constants.js +9 -2
- package/dist/main/CrowdViewWidget/constants.js.map +1 -1
- package/dist/main/CrowdViewWidget/selectConfig.js +6 -6
- package/dist/main/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/module/CrowdViewWidget/Main.js +4 -2
- package/dist/module/CrowdViewWidget/Main.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js +9 -4
- package/dist/module/CrowdViewWidget/components/Chart/chartOptions.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js +3 -2
- package/dist/module/CrowdViewWidget/components/Chart/useCrowdViewData.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js +4 -1
- package/dist/module/CrowdViewWidget/components/Chart/utils/chartUtils.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js +4 -1
- package/dist/module/CrowdViewWidget/components/Legend/Legend.js.map +1 -1
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js +4 -2
- package/dist/module/CrowdViewWidget/components/Legend/LegendBar.js.map +1 -1
- package/dist/module/CrowdViewWidget/constants.js +9 -2
- package/dist/module/CrowdViewWidget/constants.js.map +1 -1
- package/dist/module/CrowdViewWidget/selectConfig.js +6 -6
- package/dist/module/CrowdViewWidget/selectConfig.js.map +1 -1
- package/dist/types/CrowdViewWidget/components/Chart/utils/chartUtils.d.ts +1 -1
- package/dist/types/CrowdViewWidget/components/Legend/Legend.d.ts +2 -1
- package/dist/types/CrowdViewWidget/components/Legend/LegendBar.d.ts +2 -1
- package/dist/types/CrowdViewWidget/constants.d.ts +8 -2
- package/package.json +3 -3
- package/src/CrowdViewWidget/Main.tsx +2 -2
- package/src/CrowdViewWidget/components/Chart/chartOptions.ts +15 -3
- package/src/CrowdViewWidget/components/Chart/useCrowdViewData.ts +6 -2
- package/src/CrowdViewWidget/components/Chart/utils/chartUtils.ts +11 -4
- package/src/CrowdViewWidget/components/Legend/Legend.tsx +4 -0
- package/src/CrowdViewWidget/components/Legend/LegendBar.tsx +4 -2
- package/src/CrowdViewWidget/constants.ts +10 -2
- package/src/CrowdViewWidget/selectConfig.ts +8 -8
- package/test/components/Chart/utils/chartUtils.test.ts +23 -6
- package/test/components/Legend.test.tsx +44 -0
- package/test/components/LegendBar.test.tsx +73 -2
|
@@ -7,7 +7,8 @@ export const Legend = _ref => {
|
|
|
7
7
|
let {
|
|
8
8
|
longValues = [BOOKS_THRESHOLDS.MIN, BOOKS_THRESHOLDS.MAX],
|
|
9
9
|
shortValues = [BOOKS_THRESHOLDS.MIN, BOOKS_THRESHOLDS.MAX],
|
|
10
|
-
bookType
|
|
10
|
+
bookType,
|
|
11
|
+
isDark
|
|
11
12
|
} = _ref;
|
|
12
13
|
const {
|
|
13
14
|
lang
|
|
@@ -15,10 +16,12 @@ export const Legend = _ref => {
|
|
|
15
16
|
return React.createElement("div", {
|
|
16
17
|
className: "lw-mx-auto lw-flex lw-w-full lw-flex-col lw-items-center lw-space-y-4 lw-pb-6 lw-pt-0 sm:lw-max-w-md lg:lw-max-w-xl"
|
|
17
18
|
}, React.createElement(LegendBar, {
|
|
19
|
+
isDark: isDark,
|
|
18
20
|
label: lang(bookType === BookType.Order ? 'buy' : 'long'),
|
|
19
21
|
type: "long",
|
|
20
22
|
values: longValues
|
|
21
23
|
}), React.createElement(LegendBar, {
|
|
24
|
+
isDark: isDark,
|
|
22
25
|
label: lang(bookType === BookType.Order ? 'sell' : 'short'),
|
|
23
26
|
type: "short",
|
|
24
27
|
values: shortValues
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.js","names":["useLocale","React","BookType","BOOKS_THRESHOLDS","LegendBar","Legend","_ref","longValues","MIN","MAX","shortValues","bookType","lang","createElement","className","label","Order","type","values"],"sources":["../../../../../src/CrowdViewWidget/components/Legend/Legend.tsx"],"sourcesContent":["import { useLocale } from '@oanda/mono-i18n';\nimport React from 'react';\n\nimport { BookType } from '../../../gql/types/graphql';\nimport { BOOKS_THRESHOLDS } from '../../constants';\nimport { LegendBar } from './LegendBar';\n\ninterface LegendProps {\n longValues?: [number, number];\n shortValues?: [number, number];\n bookType: BookType;\n}\n\nexport const Legend = ({\n longValues = [BOOKS_THRESHOLDS.MIN, BOOKS_THRESHOLDS.MAX],\n shortValues = [BOOKS_THRESHOLDS.MIN, BOOKS_THRESHOLDS.MAX],\n bookType,\n}: LegendProps) => {\n const { lang } = useLocale();\n\n return (\n <div className=\"lw-mx-auto lw-flex lw-w-full lw-flex-col lw-items-center lw-space-y-4 lw-pb-6 lw-pt-0 sm:lw-max-w-md lg:lw-max-w-xl\">\n <LegendBar\n label={lang(bookType === BookType.Order ? 'buy' : 'long')}\n type=\"long\"\n values={longValues}\n />\n <LegendBar\n label={lang(bookType === BookType.Order ? 'sell' : 'short')}\n type=\"short\"\n values={shortValues}\n />\n </div>\n );\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,QAAQ,QAAQ,4BAA4B;AACrD,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,SAAS,QAAQ,aAAa;
|
|
1
|
+
{"version":3,"file":"Legend.js","names":["useLocale","React","BookType","BOOKS_THRESHOLDS","LegendBar","Legend","_ref","longValues","MIN","MAX","shortValues","bookType","isDark","lang","createElement","className","label","Order","type","values"],"sources":["../../../../../src/CrowdViewWidget/components/Legend/Legend.tsx"],"sourcesContent":["import { useLocale } from '@oanda/mono-i18n';\nimport React from 'react';\n\nimport { BookType } from '../../../gql/types/graphql';\nimport { BOOKS_THRESHOLDS } from '../../constants';\nimport { LegendBar } from './LegendBar';\n\ninterface LegendProps {\n longValues?: [number, number];\n shortValues?: [number, number];\n bookType: BookType;\n isDark: boolean;\n}\n\nexport const Legend = ({\n longValues = [BOOKS_THRESHOLDS.MIN, BOOKS_THRESHOLDS.MAX],\n shortValues = [BOOKS_THRESHOLDS.MIN, BOOKS_THRESHOLDS.MAX],\n bookType,\n isDark,\n}: LegendProps) => {\n const { lang } = useLocale();\n\n return (\n <div className=\"lw-mx-auto lw-flex lw-w-full lw-flex-col lw-items-center lw-space-y-4 lw-pb-6 lw-pt-0 sm:lw-max-w-md lg:lw-max-w-xl\">\n <LegendBar\n isDark={isDark}\n label={lang(bookType === BookType.Order ? 'buy' : 'long')}\n type=\"long\"\n values={longValues}\n />\n <LegendBar\n isDark={isDark}\n label={lang(bookType === BookType.Order ? 'sell' : 'short')}\n type=\"short\"\n values={shortValues}\n />\n </div>\n );\n};\n"],"mappings":"AAAA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,OAAOC,KAAK,MAAM,OAAO;AAEzB,SAASC,QAAQ,QAAQ,4BAA4B;AACrD,SAASC,gBAAgB,QAAQ,iBAAiB;AAClD,SAASC,SAAS,QAAQ,aAAa;AASvC,OAAO,MAAMC,MAAM,GAAGC,IAAA,IAKH;EAAA,IALI;IACrBC,UAAU,GAAG,CAACJ,gBAAgB,CAACK,GAAG,EAAEL,gBAAgB,CAACM,GAAG,CAAC;IACzDC,WAAW,GAAG,CAACP,gBAAgB,CAACK,GAAG,EAAEL,gBAAgB,CAACM,GAAG,CAAC;IAC1DE,QAAQ;IACRC;EACW,CAAC,GAAAN,IAAA;EACZ,MAAM;IAAEO;EAAK,CAAC,GAAGb,SAAS,CAAC,CAAC;EAE5B,OACEC,KAAA,CAAAa,aAAA;IAAKC,SAAS,EAAC;EAAqH,GAClId,KAAA,CAAAa,aAAA,CAACV,SAAS;IACRQ,MAAM,EAAEA,MAAO;IACfI,KAAK,EAAEH,IAAI,CAACF,QAAQ,KAAKT,QAAQ,CAACe,KAAK,GAAG,KAAK,GAAG,MAAM,CAAE;IAC1DC,IAAI,EAAC,MAAM;IACXC,MAAM,EAAEZ;EAAW,CACpB,CAAC,EACFN,KAAA,CAAAa,aAAA,CAACV,SAAS;IACRQ,MAAM,EAAEA,MAAO;IACfI,KAAK,EAAEH,IAAI,CAACF,QAAQ,KAAKT,QAAQ,CAACe,KAAK,GAAG,MAAM,GAAG,OAAO,CAAE;IAC5DC,IAAI,EAAC,OAAO;IACZC,MAAM,EAAET;EAAY,CACrB,CACE,CAAC;AAEV,CAAC","ignoreList":[]}
|
|
@@ -4,9 +4,11 @@ export const LegendBar = _ref => {
|
|
|
4
4
|
let {
|
|
5
5
|
values,
|
|
6
6
|
type,
|
|
7
|
-
label
|
|
7
|
+
label,
|
|
8
|
+
isDark
|
|
8
9
|
} = _ref;
|
|
9
|
-
const
|
|
10
|
+
const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
|
|
11
|
+
const colors = type === 'long' ? colorPalette.long : colorPalette.short;
|
|
10
12
|
return React.createElement("div", {
|
|
11
13
|
className: "lw-flex lw-w-full lw-flex-col lw-space-y-1 lw-border-border-primary"
|
|
12
14
|
}, React.createElement("span", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LegendBar.js","names":["React","COLOR_MAP","LegendBar","_ref","values","type","label","colors","createElement","className","style","background","concat","toFixed"],"sources":["../../../../../src/CrowdViewWidget/components/Legend/LegendBar.tsx"],"sourcesContent":["import React from 'react';\n\nimport { COLOR_MAP } from '../../constants';\n\nexport type LegendType = 'long' | 'short';\n\ninterface LegendBarProps {\n values: number[];\n type: LegendType;\n label: string;\n}\n\nexport const LegendBar = ({ values, type, label }: LegendBarProps) => {\n const colors =
|
|
1
|
+
{"version":3,"file":"LegendBar.js","names":["React","COLOR_MAP","LegendBar","_ref","values","type","label","isDark","colorPalette","dark","light","colors","long","short","createElement","className","style","background","concat","toFixed"],"sources":["../../../../../src/CrowdViewWidget/components/Legend/LegendBar.tsx"],"sourcesContent":["import React from 'react';\n\nimport { COLOR_MAP } from '../../constants';\n\nexport type LegendType = 'long' | 'short';\n\ninterface LegendBarProps {\n values: number[];\n type: LegendType;\n label: string;\n isDark: boolean;\n}\n\nexport const LegendBar = ({ values, type, label, isDark }: LegendBarProps) => {\n const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;\n const colors = type === 'long' ? colorPalette.long : colorPalette.short;\n\n return (\n <div className=\"lw-flex lw-w-full lw-flex-col lw-space-y-1 lw-border-border-primary\">\n <span className=\"lw-whitespace-nowrap lw-font-sans lw-text-xs lw-text-text-primary\">\n {label}\n </span>\n <div className=\"lw-flex lw-h-2 lw-w-full lw-overflow-hidden lw-border lw-border-border-primary\">\n <div\n className=\"lw-h-full lw-flex-1\"\n data-testid=\"legend-bar-segment\"\n style={{\n background: `linear-gradient(90deg,${colors[0]} 0%, ${colors[1]} 100%)`,\n }}\n />\n </div>\n\n <div className=\"lw-flex lw-w-full lw-justify-between\">\n <span className=\"lw-whitespace-nowrap lw-font-sans lw-text-xs lw-text-text-primary\">\n {values[0].toFixed(2)}%\n </span>\n <span className=\"lw-whitespace-nowrap lw-font-sans lw-text-xs lw-text-text-primary\">\n {`≤ ${values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@
|
|
|
1
|
+
import { colorPalette } from '@oanda/labs-widget-common';
|
|
1
2
|
import { InstrumentId } from './types';
|
|
2
3
|
export const BOOKS_THRESHOLDS = {
|
|
3
4
|
MIN: 0.15,
|
|
@@ -21,8 +22,14 @@ export const CHART_CONFIG = {
|
|
|
21
22
|
X_AXIS_DATE_PADDING: ' '
|
|
22
23
|
};
|
|
23
24
|
export const COLOR_MAP = {
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
dark: {
|
|
26
|
+
long: [colorPalette.darkBlue10, colorPalette.darkBlue90],
|
|
27
|
+
short: [colorPalette.darkYellow10, colorPalette.darkYellow90]
|
|
28
|
+
},
|
|
29
|
+
light: {
|
|
30
|
+
long: [colorPalette.lightBlue10, colorPalette.lightBlue90],
|
|
31
|
+
short: [colorPalette.lightYellow10, colorPalette.lightYellow90]
|
|
32
|
+
}
|
|
26
33
|
};
|
|
27
34
|
export const INSTRUMENTS_CONFIG = {
|
|
28
35
|
[InstrumentId.EUR_AUD]: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["InstrumentId","BOOKS_THRESHOLDS","MIN","MAX","BUCKET_CONFIG","MULTIPLIER","PRICE_PADDING_MULTIPLIER","TIME_THRESHOLDS","TWO_WEEKS_MS","CHART_CONFIG","HEIGHT","WIDTH","X_LABEL_SIZE","Y_LABEL_SIZE_DESKTOP","Y_LABEL_SIZE_MOBILE","INITIAL_START_ZOOM","INITIAL_END_ZOOM","X_AXIS_DATE_PADDING","COLOR_MAP","long","short","INSTRUMENTS_CONFIG","EUR_AUD","mt5name","v20name","precision","defaultBucketWidth","EUR_GBP","EUR_JPY","EUR_USD","EUR_CHF","USD_CHF","USD_JPY","USD_CAD","GBP_USD","GBP_JPY","GBP_CHF","AUD_JPY","AUD_USD","NZD_USD","XAU_USD","XAG_USD"],"sources":["../../../src/CrowdViewWidget/constants.ts"],"sourcesContent":["import { InstrumentId } from './types';\n\nexport const BOOKS_THRESHOLDS = {\n MIN: 0.15,\n MAX: 0.55,\n} as const;\n\nexport const BUCKET_CONFIG = {\n MULTIPLIER: 4,\n PRICE_PADDING_MULTIPLIER: 2,\n} as const;\n\nexport const TIME_THRESHOLDS = {\n TWO_WEEKS_MS: 14 * 24 * 60 * 60 * 1000,\n} as const;\n\nexport const CHART_CONFIG = {\n HEIGHT: 425,\n WIDTH: 9999,\n X_LABEL_SIZE: 40,\n Y_LABEL_SIZE_DESKTOP: 60,\n Y_LABEL_SIZE_MOBILE: 40,\n INITIAL_START_ZOOM: 80,\n INITIAL_END_ZOOM: 100,\n X_AXIS_DATE_PADDING: ' ',\n} as const;\n\nexport const COLOR_MAP = {\n long: [
|
|
1
|
+
{"version":3,"file":"constants.js","names":["colorPalette","InstrumentId","BOOKS_THRESHOLDS","MIN","MAX","BUCKET_CONFIG","MULTIPLIER","PRICE_PADDING_MULTIPLIER","TIME_THRESHOLDS","TWO_WEEKS_MS","CHART_CONFIG","HEIGHT","WIDTH","X_LABEL_SIZE","Y_LABEL_SIZE_DESKTOP","Y_LABEL_SIZE_MOBILE","INITIAL_START_ZOOM","INITIAL_END_ZOOM","X_AXIS_DATE_PADDING","COLOR_MAP","dark","long","darkBlue10","darkBlue90","short","darkYellow10","darkYellow90","light","lightBlue10","lightBlue90","lightYellow10","lightYellow90","INSTRUMENTS_CONFIG","EUR_AUD","mt5name","v20name","precision","defaultBucketWidth","EUR_GBP","EUR_JPY","EUR_USD","EUR_CHF","USD_CHF","USD_JPY","USD_CAD","GBP_USD","GBP_JPY","GBP_CHF","AUD_JPY","AUD_USD","NZD_USD","XAU_USD","XAG_USD"],"sources":["../../../src/CrowdViewWidget/constants.ts"],"sourcesContent":["import { colorPalette } from '@oanda/labs-widget-common';\n\nimport { InstrumentId } from './types';\n\nexport const BOOKS_THRESHOLDS = {\n MIN: 0.15,\n MAX: 0.55,\n} as const;\n\nexport const BUCKET_CONFIG = {\n MULTIPLIER: 4,\n PRICE_PADDING_MULTIPLIER: 2,\n} as const;\n\nexport const TIME_THRESHOLDS = {\n TWO_WEEKS_MS: 14 * 24 * 60 * 60 * 1000,\n} as const;\n\nexport const CHART_CONFIG = {\n HEIGHT: 425,\n WIDTH: 9999,\n X_LABEL_SIZE: 40,\n Y_LABEL_SIZE_DESKTOP: 60,\n Y_LABEL_SIZE_MOBILE: 40,\n INITIAL_START_ZOOM: 80,\n INITIAL_END_ZOOM: 100,\n X_AXIS_DATE_PADDING: ' ',\n} as const;\n\nexport const COLOR_MAP = {\n dark: {\n long: [colorPalette.darkBlue10, colorPalette.darkBlue90],\n short: [colorPalette.darkYellow10, colorPalette.darkYellow90],\n },\n light: {\n long: [colorPalette.lightBlue10, colorPalette.lightBlue90],\n short: [colorPalette.lightYellow10, colorPalette.lightYellow90],\n },\n} as const;\n\nexport const INSTRUMENTS_CONFIG: Record<\n InstrumentId,\n {\n precision: number;\n defaultBucketWidth: number;\n v20name: string;\n mt5name: string;\n }\n> = {\n [InstrumentId.EUR_AUD]: {\n mt5name: 'EURAUD',\n v20name: 'EUR_AUD',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.EUR_GBP]: {\n mt5name: 'EURGBP',\n v20name: 'EUR_GBP',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.EUR_JPY]: {\n mt5name: 'EURJPY',\n v20name: 'EUR_JPY',\n precision: 3,\n defaultBucketWidth: 0.05,\n },\n [InstrumentId.EUR_USD]: {\n mt5name: 'EURUSD',\n v20name: 'EUR_USD',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.EUR_CHF]: {\n mt5name: 'EURCHF',\n v20name: 'EUR_CHF',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.USD_CHF]: {\n mt5name: 'USDCHF',\n v20name: 'USD_CHF',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.USD_JPY]: {\n mt5name: 'USDJPY',\n v20name: 'USD_JPY',\n precision: 3,\n defaultBucketWidth: 0.05,\n },\n [InstrumentId.USD_CAD]: {\n mt5name: 'USDCAD',\n v20name: 'USD_CAD',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.GBP_USD]: {\n mt5name: 'GBPUSD',\n v20name: 'GBP_USD',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.GBP_JPY]: {\n mt5name: 'GBPJPY',\n v20name: 'GBP_JPY',\n precision: 3,\n defaultBucketWidth: 0.05,\n },\n [InstrumentId.GBP_CHF]: {\n mt5name: 'GBPCHF',\n v20name: 'GBP_CHF',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.AUD_JPY]: {\n mt5name: 'AUDJPY',\n v20name: 'AUD_JPY',\n precision: 3,\n defaultBucketWidth: 0.05,\n },\n [InstrumentId.AUD_USD]: {\n mt5name: 'AUDUSD',\n v20name: 'AUD_USD',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.NZD_USD]: {\n mt5name: 'NZDUSD',\n v20name: 'NZD_USD',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n [InstrumentId.XAU_USD]: {\n mt5name: 'XAUUSD',\n v20name: 'XAU_USD',\n precision: 3,\n defaultBucketWidth: 0.5,\n },\n [InstrumentId.XAG_USD]: {\n mt5name: 'XAGUSD',\n v20name: 'XAG_USD',\n precision: 5,\n defaultBucketWidth: 0.0005,\n },\n};\n"],"mappings":"AAAA,SAASA,YAAY,QAAQ,2BAA2B;AAExD,SAASC,YAAY,QAAQ,SAAS;AAEtC,OAAO,MAAMC,gBAAgB,GAAG;EAC9BC,GAAG,EAAE,IAAI;EACTC,GAAG,EAAE;AACP,CAAU;AAEV,OAAO,MAAMC,aAAa,GAAG;EAC3BC,UAAU,EAAE,CAAC;EACbC,wBAAwB,EAAE;AAC5B,CAAU;AAEV,OAAO,MAAMC,eAAe,GAAG;EAC7BC,YAAY,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG;AACpC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B,CAAC;EACD,CAACpC,YAAY,CAACgD,OAAO,GAAG;IACtBf,OAAO,EAAE,QAAQ;IACjBC,OAAO,EAAE,SAAS;IAClBC,SAAS,EAAE,CAAC;IACZC,kBAAkB,EAAE;EACtB,CAAC;EACD,CAACpC,YAAY,CAACiD,OAAO,GAAG;IACtBhB,OAAO,EAAE,QAAQ;IACjBC,OAAO,EAAE,SAAS;IAClBC,SAAS,EAAE,CAAC;IACZC,kBAAkB,EAAE;EACtB,CAAC;EACD,CAACpC,YAAY,CAACkD,OAAO,GAAG;IACtBjB,OAAO,EAAE,QAAQ;IACjBC,OAAO,EAAE,SAAS;IAClBC,SAAS,EAAE,CAAC;IACZC,kBAAkB,EAAE;EACtB,CAAC;EACD,CAACpC,YAAY,CAACmD,OAAO,GAAG;IACtBlB,OAAO,EAAE,QAAQ;IACjBC,OAAO,EAAE,SAAS;IAClBC,SAAS,EAAE,CAAC;IACZC,kBAAkB,EAAE;EACtB;AACF,CAAC","ignoreList":[]}
|
|
@@ -58,17 +58,17 @@ const instrumentSelectConfig = [...instrumentSelectConfigOC, {
|
|
|
58
58
|
label: 'XAG/USD'
|
|
59
59
|
}];
|
|
60
60
|
const granularitySelectConfig = [{
|
|
61
|
-
id: Granularity.M5,
|
|
62
|
-
label: '5_minutes'
|
|
63
|
-
}, {
|
|
64
|
-
id: Granularity.M15,
|
|
65
|
-
label: '15_minutes'
|
|
66
|
-
}, {
|
|
67
61
|
id: Granularity.H1,
|
|
68
62
|
label: '1_hour'
|
|
69
63
|
}, {
|
|
70
64
|
id: Granularity.H4,
|
|
71
65
|
label: '4_hours'
|
|
66
|
+
}, {
|
|
67
|
+
id: Granularity.M5,
|
|
68
|
+
label: '5_minutes'
|
|
69
|
+
}, {
|
|
70
|
+
id: Granularity.M15,
|
|
71
|
+
label: '15_minutes'
|
|
72
72
|
}];
|
|
73
73
|
export { granularitySelectConfig, instrumentSelectConfig, instrumentSelectConfigOC, navigationConfig };
|
|
74
74
|
//# sourceMappingURL=selectConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectConfig.js","names":["BookType","Granularity","InstrumentId","navigationConfig","id","Order","label","Position","instrumentSelectConfigOC","EUR_AUD","EUR_GBP","EUR_JPY","EUR_USD","EUR_CHF","USD_CHF","USD_JPY","USD_CAD","GBP_USD","GBP_JPY","GBP_CHF","AUD_JPY","AUD_USD","NZD_USD","instrumentSelectConfig","XAU_USD","XAG_USD","granularitySelectConfig","
|
|
1
|
+
{"version":3,"file":"selectConfig.js","names":["BookType","Granularity","InstrumentId","navigationConfig","id","Order","label","Position","instrumentSelectConfigOC","EUR_AUD","EUR_GBP","EUR_JPY","EUR_USD","EUR_CHF","USD_CHF","USD_JPY","USD_CAD","GBP_USD","GBP_JPY","GBP_CHF","AUD_JPY","AUD_USD","NZD_USD","instrumentSelectConfig","XAU_USD","XAG_USD","granularitySelectConfig","H1","H4","M5","M15"],"sources":["../../../src/CrowdViewWidget/selectConfig.ts"],"sourcesContent":["import { BookType, Granularity } from '../gql/types/graphql';\nimport { InstrumentId } from './types';\n\nconst navigationConfig = [\n {\n id: BookType.Order,\n label: 'order_book',\n },\n {\n id: BookType.Position,\n label: 'position_book',\n },\n];\n\nconst instrumentSelectConfigOC = [\n {\n id: InstrumentId.EUR_AUD,\n label: 'EUR/AUD',\n },\n {\n id: InstrumentId.EUR_GBP,\n label: 'EUR/GBP',\n },\n {\n id: InstrumentId.EUR_JPY,\n label: 'EUR/JPY',\n },\n {\n id: InstrumentId.EUR_USD,\n label: 'EUR/USD',\n },\n {\n id: InstrumentId.EUR_CHF,\n label: 'EUR/CHF',\n },\n {\n id: InstrumentId.USD_CHF,\n label: 'USD/CHF',\n },\n {\n id: InstrumentId.USD_JPY,\n label: 'USD/JPY',\n },\n {\n id: InstrumentId.USD_CAD,\n label: 'USD/CAD',\n },\n {\n id: InstrumentId.GBP_USD,\n label: 'GBP/USD',\n },\n {\n id: InstrumentId.GBP_JPY,\n label: 'GBP/JPY',\n },\n {\n id: InstrumentId.GBP_CHF,\n label: 'GBP/CHF',\n },\n {\n id: InstrumentId.AUD_JPY,\n label: 'AUD/JPY',\n },\n {\n id: InstrumentId.AUD_USD,\n label: 'AUD/USD',\n },\n {\n id: InstrumentId.NZD_USD,\n label: 'NZD/USD',\n },\n];\n\nconst instrumentSelectConfig = [\n ...instrumentSelectConfigOC,\n {\n id: InstrumentId.XAU_USD,\n label: 'XAU/USD',\n },\n {\n id: InstrumentId.XAG_USD,\n label: 'XAG/USD',\n },\n];\n\nconst granularitySelectConfig = [\n {\n id: Granularity.H1,\n label: '1_hour',\n },\n {\n id: Granularity.H4,\n label: '4_hours',\n },\n {\n id: Granularity.M5,\n label: '5_minutes',\n },\n {\n id: Granularity.M15,\n label: '15_minutes',\n },\n];\n\nexport {\n granularitySelectConfig,\n instrumentSelectConfig,\n instrumentSelectConfigOC,\n navigationConfig,\n};\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,WAAW,QAAQ,sBAAsB;AAC5D,SAASC,YAAY,QAAQ,SAAS;AAEtC,MAAMC,gBAAgB,GAAG,CACvB;EACEC,EAAE,EAAEJ,QAAQ,CAACK,KAAK;EAClBC,KAAK,EAAE;AACT,CAAC,EACD;EACEF,EAAE,EAAEJ,QAAQ,CAACO,QAAQ;EACrBD,KAAK,EAAE;AACT,CAAC,CACF;AAED,MAAME,wBAAwB,GAAG,CAC/B;EACEJ,EAAE,EAAEF,YAAY,CAACO,OAAO;EACxBH,KAAK,EAAE;AACT,CAAC,EACD;EACEF,EAAE,EAAEF,YAAY,CAACQ,OAAO;EACxBJ,KAAK,EAAE;AACT,CAAC,EACD;EACEF,EAAE,EAAEF,YAAY,CAACS,OAAO;EACxBL,KAAK,EAAE;AACT,CAAC,EACD;EACEF,EAAE,EAAEF,YAAY,CAACU,OAAO;EACxBN,KAAK,EAAE;AACT,CAAC,EACD;EACEF,EAAE,EAAEF,YAAY,CAACW,OAAO;EACxBP,KAAK,EAAE;AACT,CAAC,EACD;EAC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BAAsB,EACtBf,wBAAwB,EACxBL,gBAAgB","ignoreList":[]}
|
|
@@ -18,7 +18,7 @@ export declare const getLabelData: ({ xAxisData, isGreaterThanTwoWeeks, }: GetLa
|
|
|
18
18
|
}[];
|
|
19
19
|
export declare const isDifferenceGreaterThanTwoWeeks: (startDate: string, endDate: string) => boolean;
|
|
20
20
|
export declare const getTimeSpanForGranularity: (granularity: Granularity) => TimeSpan;
|
|
21
|
-
export declare const getRectColor: (sentiment: number) => string;
|
|
21
|
+
export declare const getRectColor: (sentiment: number, isDark: boolean) => string;
|
|
22
22
|
export declare const getTooltipFormatter: ({ params, buckets, bucketWidth, selectedPrice, precision, bookType, labelCallback, }: {
|
|
23
23
|
params: unknown;
|
|
24
24
|
buckets: Bucket[][];
|
|
@@ -4,6 +4,7 @@ interface LegendProps {
|
|
|
4
4
|
longValues?: [number, number];
|
|
5
5
|
shortValues?: [number, number];
|
|
6
6
|
bookType: BookType;
|
|
7
|
+
isDark: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const Legend: ({ longValues, shortValues, bookType, }: LegendProps) => React.JSX.Element;
|
|
9
|
+
export declare const Legend: ({ longValues, shortValues, bookType, isDark, }: LegendProps) => React.JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -4,6 +4,7 @@ interface LegendBarProps {
|
|
|
4
4
|
values: number[];
|
|
5
5
|
type: LegendType;
|
|
6
6
|
label: string;
|
|
7
|
+
isDark: boolean;
|
|
7
8
|
}
|
|
8
|
-
export declare const LegendBar: ({ values, type, label }: LegendBarProps) => React.JSX.Element;
|
|
9
|
+
export declare const LegendBar: ({ values, type, label, isDark }: LegendBarProps) => React.JSX.Element;
|
|
9
10
|
export {};
|
|
@@ -21,8 +21,14 @@ export declare const CHART_CONFIG: {
|
|
|
21
21
|
readonly X_AXIS_DATE_PADDING: " ";
|
|
22
22
|
};
|
|
23
23
|
export declare const COLOR_MAP: {
|
|
24
|
-
readonly
|
|
25
|
-
|
|
24
|
+
readonly dark: {
|
|
25
|
+
readonly long: readonly [string, string];
|
|
26
|
+
readonly short: readonly [string, string];
|
|
27
|
+
};
|
|
28
|
+
readonly light: {
|
|
29
|
+
readonly long: readonly [string, string];
|
|
30
|
+
readonly short: readonly [string, string];
|
|
31
|
+
};
|
|
26
32
|
};
|
|
27
33
|
export declare const INSTRUMENTS_CONFIG: Record<InstrumentId, {
|
|
28
34
|
precision: number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oanda/labs-crowd-view-widget",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.49",
|
|
4
4
|
"description": "Labs Crowd View Widget",
|
|
5
5
|
"main": "dist/main/index.js",
|
|
6
6
|
"module": "dist/module/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"author": "OANDA",
|
|
14
14
|
"license": "UNLICENSED",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@oanda/labs-widget-common": "^1.0.
|
|
16
|
+
"@oanda/labs-widget-common": "^1.0.231",
|
|
17
17
|
"@oanda/mono-i18n": "10.0.1",
|
|
18
18
|
"chroma-js": "^3.1.2",
|
|
19
19
|
"decimal.js": "^10.6.0",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@graphql-codegen/client-preset": "4.1.0",
|
|
25
25
|
"@types/chroma-js": "^3.1.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "562750cf0dc3afe44417d6563fbca5553c675e7d"
|
|
28
28
|
}
|
|
@@ -17,7 +17,7 @@ import { getInstrumentConfigForDivision } from './utils/instrumentUtils';
|
|
|
17
17
|
|
|
18
18
|
const Main = ({ division }: MainProps) => {
|
|
19
19
|
const { lang } = useLocale();
|
|
20
|
-
const { size } = useLayoutProvider();
|
|
20
|
+
const { size, isDark } = useLayoutProvider();
|
|
21
21
|
const isDesktop = size === Size.DESKTOP;
|
|
22
22
|
|
|
23
23
|
const [bookType, setBookType] = useState(BookType.Order);
|
|
@@ -108,7 +108,7 @@ const Main = ({ division }: MainProps) => {
|
|
|
108
108
|
instrument={instrument.id}
|
|
109
109
|
/>
|
|
110
110
|
|
|
111
|
-
<Legend bookType={bookType} />
|
|
111
|
+
<Legend bookType={bookType} isDark={isDark} />
|
|
112
112
|
</div>
|
|
113
113
|
)}
|
|
114
114
|
</>
|
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
colorPalette,
|
|
3
3
|
getGridLines,
|
|
4
4
|
getLineCommons,
|
|
5
|
+
themeColors,
|
|
5
6
|
} from '@oanda/labs-widget-common';
|
|
6
7
|
|
|
7
8
|
import { CHART_CONFIG } from '../../constants';
|
|
@@ -71,6 +72,9 @@ export const getOption: GetOptionType = (
|
|
|
71
72
|
axisPointer: {
|
|
72
73
|
type: 'cross',
|
|
73
74
|
axis: 'x',
|
|
75
|
+
crossStyle: {
|
|
76
|
+
color: isDark ? colorPalette.orange : themeColors.borderPrimary.light,
|
|
77
|
+
},
|
|
74
78
|
label: {
|
|
75
79
|
formatter: (params) => {
|
|
76
80
|
if (params.axisDimension === 'y') {
|
|
@@ -137,8 +141,16 @@ export const getOption: GetOptionType = (
|
|
|
137
141
|
id: 'candlestick',
|
|
138
142
|
data: candlesSeriesData,
|
|
139
143
|
itemStyle: {
|
|
140
|
-
color: colorPalette.raspberryLight,
|
|
141
|
-
color0:
|
|
144
|
+
color: isDark ? colorPalette.orange : colorPalette.raspberryLight,
|
|
145
|
+
color0: isDark
|
|
146
|
+
? colorPalette.bottleGreenDark
|
|
147
|
+
: colorPalette.bottleGreenLight,
|
|
148
|
+
borderColor: isDark
|
|
149
|
+
? colorPalette.orange
|
|
150
|
+
: colorPalette.raspberryLight,
|
|
151
|
+
borderColor0: isDark
|
|
152
|
+
? colorPalette.bottleGreenDark
|
|
153
|
+
: colorPalette.bottleGreenLight,
|
|
142
154
|
},
|
|
143
155
|
|
|
144
156
|
markPoint: {
|
|
@@ -175,7 +187,7 @@ export const getOption: GetOptionType = (
|
|
|
175
187
|
height: rectHeight,
|
|
176
188
|
},
|
|
177
189
|
style: {
|
|
178
|
-
fill: getRectColor(sentiment),
|
|
190
|
+
fill: getRectColor(sentiment, isDark),
|
|
179
191
|
},
|
|
180
192
|
silent: true,
|
|
181
193
|
emphasisDisabled: true,
|
|
@@ -27,6 +27,10 @@ export const useCrowdViewData = ({
|
|
|
27
27
|
division,
|
|
28
28
|
granularity,
|
|
29
29
|
}: UseCrowdViewDataProps): UseCrowdViewDataReturn => {
|
|
30
|
+
const dataSource =
|
|
31
|
+
division === Division.Ogm || division === Division.Oj
|
|
32
|
+
? DataSource.Mt5
|
|
33
|
+
: DataSource.V20;
|
|
30
34
|
const {
|
|
31
35
|
loading: priceCandlesLoading,
|
|
32
36
|
data: priceCandlesData,
|
|
@@ -35,10 +39,10 @@ export const useCrowdViewData = ({
|
|
|
35
39
|
getPriceCandles,
|
|
36
40
|
{
|
|
37
41
|
variables: {
|
|
38
|
-
dataSource
|
|
42
|
+
dataSource,
|
|
39
43
|
division,
|
|
40
44
|
instrument:
|
|
41
|
-
|
|
45
|
+
dataSource === DataSource.Mt5
|
|
42
46
|
? INSTRUMENTS_CONFIG[instrument].mt5name
|
|
43
47
|
: INSTRUMENTS_CONFIG[instrument].v20name,
|
|
44
48
|
granularity,
|
|
@@ -87,10 +87,17 @@ const getGradientColor = (
|
|
|
87
87
|
return colorScale(value).hex();
|
|
88
88
|
};
|
|
89
89
|
|
|
90
|
-
export const getRectColor = (sentiment: number) =>
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
export const getRectColor = (sentiment: number, isDark: boolean) => {
|
|
91
|
+
const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
|
|
92
|
+
|
|
93
|
+
return sentiment < 0
|
|
94
|
+
? getGradientColor(
|
|
95
|
+
sentiment * -1,
|
|
96
|
+
colorPalette.short[0],
|
|
97
|
+
colorPalette.short[1]
|
|
98
|
+
)
|
|
99
|
+
: getGradientColor(sentiment, colorPalette.long[0], colorPalette.long[1]);
|
|
100
|
+
};
|
|
94
101
|
|
|
95
102
|
export const getTooltipFormatter = ({
|
|
96
103
|
params,
|
|
@@ -9,23 +9,27 @@ interface LegendProps {
|
|
|
9
9
|
longValues?: [number, number];
|
|
10
10
|
shortValues?: [number, number];
|
|
11
11
|
bookType: BookType;
|
|
12
|
+
isDark: boolean;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export const Legend = ({
|
|
15
16
|
longValues = [BOOKS_THRESHOLDS.MIN, BOOKS_THRESHOLDS.MAX],
|
|
16
17
|
shortValues = [BOOKS_THRESHOLDS.MIN, BOOKS_THRESHOLDS.MAX],
|
|
17
18
|
bookType,
|
|
19
|
+
isDark,
|
|
18
20
|
}: LegendProps) => {
|
|
19
21
|
const { lang } = useLocale();
|
|
20
22
|
|
|
21
23
|
return (
|
|
22
24
|
<div className="lw-mx-auto lw-flex lw-w-full lw-flex-col lw-items-center lw-space-y-4 lw-pb-6 lw-pt-0 sm:lw-max-w-md lg:lw-max-w-xl">
|
|
23
25
|
<LegendBar
|
|
26
|
+
isDark={isDark}
|
|
24
27
|
label={lang(bookType === BookType.Order ? 'buy' : 'long')}
|
|
25
28
|
type="long"
|
|
26
29
|
values={longValues}
|
|
27
30
|
/>
|
|
28
31
|
<LegendBar
|
|
32
|
+
isDark={isDark}
|
|
29
33
|
label={lang(bookType === BookType.Order ? 'sell' : 'short')}
|
|
30
34
|
type="short"
|
|
31
35
|
values={shortValues}
|
|
@@ -8,10 +8,12 @@ interface LegendBarProps {
|
|
|
8
8
|
values: number[];
|
|
9
9
|
type: LegendType;
|
|
10
10
|
label: string;
|
|
11
|
+
isDark: boolean;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
export const LegendBar = ({ values, type, label }: LegendBarProps) => {
|
|
14
|
-
const
|
|
14
|
+
export const LegendBar = ({ values, type, label, isDark }: LegendBarProps) => {
|
|
15
|
+
const colorPalette = isDark ? COLOR_MAP.dark : COLOR_MAP.light;
|
|
16
|
+
const colors = type === 'long' ? colorPalette.long : colorPalette.short;
|
|
15
17
|
|
|
16
18
|
return (
|
|
17
19
|
<div className="lw-flex lw-w-full lw-flex-col lw-space-y-1 lw-border-border-primary">
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { colorPalette } from '@oanda/labs-widget-common';
|
|
2
|
+
|
|
1
3
|
import { InstrumentId } from './types';
|
|
2
4
|
|
|
3
5
|
export const BOOKS_THRESHOLDS = {
|
|
@@ -26,8 +28,14 @@ export const CHART_CONFIG = {
|
|
|
26
28
|
} as const;
|
|
27
29
|
|
|
28
30
|
export const COLOR_MAP = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
dark: {
|
|
32
|
+
long: [colorPalette.darkBlue10, colorPalette.darkBlue90],
|
|
33
|
+
short: [colorPalette.darkYellow10, colorPalette.darkYellow90],
|
|
34
|
+
},
|
|
35
|
+
light: {
|
|
36
|
+
long: [colorPalette.lightBlue10, colorPalette.lightBlue90],
|
|
37
|
+
short: [colorPalette.lightYellow10, colorPalette.lightYellow90],
|
|
38
|
+
},
|
|
31
39
|
} as const;
|
|
32
40
|
|
|
33
41
|
export const INSTRUMENTS_CONFIG: Record<
|
|
@@ -84,14 +84,6 @@ const instrumentSelectConfig = [
|
|
|
84
84
|
];
|
|
85
85
|
|
|
86
86
|
const granularitySelectConfig = [
|
|
87
|
-
{
|
|
88
|
-
id: Granularity.M5,
|
|
89
|
-
label: '5_minutes',
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
id: Granularity.M15,
|
|
93
|
-
label: '15_minutes',
|
|
94
|
-
},
|
|
95
87
|
{
|
|
96
88
|
id: Granularity.H1,
|
|
97
89
|
label: '1_hour',
|
|
@@ -100,6 +92,14 @@ const granularitySelectConfig = [
|
|
|
100
92
|
id: Granularity.H4,
|
|
101
93
|
label: '4_hours',
|
|
102
94
|
},
|
|
95
|
+
{
|
|
96
|
+
id: Granularity.M5,
|
|
97
|
+
label: '5_minutes',
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
id: Granularity.M15,
|
|
101
|
+
label: '15_minutes',
|
|
102
|
+
},
|
|
103
103
|
];
|
|
104
104
|
|
|
105
105
|
export {
|
|
@@ -48,20 +48,37 @@ describe('chartUtils', () => {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
describe('getRectColor', () => {
|
|
51
|
-
it('uses long color scale for positive sentiment', () => {
|
|
52
|
-
const color = getRectColor(BOOKS_THRESHOLDS.MAX);
|
|
51
|
+
it('uses long color scale for positive sentiment in light mode', () => {
|
|
52
|
+
const color = getRectColor(BOOKS_THRESHOLDS.MAX, false);
|
|
53
53
|
expect(typeof color).toBe('string');
|
|
54
54
|
// At max threshold, should be at or near target color
|
|
55
55
|
expect(color.toLowerCase()).toContain(
|
|
56
|
-
COLOR_MAP.long[1].slice(1).toLowerCase().substring(0, 3)
|
|
56
|
+
COLOR_MAP.light.long[1].slice(1).toLowerCase().substring(0, 3)
|
|
57
57
|
);
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
-
it('uses short color scale for negative sentiment', () => {
|
|
61
|
-
const color = getRectColor(-BOOKS_THRESHOLDS.MAX);
|
|
60
|
+
it('uses short color scale for negative sentiment in light mode', () => {
|
|
61
|
+
const color = getRectColor(-BOOKS_THRESHOLDS.MAX, false);
|
|
62
62
|
expect(typeof color).toBe('string');
|
|
63
63
|
expect(color.toLowerCase()).toContain(
|
|
64
|
-
COLOR_MAP.short[1].slice(1).toLowerCase().substring(0, 3)
|
|
64
|
+
COLOR_MAP.light.short[1].slice(1).toLowerCase().substring(0, 3)
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('uses long color scale for positive sentiment in dark mode', () => {
|
|
69
|
+
const color = getRectColor(BOOKS_THRESHOLDS.MAX, true);
|
|
70
|
+
expect(typeof color).toBe('string');
|
|
71
|
+
// At max threshold, should be at or near target color
|
|
72
|
+
expect(color.toLowerCase()).toContain(
|
|
73
|
+
COLOR_MAP.dark.long[1].slice(1).toLowerCase().substring(0, 3)
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('uses short color scale for negative sentiment in dark mode', () => {
|
|
78
|
+
const color = getRectColor(-BOOKS_THRESHOLDS.MAX, true);
|
|
79
|
+
expect(typeof color).toBe('string');
|
|
80
|
+
expect(color.toLowerCase()).toContain(
|
|
81
|
+
COLOR_MAP.dark.short[1].slice(1).toLowerCase().substring(0, 3)
|
|
65
82
|
);
|
|
66
83
|
});
|
|
67
84
|
});
|
|
@@ -6,6 +6,7 @@ import { render } from '@testing-library/react';
|
|
|
6
6
|
import React from 'react';
|
|
7
7
|
|
|
8
8
|
import { Legend } from '../../src/CrowdViewWidget/components';
|
|
9
|
+
import { COLOR_MAP } from '../../src/CrowdViewWidget/constants';
|
|
9
10
|
import { BookType } from '../../src/gql/types/graphql';
|
|
10
11
|
|
|
11
12
|
describe('Crowd View Widget', () => {
|
|
@@ -15,6 +16,7 @@ describe('Crowd View Widget', () => {
|
|
|
15
16
|
const { getAllByText } = render(
|
|
16
17
|
<Legend
|
|
17
18
|
bookType={BookType.Position}
|
|
19
|
+
isDark={false}
|
|
18
20
|
longValues={[0.15, 0.55]}
|
|
19
21
|
shortValues={[0.15, 0.55]}
|
|
20
22
|
/>
|
|
@@ -23,6 +25,48 @@ describe('Crowd View Widget', () => {
|
|
|
23
25
|
expect(getAllByText(/long/)).toHaveLength(1);
|
|
24
26
|
expect(getAllByText(/short/)).toHaveLength(1);
|
|
25
27
|
});
|
|
28
|
+
|
|
29
|
+
it('passes isDark prop to LegendBar components in light mode', () => {
|
|
30
|
+
const { getAllByTestId } = render(
|
|
31
|
+
<Legend
|
|
32
|
+
bookType={BookType.Position}
|
|
33
|
+
isDark={false}
|
|
34
|
+
longValues={[0.15, 0.55]}
|
|
35
|
+
shortValues={[0.15, 0.55]}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
const segments = getAllByTestId('legend-bar-segment');
|
|
39
|
+
expect(segments.length).toBe(2);
|
|
40
|
+
// Check that segments use light mode colors (either long or short)
|
|
41
|
+
const styles = segments.map((segment) => segment.getAttribute('style'));
|
|
42
|
+
const hasLightColors = styles.some(
|
|
43
|
+
(style) =>
|
|
44
|
+
style?.includes(COLOR_MAP.light.long[0]) ||
|
|
45
|
+
style?.includes(COLOR_MAP.light.short[0])
|
|
46
|
+
);
|
|
47
|
+
expect(hasLightColors).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('passes isDark prop to LegendBar components in dark mode', () => {
|
|
51
|
+
const { getAllByTestId } = render(
|
|
52
|
+
<Legend
|
|
53
|
+
bookType={BookType.Position}
|
|
54
|
+
isDark={true}
|
|
55
|
+
longValues={[0.15, 0.55]}
|
|
56
|
+
shortValues={[0.15, 0.55]}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
const segments = getAllByTestId('legend-bar-segment');
|
|
60
|
+
expect(segments.length).toBe(2);
|
|
61
|
+
// Check that segments use dark mode colors (either long or short)
|
|
62
|
+
const styles = segments.map((segment) => segment.getAttribute('style'));
|
|
63
|
+
const hasDarkColors = styles.some(
|
|
64
|
+
(style) =>
|
|
65
|
+
style?.includes(COLOR_MAP.dark.long[0]) ||
|
|
66
|
+
style?.includes(COLOR_MAP.dark.short[0])
|
|
67
|
+
);
|
|
68
|
+
expect(hasDarkColors).toBe(true);
|
|
69
|
+
});
|
|
26
70
|
});
|
|
27
71
|
});
|
|
28
72
|
});
|