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] Add columnHeader
, row
and cell
in addition to root
in classes prop
#1660
[DataGrid] Add columnHeader
, row
and cell
in addition to root
in classes prop
#1660
Conversation
columnHeader
, row
and cell
in addition to root
in classes propcolumnHeader
, row
and cell
in addition to root
in classes prop
@@ -98,6 +98,14 @@ const columns: GridColumns = [ | |||
|
|||
{{"demo": "pages/components/data-grid/style/StylingCellsGrid.js", "bg": "inline"}} | |||
|
|||
## Using the `classes` object prop |
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.
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.
Well what's the point of doing the feature if we don't want to show it to the users?
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.
The main value I think is about having the same API as in the core components. It's only a foot gun because we increase specificity for performance. This mean that developers will lose specificity over the default styles of the grid.
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.
Maybe a warning about this, to prefix the demo would be enough?
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.
When doing the demo it felt like a duplicate. I can remove the demo and just add a link to the page that explains how to use classes
?
@@ -82,3 +84,7 @@ export function mapColDefTypeToInputType(type: string) { | |||
|
|||
// Util to make specific interface properties optional | |||
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>; | |||
|
|||
export function getButtonBaseUtilityClass(slot) { | |||
return generateUtilityClass(GRID_CSS_CLASS_PREFIX, slot); |
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.
what is this one? What issue does it solve?
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 one is used to generate the class names. We didn't complete the migration, we are not supposed to have GRID_HEADER_CELL_CSS_CLASS
variables like with the approach of v5 in the core. Instead, we would read the global gridClasses.headerCell.
@@ -98,6 +98,14 @@ const columns: GridColumns = [ | |||
|
|||
{{"demo": "pages/components/data-grid/style/StylingCellsGrid.js", "bg": "inline"}} | |||
|
|||
## Using the `classes` object prop |
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.
Maybe a warning about this, to prefix the demo would be enough?
@@ -82,3 +84,7 @@ export function mapColDefTypeToInputType(type: string) { | |||
|
|||
// Util to make specific interface properties optional | |||
export type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>; | |||
|
|||
export function getButtonBaseUtilityClass(slot) { | |||
return generateUtilityClass(GRID_CSS_CLASS_PREFIX, slot); |
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 one is used to generate the class names. We didn't complete the migration, we are not supposed to have GRID_HEADER_CELL_CSS_CLASS
variables like with the approach of v5 in the core. Instead, we would read the global gridClasses.headerCell.
Ok, I've renamed the classes from |
export const GRID_COLUMN_HEADER_CSS_CLASS = `${GRID_CSS_CLASS_PREFIX}-${GRID_COLUMN_HEADER_CSS_CLASS_SUFFIX}`; | ||
export const GRID_ROW_CSS_CLASS = `${GRID_CSS_CLASS_PREFIX}-${GRID_ROW_CSS_CLASS_SUFFIX}`; | ||
export const GRID_CELL_CSS_CLASS = `${GRID_CSS_CLASS_PREFIX}-${GRID_CELL_CSS_CLASS_SUFFIX}`; | ||
export const GRID_COLUMN_HEADER_SEPARATOR_RESIZABLE_CSS_CLASS = `${GRID_ROOT_CSS_CLASS_SUFFIX}-columnSeparatorResizable`; | ||
export const GRID_COLUMN_HEADER_TITLE_CSS_CLASS = `${GRID_ROOT_CSS_CLASS_SUFFIX}-columnHeaderTitleContainer`; |
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 believe we will need to move the logic into a plain dataGridClasses
file, as in the core.
export const GRID_COLUMN_HEADER_CSS_CLASS = `${GRID_CSS_CLASS_PREFIX}-${GRID_COLUMN_HEADER_CSS_CLASS_SUFFIX}`; | |
export const GRID_ROW_CSS_CLASS = `${GRID_CSS_CLASS_PREFIX}-${GRID_ROW_CSS_CLASS_SUFFIX}`; | |
export const GRID_CELL_CSS_CLASS = `${GRID_CSS_CLASS_PREFIX}-${GRID_CELL_CSS_CLASS_SUFFIX}`; | |
export const GRID_COLUMN_HEADER_SEPARATOR_RESIZABLE_CSS_CLASS = `${GRID_ROOT_CSS_CLASS_SUFFIX}-columnSeparatorResizable`; | |
export const GRID_COLUMN_HEADER_TITLE_CSS_CLASS = `${GRID_ROOT_CSS_CLASS_SUFFIX}-columnHeaderTitleContainer`; |
Related to #408 |
Fixes #1495
Not much in terms of the approach. I had to add the
classes
to the gridoptions
in order to have access to them in the column header, row, and cell components.BREAKING CHANGES:
Missing:
/style
page in the docshttps://deploy-preview-1660--material-ui-x.netlify.app/components/data-grid/style/#using-the-classes-object-prop