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

[DataGrid] Remove cellClassRules from GridColDef #1716

Merged
merged 11 commits into from May 24, 2021

Conversation

m4theushw
Copy link
Member

@m4theushw m4theushw commented May 20, 2021

Breaking changes

  • [DataGrid] Remove cellClassRules from GridColDef ([DataGrid] Remove cellClassRules from GridColDef #1716) @m4theushw

    The GridCellClassParams type is not exported anymore. Replace it with GridCellParams.

    -import { GridCellClassParams} from '@material-ui/data-grid';
    +import { GridCellParams } from '@material-ui/data-grid';
    
    -cellClassName: (params: GridCellClassParams) =>
    +cellClassName: (params: GridCellParams) =>

    The cellClassRules in GridColDef was removed because it's redundant. The same functionality can be obtained using cellClassName and the clsx utility:

    +import clsx from 'clsx';
    
     {
       field: 'age',
       width: 150,
    -  cellClassRules: {
    -    negative: params => params.value < 0,
    -    positive: params => params.value > 0,
    -  },
    +  cellClassName: params => clsx({
    +    negative: params.value < 0,
    +    positive: params.value > 0,
    +  }),
     }

Closes #275
To be merged after #1687

@m4theushw m4theushw requested review from DanailH, dtassone and oliviertassinari and removed request for DanailH and dtassone May 21, 2021 13:23
}

const editCellState = editRowState && editRowState[column.field];
let cellComponent: React.ReactElement | null = null;

if (editCellState == null && column.renderCell) {
cellComponent = column.renderCell(cellParams);
cssClassProp = { cssClass: `${cssClassProp.cssClass} MuiDataGrid-cellWithRenderer` };
classNames.push('MuiDataGrid-cellWithRenderer');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we move those hardcoded class names into cssClassesConstants.ts and build them using the GRID_CSS_CLASS_PREFIX? That way if we change it in the future it will be easier to handle the change.

x-(the other places)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even better, we can reproduce the classes approach of the core component (dataGridClasses.ts + generateUtilityClasses). I have added the item to #408.

@m4theushw m4theushw merged commit 54e6261 into mui:master May 24, 2021
@m4theushw m4theushw deleted the remove-cellClassRules branch May 24, 2021 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Remove cellClassRules
4 participants