From 3422b9949147b8d8c02f596073bbef78393c171f Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Fri, 25 Aug 2023 15:24:57 -0700 Subject: [PATCH] feat(trading): change to system monospace font (#4634) --- apps/trading/pages/styles.css | 6 ++- .../last-24h-price-change.tsx | 51 ++++++++++++++++--- libs/tailwindcss-config/src/theme.js | 16 +++++- 3 files changed, 64 insertions(+), 9 deletions(-) diff --git a/apps/trading/pages/styles.css b/apps/trading/pages/styles.css index 5b64552b8..17d403b9e 100644 --- a/apps/trading/pages/styles.css +++ b/apps/trading/pages/styles.css @@ -15,6 +15,10 @@ body, @apply h-full; } +.font-mono { + @apply tracking-tighter; +} + .text-default { @apply text-vega-clight-50 dark:text-vega-cdark-50; } @@ -147,7 +151,7 @@ html [data-theme='dark'] { } .vega-ag-grid .ag-header-row { - @apply font-alpha font-normal; + @apply font-normal font-alpha; } /* Light variables */ diff --git a/libs/markets/src/lib/components/last-24h-price-change/last-24h-price-change.tsx b/libs/markets/src/lib/components/last-24h-price-change/last-24h-price-change.tsx index 9d2ae2347..aff79d012 100644 --- a/libs/markets/src/lib/components/last-24h-price-change/last-24h-price-change.tsx +++ b/libs/markets/src/lib/components/last-24h-price-change/last-24h-price-change.tsx @@ -1,8 +1,16 @@ -import { isNumeric } from '@vegaprotocol/utils'; -import { PriceChangeCell } from '@vegaprotocol/datagrid'; -import { Tooltip } from '@vegaprotocol/ui-toolkit'; +import { + addDecimalsFormatNumber, + formatNumberPercentage, + isNumeric, + priceChange, + priceChangePercentage, +} from '@vegaprotocol/utils'; +import { PriceChangeCell, signedNumberCssClass } from '@vegaprotocol/datagrid'; +import { Tooltip, VegaIcon, VegaIconNames } from '@vegaprotocol/ui-toolkit'; import { t } from '@vegaprotocol/i18n'; import { useCandles } from '../../hooks/use-candles'; +import BigNumber from 'bignumber.js'; +import classNames from 'classnames'; interface Props { marketId?: string; @@ -47,10 +55,39 @@ export const Last24hPriceChange = ({ if (error || !isNumeric(decimalPlaces)) { return -; } + + const candles = oneDayCandles?.map((c) => c.close) || initialValue || []; + const change = priceChange(candles); + const changePercentage = priceChangePercentage(candles); + return ( - c.close) || initialValue || []} - decimalPlaces={decimalPlaces} - /> + + + + {formatNumberPercentage(new BigNumber(changePercentage.toString()), 2)} + + + {addDecimalsFormatNumber(change.toString(), decimalPlaces ?? 0, 3)} + + ); }; + +const Arrow = ({ value }: { value: number | bigint }) => { + const size = 10; + + if (value > 0) { + return ; + } + + if (value < 0) { + return ; + } + + return null; +}; diff --git a/libs/tailwindcss-config/src/theme.js b/libs/tailwindcss-config/src/theme.js index 111b0bf0f..28b041988 100644 --- a/libs/tailwindcss-config/src/theme.js +++ b/libs/tailwindcss-config/src/theme.js @@ -177,7 +177,21 @@ module.exports = { success: '#00F780', }, fontFamily: { - mono: ['Roboto Mono', 'monospace'], + mono: [ + 'ui-monospace', + 'Menlo', + 'Monaco', + 'Cascadia Mono', + 'Segoe UI Mono', + 'Roboto Mono', + 'Oxygen Mono', + 'Ubuntu Monospace', + 'Source Code Pro', + 'Fira Mono', + 'Droid Sans Mono', + 'Courier New', + 'monospace', + ], sans: [ '"Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"', ],