-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
[core] Reduce styles complexity #3012
[core] Reduce styles complexity #3012
Conversation
Related to #2995 (comment). If we make this change, I think that we should make sure it has no performance implications. |
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
Looks good to me |
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 didn't find any performance issues. 💯
packages/grid/_modules_/grid/components/cell/GridEditInputCell.tsx
Outdated
Show resolved
Hide resolved
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.
Great to see this one in. A few notes, looking at what was already here
@@ -1,6 +1,7 @@ | |||
import * as React from 'react'; | |||
import clsx from 'clsx'; | |||
import { unstable_composeClasses as composeClasses } from '@mui/material'; |
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.
This looks problematic. We bundle the whole @mui/material
dependency in dev mode. Could we import the util only?
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.
Fixed #3094
export const GridFooterContainer = React.forwardRef<HTMLDivElement, GridFooterContainerProps>( | ||
function GridFooterContainer(props: GridFooterContainerProps, ref) { | ||
const { className, ...other } = props; | ||
const rootProps = useGridRootProps(); | ||
const ownerState = { classes: rootProps.classes }; | ||
const classes = useUtilityClasses(ownerState); | ||
|
||
return <div ref={ref} className={clsx(classes.root, className)} {...other} />; |
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.
Something is off with the classes
.
gridClasses
has footerContainer
and yet, in this file, we create the class name a second time. I think that we should either:
- have
<DataGrid classes={{ footerContainer: 'foo' }} />
to actually work and usegridClasses.footerContainer
for the class name, not duplicating its creation. - or change the name of the styled component:
name: 'MuiDataGrid',
->name: 'GridFooterContainer',
slot: 'FooterContainer',
->slot: 'Root',
, remove footerContainer fromgridClasses
and expose agridFooterContainerClasses
module.
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 would stick to the first option since that is the convention we are currently following. IMO it will look off to have GridFooterContainer
because that way we would need to go through the other components and update them as well.
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.
@oliviertassinari I didn't understand the problem and solution proposed in the first option.
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.
Ok, it seems that we are good.
Reorganizing the grid styles. Due to performance reasons the styles for the column headers, cells and rows are kept in the
GridRootStyles
. All other styles that aren't nested in one of those components have been moved out of this file and into their respective component.This PR doesn't have any breaking changes.