-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[charts-pro] Update zoom slider range selection cursor #17977
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[charts-pro] Update zoom slider range selection cursor #17977
Conversation
Thanks for adding a type label to the PR! 👍 |
Deploy preview: https://deploy-preview-17977--material-ui-x.netlify.app/ Bundle size reportTotal Size Change: @mui/x-charts-pro/ChartZoomSlider parsed: Show 34 more bundle changes@mui/x-data-grid-pro/DataGridPro parsed: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to use pointer for hovering on the track, and then when you are creating the new selection, it switches to the resize cursor?
CodSpeed Performance ReportMerging #17977 will not alter performanceComparing Summary
|
Something like this? Screen.Recording.2025-05-23.at.12.01.33.mov |
@bernardobelchior yeah, that would be an improvement I think. |
const Group = styled('g')({ | ||
[`&.${chartAxisZoomSliderClasses.root}.${chartAxisZoomSliderClasses.horizontal} .${chartAxisZoomSliderClasses.track}.${chartAxisZoomSliderClasses.selecting}`]: | ||
{ cursor: 'ew-resize' }, | ||
[`&.${chartAxisZoomSliderClasses.root}.${chartAxisZoomSliderClasses.vertical} .${chartAxisZoomSliderClasses.track}.${chartAxisZoomSliderClasses.selecting}`]: | ||
{ cursor: 'ns-resize' }, | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bit weird to have that many classes. Users would need a specificity higher than 0-5-0
to verride those rules.
What about moving that style into the ZoomSliderTrack
?
You can look at this component. In short, you pass the props of interest (the direction and the selecting state) such that it adapts its style to it, but do not propagate those props. The goal is to have only one class such that any style override wins over the default one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the code as suggested. Is that what you had in mind?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can go further on the simplification with
const ZoomSliderTrack = styled('rect', {
shouldForwardProp: (prop) =>
shouldForwardProp(prop) && prop !== 'axisDirection' && prop !== 'isSelecting',
})<{ axisDirection: 'x' | 'y'; isSelecting: boolean }>(({ theme }) => ({
fill:
theme.palette.mode === 'dark'
? (theme.vars || theme).palette.grey[800]
: (theme.vars || theme).palette.grey[300],
cursor: 'pointer',
variants: [
{
props: { axisDirection: 'y', isSelecting: true },
style: {
cursor: 'ns-resize',
},
},
{
props: { axisDirection: 'x', isSelecting: true },
style: {
cursor: 'ew-resize',
},
},
],
}));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems to work 😄 done 👍
02ff199
to
f77dbd3
Compare
Use pointer instead of crosshair, as suggested by @KenanYusuf.
Screen.Recording.2025-05-23.at.12.01.33.mov