Skip to content

Commit

Permalink
[DataGrid] Rename toolbar components for consistency (#1724)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanailH authored May 21, 2021
1 parent 9953f25 commit 71d84fd
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as React from 'react';
import {
DataGrid,
GridToolbarContainer,
GridDensitySelector,
GridToolbarDensitySelector,
} from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';

function CustomToolbar() {
return (
<GridToolbarContainer>
<GridDensitySelector />
<GridToolbarDensitySelector />
</GridToolbarContainer>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as React from 'react';
import {
DataGrid,
GridToolbarContainer,
GridDensitySelector,
GridToolbarDensitySelector,
} from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';

function CustomToolbar() {
return (
<GridToolbarContainer>
<GridDensitySelector />
<GridToolbarDensitySelector />
</GridToolbarContainer>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as React from 'react';
import {
DataGrid,
GridToolbarContainer,
GridDensitySelector,
GridToolbarDensitySelector,
} from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';

function CustomToolbar() {
return (
<GridToolbarContainer>
<GridDensitySelector />
<GridToolbarDensitySelector />
</GridToolbarContainer>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as React from 'react';
import {
DataGrid,
GridToolbarContainer,
GridDensitySelector,
GridToolbarDensitySelector,
} from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';

function CustomToolbar() {
return (
<GridToolbarContainer>
<GridDensitySelector />
<GridToolbarDensitySelector />
</GridToolbarContainer>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ You can change the density of the rows and the column header.

### Density selector

To enable the density selector you need to compose a toolbar containing the `GridDensitySelector` component, and apply it using the `Toolbar` property in the grid `components` prop.
To enable the density selector you need to compose a toolbar containing the `GridToolbarDensitySelector` component, and apply it using the `Toolbar` property in the grid `components` prop.

The user can change the density of the data grid by using the density selector from the toolbar.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import * as React from 'react';
import {
DataGrid,
GridToolbarContainer,
GridColumnsToolbarButton,
GridFilterToolbarButton,
GridToolbarColumnsButton,
GridToolbarFilterButton,
GridToolbarExport,
GridDensitySelector,
GridToolbarDensitySelector,
} from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';

function CustomToolbar() {
return (
<GridToolbarContainer>
<GridColumnsToolbarButton />
<GridFilterToolbarButton />
<GridDensitySelector />
<GridToolbarColumnsButton />
<GridToolbarFilterButton />
<GridToolbarDensitySelector />
<GridToolbarExport />
</GridToolbarContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import * as React from 'react';
import {
DataGrid,
GridToolbarContainer,
GridColumnsToolbarButton,
GridFilterToolbarButton,
GridToolbarColumnsButton,
GridToolbarFilterButton,
GridToolbarExport,
GridDensitySelector,
GridToolbarDensitySelector,
} from '@material-ui/data-grid';
import { useDemoData } from '@material-ui/x-grid-data-generator';

function CustomToolbar() {
return (
<GridToolbarContainer>
<GridColumnsToolbarButton />
<GridFilterToolbarButton />
<GridDensitySelector />
<GridToolbarColumnsButton />
<GridToolbarFilterButton />
<GridToolbarDensitySelector />
<GridToolbarExport />
</GridToolbarContainer>
);
Expand Down
6 changes: 3 additions & 3 deletions docs/src/pages/components/data-grid/components/components.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ Alternatively, you can compose your own toolbar.
function CustomToolbar() {
return (
<GridToolbarContainer>
<GridColumnsToolbarButton />
<GridFilterToolbarButton />
<GridDensitySelector />
<GridToolbarColumnsButton />
<GridToolbarFilterButton />
<GridToolbarDensitySelector />
<GridToolbarExport />
</GridToolbarContainer>
);
Expand Down
12 changes: 6 additions & 6 deletions packages/grid/_modules_/grid/components/toolbar/GridToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
GridToolbarContainer,
GridToolbarContainerProps,
} from '../containers/GridToolbarContainer';
import { GridColumnsToolbarButton } from './GridColumnsToolbarButton';
import { GridDensitySelector } from './GridDensitySelector';
import { GridFilterToolbarButton } from './GridFilterToolbarButton';
import { GridToolbarColumnsButton } from './GridToolbarColumnsButton';
import { GridToolbarDensitySelector } from './GridToolbarDensitySelector';
import { GridToolbarFilterButton } from './GridToolbarFilterButton';
import { GridToolbarExport } from './GridToolbarExport';

export const GridToolbar = React.forwardRef<HTMLDivElement, GridToolbarContainerProps>(
Expand All @@ -27,9 +27,9 @@ export const GridToolbar = React.forwardRef<HTMLDivElement, GridToolbarContainer

return (
<GridToolbarContainer ref={ref} {...props}>
<GridColumnsToolbarButton />
<GridFilterToolbarButton />
<GridDensitySelector />
<GridToolbarColumnsButton />
<GridToolbarFilterButton />
<GridToolbarDensitySelector />
<GridToolbarExport />
</GridToolbarContainer>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { gridPreferencePanelStateSelector } from '../../hooks/features/preferenc
import { GridPreferencePanelsValue } from '../../hooks/features/preferencesPanel/gridPreferencePanelsValue';
import { GridApiContext } from '../GridApiContext';

export const GridColumnsToolbarButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
function GridColumnsToolbarButton(props, ref) {
export const GridToolbarColumnsButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
function GridToolbarColumnsButton(props, ref) {
const apiRef = React.useContext(GridApiContext);
const options = useGridSelector(apiRef, optionsSelector);
const ColumnSelectorIcon = apiRef!.current.components.ColumnSelectorIcon!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { optionsSelector } from '../../hooks/utils/optionsSelector';
import { GridDensityOption } from '../../models/api/gridDensityApi';
import { GridMenu } from '../menu/GridMenu';

export const GridDensitySelector = React.forwardRef<HTMLButtonElement, ButtonProps>(
function GridDensitySelector(props, ref) {
export const GridToolbarDensitySelector = React.forwardRef<HTMLButtonElement, ButtonProps>(
function GridToolbarDensitySelector(props, ref) {
const apiRef = React.useContext(GridApiContext);
const options = useGridSelector(apiRef, optionsSelector);
const densityValue = useGridSelector(apiRef, gridDensityValueSelector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ const useStyles = makeStyles(
padding: theme.spacing(0, 1),
},
}),
{ name: 'MuiDataGridFilterToolbarButton', defaultTheme },
{ name: 'MuiDataGridToolbarFilterButton', defaultTheme },
);

export const GridFilterToolbarButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
function GridFilterToolbarButton(props, ref) {
export const GridToolbarFilterButton = React.forwardRef<HTMLButtonElement, ButtonProps>(
function GridToolbarFilterButton(props, ref) {
const classes = useStyles();
const apiRef = React.useContext(GridApiContext);
const options = useGridSelector(apiRef, optionsSelector);
Expand Down
8 changes: 4 additions & 4 deletions packages/grid/_modules_/grid/components/toolbar/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './GridColumnsToolbarButton';
export * from './GridDensitySelector';
export * from './GridFilterToolbarButton';
export * from './GridToolbarExport';
export * from './GridToolbar';
export * from './GridToolbarColumnsButton';
export * from './GridToolbarDensitySelector';
export * from './GridToolbarExport';
export * from './GridToolbarFilterButton';

0 comments on commit 71d84fd

Please sign in to comment.