From 00083149e885c6b5d3e9279083abd94885a471df Mon Sep 17 00:00:00 2001 From: Andrei Zhaleznichenka Date: Thu, 20 Jul 2023 14:54:36 +0200 Subject: [PATCH] experiment: conditional fit-height containers --- .../cartesian-chart/chart-container.tsx | 42 ++++++--- .../components/cartesian-chart/styles.scss | 6 -- .../components/chart-wrapper/index.tsx | 89 ++++++++++++------- .../components/chart-wrapper/styles.scss | 2 - 4 files changed, 87 insertions(+), 52 deletions(-) diff --git a/src/internal/components/cartesian-chart/chart-container.tsx b/src/internal/components/cartesian-chart/chart-container.tsx index 0730c08447..87d5879d47 100644 --- a/src/internal/components/cartesian-chart/chart-container.tsx +++ b/src/internal/components/cartesian-chart/chart-container.tsx @@ -30,23 +30,43 @@ export const CartesianChartContainer = forwardRef( }: CartesianChartContainerProps, ref: React.Ref ) => { - const withFitHeight = (className: string) => clsx(className, fitHeight && styles['fit-height']); + if (fitHeight) { + return ( +
+ {leftAxisLabel} + +
+ {leftAxisLabelMeasure} + +
+
+
{chartPlot}
+
+ +
+ {bottomAxisLabel} +
+
+ + {popover} +
+
+ ); + } + return ( -
+
{leftAxisLabel} -
+
{leftAxisLabelMeasure}
-
-
{chartPlot}
-
- -
{bottomAxisLabel}
+ {chartPlot} + {bottomAxisLabel}
{popover} diff --git a/src/internal/components/cartesian-chart/styles.scss b/src/internal/components/cartesian-chart/styles.scss index 7118cd273a..290397bb2b 100644 --- a/src/internal/components/cartesian-chart/styles.scss +++ b/src/internal/components/cartesian-chart/styles.scss @@ -137,8 +137,6 @@ } .chart-container-plot-wrapper { - display: contents; - &.fit-height { display: block; position: relative; @@ -147,8 +145,6 @@ } .chart-container-plot { - display: contents; - &.fit-height { display: block; position: absolute; @@ -160,8 +156,6 @@ } .chart-container-bottom-labels { - display: contents; - &.fit-height { display: block; } diff --git a/src/internal/components/chart-wrapper/index.tsx b/src/internal/components/chart-wrapper/index.tsx index 97c1ed75b6..4afd054439 100644 --- a/src/internal/components/chart-wrapper/index.tsx +++ b/src/internal/components/chart-wrapper/index.tsx @@ -42,43 +42,66 @@ export const ChartWrapper = forwardRef( ref: React.Ref ) => { const baseProps = getBaseProps(props); - return ( -
-
- {(defaultFilter || additionalFilters) && ( - - - {defaultFilter} - {additionalFilters} - - - )} -
- {chartStatus} - {chart} + const filtersNode = (defaultFilter || additionalFilters) && ( + + + {defaultFilter} + {additionalFilters} + + + ); + + const legendNode = legend && {legend}; + + if (fitHeight) { + return ( +
+
+ {filtersNode} + +
+ {chartStatus} + {chart} +
+ + {legendNode}
+
+ ); + } - {legend && {legend}} + return ( +
+ {filtersNode} + +
+ {chartStatus} + {chart}
+ + {legendNode}
); } diff --git a/src/internal/components/chart-wrapper/styles.scss b/src/internal/components/chart-wrapper/styles.scss index caef6ad956..ccb773ce04 100644 --- a/src/internal/components/chart-wrapper/styles.scss +++ b/src/internal/components/chart-wrapper/styles.scss @@ -18,8 +18,6 @@ } .inner-wrapper { - display: contents; - &--fit-height { display: flex; flex-direction: column;