Skip to content

Commit

Permalink
[DataGrid] Column header design updates (#14293)
Browse files Browse the repository at this point in the history
  • Loading branch information
KenanYusuf authored Sep 3, 2024
1 parent 8138f66 commit bb26d25
Show file tree
Hide file tree
Showing 18 changed files with 117 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,10 @@
"description": "Set the area in <code>px</code> at the bottom of the grid viewport where onRowsScrollEnd is called."
},
"showCellVerticalBorder": {
"description": "If <code>true</code>, the vertical borders of the cells are displayed."
"description": "If <code>true</code>, vertical borders will be displayed between cells."
},
"showColumnVerticalBorder": {
"description": "If <code>true</code>, the right border of the column headers are displayed."
"description": "If <code>true</code>, vertical borders will be displayed between column header items."
},
"slotProps": {
"description": "Overridable components props dynamically passed to the component at rendering."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,10 +562,10 @@
"description": "Set the area in <code>px</code> at the bottom of the grid viewport where onRowsScrollEnd is called."
},
"showCellVerticalBorder": {
"description": "If <code>true</code>, the vertical borders of the cells are displayed."
"description": "If <code>true</code>, vertical borders will be displayed between cells."
},
"showColumnVerticalBorder": {
"description": "If <code>true</code>, the right border of the column headers are displayed."
"description": "If <code>true</code>, vertical borders will be displayed between column header items."
},
"slotProps": {
"description": "Overridable components props dynamically passed to the component at rendering."
Expand Down
4 changes: 2 additions & 2 deletions docs/translations/api-docs/data-grid/data-grid/data-grid.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,10 @@
"description": "Override the height/width of the Data Grid inner scrollbar."
},
"showCellVerticalBorder": {
"description": "If <code>true</code>, the vertical borders of the cells are displayed."
"description": "If <code>true</code>, vertical borders will be displayed between cells."
},
"showColumnVerticalBorder": {
"description": "If <code>true</code>, the right border of the column headers are displayed."
"description": "If <code>true</code>, vertical borders will be displayed between column header items."
},
"slotProps": {
"description": "Overridable components props dynamically passed to the component at rendering."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -997,12 +997,12 @@ DataGridPremiumRaw.propTypes = {
*/
scrollEndThreshold: PropTypes.number,
/**
* If `true`, the vertical borders of the cells are displayed.
* If `true`, vertical borders will be displayed between cells.
* @default false
*/
showCellVerticalBorder: PropTypes.bool,
/**
* If `true`, the right border of the column headers are displayed.
* If `true`, vertical borders will be displayed between column header items.
* @default false
*/
showColumnVerticalBorder: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,9 @@ const GridAggregationFunctionLabel = styled('div', {
})<{ ownerState: OwnerState }>(({ theme }) => {
return {
fontSize: theme.typography.caption.fontSize,
lineHeight: theme.typography.caption.fontSize,
position: 'absolute',
bottom: 4,
fontWeight: theme.typography.fontWeightMedium,
color: (theme.vars || theme).palette.primary.dark,
textTransform: 'uppercase',
lineHeight: 'normal',
color: theme.palette.text.secondary,
marginTop: -1,
};
});

Expand Down
4 changes: 2 additions & 2 deletions packages/x-data-grid-pro/src/DataGridPro/DataGridPro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -903,12 +903,12 @@ DataGridProRaw.propTypes = {
*/
scrollEndThreshold: PropTypes.number,
/**
* If `true`, the vertical borders of the cells are displayed.
* If `true`, vertical borders will be displayed between cells.
* @default false
*/
showCellVerticalBorder: PropTypes.bool,
/**
* If `true`, the right border of the column headers are displayed.
* If `true`, vertical borders will be displayed between column header items.
* @default false
*/
showColumnVerticalBorder: PropTypes.bool,
Expand Down
16 changes: 8 additions & 8 deletions packages/x-data-grid-pro/src/tests/columns.DataGridPro.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,11 @@ describe('<DataGridPro /> - Columns', () => {
await microtasks();
expect(onColumnWidthChange.callCount).to.be.at.least(2);
const widthArgs = onColumnWidthChange.args.map((arg) => arg[0].width);
const isWidth116Present = widthArgs.some((width) => width === 116);
expect(isWidth116Present).to.equal(true);
const isWidth114Present = widthArgs.some((width) => width === 114);
expect(isWidth114Present).to.equal(true);
const colDefWidthArgs = onColumnWidthChange.args.map((arg) => arg[0].colDef.width);
const isColDefWidth116Present = colDefWidthArgs.some((width) => width === 116);
expect(isColDefWidth116Present).to.equal(true);
const isColDefWidth114Present = colDefWidthArgs.some((width) => width === 114);
expect(isColDefWidth114Present).to.equal(true);
});

it('should not affect other cell elements that are not part of the main DataGrid instance', () => {
Expand Down Expand Up @@ -473,7 +473,7 @@ describe('<DataGridPro /> - Columns', () => {
render(<Test rows={rows} columns={columns} />);
await apiRef.current.autosizeColumns();
await microtasks();
expect(getWidths()).to.deep.equal([213, 235]);
expect(getWidths()).to.deep.equal([211, 233]);
});

it('should work through double-clicking the separator', async () => {
Expand All @@ -483,14 +483,14 @@ describe('<DataGridPro /> - Columns', () => {
)[1];
fireEvent.doubleClick(separator);
await microtasks();
expect(getWidths()).to.deep.equal([100, 235]);
expect(getWidths()).to.deep.equal([100, 233]);
});

it('should work on mount', async () => {
render(<Test rows={rows} columns={columns} autosizeOnMount />);
await microtasks(); /* first effect after render */
await microtasks(); /* async autosize operation */
expect(getWidths()).to.deep.equal([213, 235]);
expect(getWidths()).to.deep.equal([211, 233]);
});

describe('options', () => {
Expand All @@ -506,7 +506,7 @@ describe('<DataGridPro /> - Columns', () => {
});

it('.includeHeaders works', async () => {
await autosize({ includeHeaders: true }, [213, 235]);
await autosize({ includeHeaders: true }, [211, 233]);
});

it('.includeOutliers works', async () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/x-data-grid/src/DataGrid/DataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -752,12 +752,12 @@ DataGridRaw.propTypes = {
*/
scrollbarSize: PropTypes.number,
/**
* If `true`, the vertical borders of the cells are displayed.
* If `true`, vertical borders will be displayed between cells.
* @default false
*/
showCellVerticalBorder: PropTypes.bool,
/**
* If `true`, the right border of the column headers are displayed.
* If `true`, vertical borders will be displayed between column header items.
* @default false
*/
showColumnVerticalBorder: PropTypes.bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const ColumnHeaderMenuIcon = React.memo((props: ColumnHeaderMenuIconProps
id={columnMenuButtonId}
{...rootProps.slotProps?.baseIconButton}
>
<rootProps.slots.columnMenuIcon fontSize="small" />
<rootProps.slots.columnMenuIcon fontSize="inherit" />
</rootProps.slots.baseIconButton>
</rootProps.slots.baseTooltip>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function GridColumnGroupHeader(props: GridColumnGroupHeaderProps) {
pinnedPosition,
indexInSection,
sectionLength,
rootProps.showCellVerticalBorder,
rootProps.showColumnVerticalBorder,
gridHasFiller,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function GridColumnHeaderItem(props: GridColumnHeaderItemProps) {
pinnedPosition,
indexInSection,
sectionLength,
rootProps.showCellVerticalBorder,
rootProps.showColumnVerticalBorder,
gridHasFiller,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ function GridColumnHeaderSeparatorRaw(props: GridColumnHeaderSeparatorProps) {

return (
// eslint-disable-next-line jsx-a11y/click-events-have-key-events,jsx-a11y/no-static-element-interactions
<div
className={classes.root}
style={{ minHeight: height, opacity: rootProps.showColumnVerticalBorder ? 0 : 1 }}
{...other}
onClick={stopClick}
>
<div className={classes.root} style={{ minHeight: height }} {...other} onClick={stopClick}>
<rootProps.slots.columnResizeIcon className={classes.icon} />
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const GridColumnHeaderTitleRoot = styled('div', {
overflow: 'hidden',
whiteSpace: 'nowrap',
fontWeight: 'var(--unstable_DataGrid-headWeight)',
lineHeight: 'normal',
});

const ColumnHeaderInnerTitle = React.forwardRef<
Expand Down
Loading

0 comments on commit bb26d25

Please sign in to comment.