vega-frontend-monorepo/libs/react-helpers/src/lib/grid/cell-class-rules.ts
Bartłomiej Głownia 6de90c6b1f
feat(): update positions tab ()
* feat(): add positions metrics data provider

* feat() add positions stats

* feat() add positions stats

* feat(): add positions stats

* feat(): add positions stats

* feat(): position metrics, test and refactoring

* feat(): add unit tests to positions table

* feat(): fix spelling, order positions by updated at desc

* feat(): protect from division by 0

* feat(): fix trading positions e2e tests

* feat(): fix e2e data mocks

* feat(): post code review clean up

* feat(): dependencies handling in data provider

* feat(): fix e2e tests data mocks

* feat(): remove position metrics mocks, add market data market id

* feat(): add missing mocks, fix combine function

* feat(): set loading initially to true, add unit tests

* feat(): cleanup, add comments

* feat(): remove undefined from client type

* feat(): cosmetic changes

* feat(): update positions tab

* feat:(): pass informaton about update callback cause

* feat(): update positions tab

* feat(): update positions tab

* feat(): update positions tab

* chore: skip handles 5000 markets e2e test

* feat(): update positions tab

* feat(): rename assetDecimals to decimals

* feat(): close position

* feat(): notify about update

* feat(): add use close position hook

* feat(): do not show 0 volume positions, make liquidation price minimum 0

* feat(): post code review fixes and improvments

* feat: fix fill-table spec
2022-09-02 13:53:00 -07:00

24 lines
802 B
TypeScript

export const positiveClassNames = 'text-vega-green-dark dark:text-vega-green';
export const negativeClassNames = 'text-vega-red-dark dark:text-vega-red';
const isPositive = ({ value }: { value: string | bigint | number }) =>
value && ((typeof value === 'string' && !value.startsWith('-')) || value > 0);
const isNegative = ({ value }: { value: string | bigint | number }) =>
value && ((typeof value === 'string' && value.startsWith('-')) || value < 0);
export const signedNumberCssClass = (value: string | bigint | number) => {
if (isPositive({ value })) {
return positiveClassNames;
}
if (isNegative({ value })) {
return negativeClassNames;
}
return '';
};
export const signedNumberCssClassRules = {
[positiveClassNames]: isPositive,
[negativeClassNames]: isNegative,
};