Skip to content

Commit f77dbd3

Browse files
Address feedback
1 parent af7f3ea commit f77dbd3

File tree

2 files changed

+17
-37
lines changed

2 files changed

+17
-37
lines changed

packages/x-charts-pro/src/ChartZoomSlider/internals/ChartAxisZoomSlider.tsx

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ import {
1818
import { styled } from '@mui/material/styles';
1919
import { useXAxes, useYAxes } from '@mui/x-charts/hooks';
2020
import { rafThrottle } from '@mui/x-internals/rafThrottle';
21-
import clsx from 'clsx';
2221
import { shouldForwardProp } from '@mui/system';
23-
import { chartAxisZoomSliderTrackClasses } from './chartAxisZoomSliderTrackClasses';
2422
import { ChartsTooltipZoomSliderValue } from './ChartsTooltipZoomSliderValue';
2523
import {
2624
selectorChartAxisZoomData,
@@ -29,27 +27,25 @@ import {
2927
import { ChartAxisZoomSliderThumb } from './ChartAxisZoomSliderThumb';
3028

3129
const ZoomSliderTrack = styled('rect', {
32-
shouldForwardProp: (prop) => shouldForwardProp(prop) && prop !== 'axisDirection',
33-
})<{ axisDirection: 'x' | 'y' }>(({ theme }) => ({
34-
[`&.${chartAxisZoomSliderTrackClasses.root}`]: {
35-
fill:
36-
theme.palette.mode === 'dark'
37-
? (theme.vars || theme).palette.grey[800]
38-
: (theme.vars || theme).palette.grey[300],
39-
cursor: 'pointer',
40-
41-
[`&.${chartAxisZoomSliderTrackClasses.selecting}`]: {
42-
cursor: 'ew-resize',
43-
},
44-
},
30+
shouldForwardProp: (prop) =>
31+
shouldForwardProp(prop) && prop !== 'axisDirection' && prop !== 'isSelecting',
32+
})<{ axisDirection: 'x' | 'y'; isSelecting: boolean }>(({ theme }) => ({
33+
fill:
34+
theme.palette.mode === 'dark'
35+
? (theme.vars || theme).palette.grey[800]
36+
: (theme.vars || theme).palette.grey[300],
37+
cursor: 'pointer',
4538
variants: [
4639
{
47-
props: { axisDirection: 'y' },
40+
props: { axisDirection: 'x', isSelecting: true },
4841
style: {
49-
[`&.${chartAxisZoomSliderTrackClasses.root}.${chartAxisZoomSliderTrackClasses.selecting}`]:
50-
{
51-
cursor: 'ns-resize',
52-
},
42+
cursor: 'ew-resize',
43+
},
44+
},
45+
{
46+
props: { axisDirection: 'y', isSelecting: true },
47+
style: {
48+
cursor: 'ns-resize',
5349
},
5450
},
5551
],
@@ -183,10 +179,6 @@ function ChartAxisZoomSliderTrack({
183179
const { instance, svgRef } = useChartContext<[UseChartProZoomSignature]>();
184180
const store = useStore<[UseChartProZoomSignature]>();
185181
const [isSelecting, setIsSelecting] = React.useState(false);
186-
const className = clsx(
187-
chartAxisZoomSliderTrackClasses.root,
188-
isSelecting && chartAxisZoomSliderTrackClasses.selecting,
189-
);
190182

191183
const onPointerDown = function onPointerDown(event: React.PointerEvent<SVGRectElement>) {
192184
const rect = ref.current;
@@ -311,6 +303,7 @@ function ChartAxisZoomSliderTrack({
311303
className={className}
312304
onPointerDown={onPointerDown}
313305
axisDirection={axisDirection}
306+
isSelecting={isSelecting}
314307
{...other}
315308
/>
316309
);

packages/x-charts-pro/src/ChartZoomSlider/internals/chartAxisZoomSliderTrackClasses.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)