From 78afecc2e51409f3973b20450d09e5b2e75d23e5 Mon Sep 17 00:00:00 2001 From: Matthew Russell Date: Fri, 15 Sep 2023 05:24:47 -0700 Subject: [PATCH] chore(trading): layout adjustments to accomodate default 13 inch screens (#4798) --- .../client-pages/market/trade-grid.tsx | 4 +- .../layouts/layout-with-sidebar.tsx | 3 +- apps/trading/pages/styles.css | 24 ++++--- libs/candles-chart/src/lib/candles-chart.tsx | 62 ++++++++++--------- .../src/lib/use-candles-chart-settings.ts | 2 +- 5 files changed, 54 insertions(+), 41 deletions(-) diff --git a/apps/trading/client-pages/market/trade-grid.tsx b/apps/trading/client-pages/market/trade-grid.tsx index 39a2e4723..79433a3b1 100644 --- a/apps/trading/client-pages/market/trade-grid.tsx +++ b/apps/trading/client-pages/market/trade-grid.tsx @@ -73,7 +73,7 @@ const MainGrid = memo( @@ -181,7 +181,7 @@ const TradeGridChild = ({ children }: TradeGridChildProps) => { {({ width, height }) => (
{children}
diff --git a/apps/trading/components/layouts/layout-with-sidebar.tsx b/apps/trading/components/layouts/layout-with-sidebar.tsx index e9558833f..d8c3a461e 100644 --- a/apps/trading/components/layouts/layout-with-sidebar.tsx +++ b/apps/trading/components/layouts/layout-with-sidebar.tsx @@ -13,7 +13,8 @@ export const LayoutWithSidebar = () => { 'h-full relative z-0 grid', 'grid-rows-[min-content_1fr_40px]', 'lg:grid-rows-[min-content_1fr]', - 'lg:grid-cols-[1fr_350px_40px]' + 'lg:grid-cols-[1fr_280px_40px]', + 'xxxl:grid-cols-[1fr_320px_40px]' ); return ( diff --git a/apps/trading/pages/styles.css b/apps/trading/pages/styles.css index e4e2d4659..7d4f32462 100644 --- a/apps/trading/pages/styles.css +++ b/apps/trading/pages/styles.css @@ -83,8 +83,7 @@ html [data-theme='light'] { --pennant-color-volume-sell: theme(colors.market.red.DEFAULT); /* reduce space between candles */ - --pennant-candlestick-inner-padding: 0.175; - --pennant-candlestick-stroke-width: 0.5; + --pennant-candlestick-inner-padding: 0.25; } html [data-theme='light'] { @@ -162,11 +161,22 @@ html [data-theme='dark'] { @apply font-normal font-alpha; } -/* Light variables */ -.ag-theme-balham { +.ag-theme-balham, +.ag-theme-balham-dark { --ag-grid-size: 2px; /* Used for compactness */ --ag-row-height: 36px; - --ag-header-height: 36px; + --ag-header-height: 28px; +} + +@media (min-width: theme(screens.xxl)) { + .ag-theme-balham, + .ag-theme-balham-dark { + --ag-header-height: 36px; + } +} + +/* Light variables */ +.ag-theme-balham { --ag-background-color: theme(colors.white); --ag-border-color: theme(colors.vega.clight.600); --ag-header-background-color: theme(colors.vega.clight.700); @@ -179,9 +189,6 @@ html [data-theme='dark'] { /* Dark variables */ .ag-theme-balham-dark { - --ag-grid-size: 2px; /* Used for compactness */ - --ag-row-height: 36px; - --ag-header-height: 36px; --ag-background-color: theme(colors.vega.cdark.900); --ag-border-color: theme(colors.vega.cdark.600); --ag-header-background-color: theme(colors.vega.cdark.700); @@ -191,6 +198,7 @@ html [data-theme='dark'] { --ag-row-hover-color: theme(colors.vega.cdark.800); --ag-modal-overlay-background-color: rgb(9 11 16 / 50%); } + .ag-theme-balham-dark .ag-row.no-hover, .ag-theme-balham-dark .ag-row.no-hover:hover, .ag-theme-balham .ag-row.no-hover, diff --git a/libs/candles-chart/src/lib/candles-chart.tsx b/libs/candles-chart/src/lib/candles-chart.tsx index c0397f681..aeb1e4091 100644 --- a/libs/candles-chart/src/lib/candles-chart.tsx +++ b/libs/candles-chart/src/lib/candles-chart.tsx @@ -8,13 +8,16 @@ import AutoSizer from 'react-virtualized-auto-sizer'; import { useVegaWallet } from '@vegaprotocol/wallet'; import { useThemeSwitcher } from '@vegaprotocol/react-helpers'; import { t } from '@vegaprotocol/i18n'; -import { useCandlesChartSettings } from './use-candles-chart-settings'; +import { + STUDY_SIZE, + useCandlesChartSettings, +} from './use-candles-chart-settings'; export type CandlesChartContainerProps = { marketId: string; }; -const CANDLES_TO_WIDTH_FACTOR = 0.15; +const CANDLES_TO_WIDTH_FACTOR = 0.2; export const CandlesChartContainer = ({ marketId, @@ -49,33 +52,34 @@ export const CandlesChartContainer = ({ return ( - {({ width, height }) => ( -
- {t('No data')} - ), - initialNumCandlesToDisplay: Math.floor( - width * CANDLES_TO_WIDTH_FACTOR - ), - studySize: 150, // default size - studySizes, - }} - interval={interval} - theme={theme} - onOptionsChanged={(options) => { - setStudies(options.studies); - setOverlays(options.overlays); - }} - onPaneChanged={handlePaneChange} - /> -
- )} + {({ width, height }) => { + const candlesCount = Math.floor(width * CANDLES_TO_WIDTH_FACTOR); + return ( +
+ {t('No data')} + ), + initialNumCandlesToDisplay: candlesCount, + studySize: STUDY_SIZE, + studySizes, + }} + interval={interval} + theme={theme} + onOptionsChanged={(options) => { + setStudies(options.studies); + setOverlays(options.overlays); + }} + onPaneChanged={handlePaneChange} + /> +
+ ); + }}
); }; diff --git a/libs/candles-chart/src/lib/use-candles-chart-settings.ts b/libs/candles-chart/src/lib/use-candles-chart-settings.ts index c43ab4732..053101892 100644 --- a/libs/candles-chart/src/lib/use-candles-chart-settings.ts +++ b/libs/candles-chart/src/lib/use-candles-chart-settings.ts @@ -15,7 +15,7 @@ interface StoredSettings { studySizes: StudySizes; } -export const STUDY_SIZE = 100; +export const STUDY_SIZE = 90; const STUDY_ORDER: Study[] = [ Study.FORCE_INDEX, Study.RELATIVE_STRENGTH_INDEX,