Skip to content
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

Merged
merged 6 commits into from
Nov 4, 2021

Conversation

DanailH
Copy link
Member

@DanailH DanailH commented Oct 28, 2021

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.

@DanailH DanailH added core Infrastructure work going on behind the scenes new feature New feature or request labels Oct 28, 2021
@DanailH DanailH self-assigned this Oct 28, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 28, 2021

Related to #2995 (comment). If we make this change, I think that we should make sure it has no performance implications.

@DanailH DanailH changed the title [WIP][core] Reduce styles complexity [core] Reduce styles complexity [WIP] Oct 29, 2021
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 2, 2021
@github-actions
Copy link

github-actions bot commented Nov 2, 2021

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@DanailH DanailH changed the title [core] Reduce styles complexity [WIP] [core] Reduce styles complexity Nov 2, 2021
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 2, 2021
@DanailH DanailH marked this pull request as ready for review November 2, 2021 14:49
@flaviendelangle
Copy link
Member

Looks good to me

Copy link
Member

@m4theushw m4theushw left a 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. 💯

@DanailH DanailH merged commit 5d16eac into mui:next Nov 4, 2021
@DanailH DanailH mentioned this pull request Nov 4, 2021
Copy link
Member

@oliviertassinari oliviertassinari left a 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';
Copy link
Member

@oliviertassinari oliviertassinari Nov 4, 2021

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?

Copy link
Member

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} />;
Copy link
Member

@oliviertassinari oliviertassinari Nov 4, 2021

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:

  1. have <DataGrid classes={{ footerContainer: 'foo' }} /> to actually work and use gridClasses.footerContainer for the class name, not duplicating its creation.
  2. or change the name of the styled component: name: 'MuiDataGrid', -> name: 'GridFooterContainer',
    slot: 'FooterContainer', -> slot: 'Root',, remove footerContainer from gridClasses and expose a gridFooterContainerClasses module.

Copy link
Member Author

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.

Copy link
Member

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.

  • The value of gridClasses.footerContainer is MuiDataGrid-footerContainer which breaks composeClasses.

  • <DataGrid classes={{ footerContainer: 'foo' }} /> works correctly:

    image

Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Infrastructure work going on behind the scenes new feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants