Skip to content

Commit

Permalink
[data grid] Use styled from system (#8032)
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp authored Mar 3, 2023
1 parent 4d6f62e commit 7dd77b7
Show file tree
Hide file tree
Showing 20 changed files with 49 additions and 50 deletions.
2 changes: 1 addition & 1 deletion packages/grid/x-data-grid/src/components/GridRowCount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { getDataGridUtilityClass } from '../constants/gridClasses';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { styled } from '@mui/material/styles';
import { styled } from '@mui/system';
import { GridEventListener } from '../models/events';
import { useGridApiEventHandler } from '../hooks/utils/useGridApiEventHandler';
import { GridScrollParams } from '../models/params/gridScrollParams';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { useGridApiContext } from '../hooks/utils/useGridApiContext';
import { getDataGridUtilityClass } from '../constants/gridClasses';
import { useGridRootProps } from '../hooks/utils/useGridRootProps';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { styled } from '@mui/material/styles';
import { styled } from '@mui/system';
import {
unstable_composeClasses as composeClasses,
unstable_useEnhancedEffect as useEnhancedEffect,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { DataGridProcessedProps } from '../../models/props/DataGridProps';
Expand All @@ -22,17 +22,15 @@ const GridColumnHeadersRoot = styled('div', {
name: 'MuiDataGrid',
slot: 'ColumnHeaders',
overridesResolver: (props, styles) => styles.columnHeaders,
})<{ ownerState: OwnerState }>(({ theme }) => {
return {
position: 'relative',
overflow: 'hidden',
display: 'flex',
alignItems: 'center',
boxSizing: 'border-box',
borderBottom: '1px solid',
borderTopLeftRadius: theme.shape.borderRadius,
borderTopRightRadius: theme.shape.borderRadius,
};
})<{ ownerState: OwnerState }>({
position: 'relative',
overflow: 'hidden',
display: 'flex',
alignItems: 'center',
boxSizing: 'border-box',
borderBottom: '1px solid',
borderTopLeftRadius: 'var(--unstable_DataGrid-radius)',
borderTopRightRadius: 'var(--unstable_DataGrid-radius)',
});

interface GridBaseColumnHeadersProps extends React.HTMLAttributes<HTMLDivElement> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { styled } from '@mui/material/styles';
import { styled } from '@mui/system';
import { isOverflown } from '../../utils/domUtils';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
Expand All @@ -24,12 +24,12 @@ const GridColumnHeaderTitleRoot = styled('div', {
name: 'MuiDataGrid',
slot: 'ColumnHeaderTitle',
overridesResolver: (props, styles) => styles.columnHeaderTitle,
})<{ ownerState: OwnerState }>(({ theme }) => ({
})<{ ownerState: OwnerState }>({
textOverflow: 'ellipsis',
overflow: 'hidden',
whiteSpace: 'nowrap',
fontWeight: theme.typography.fontWeightMedium,
}));
fontWeight: 'var(--unstable_DataGrid-headWeight)',
});

const ColumnHeaderInnerTitle = React.forwardRef<
HTMLDivElement,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { gridClasses, getDataGridUtilityClass } from '../../constants/gridClasses';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { DataGridProcessedProps } from '../../models/props/DataGridProps';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { styled } from '@mui/material/styles';
import { styled } from '@mui/system';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import type { DataGridProcessedProps } from '../../models/props/DataGridProps';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import type { DataGridProcessedProps } from '../../models/props/DataGridProps';
Expand All @@ -27,14 +27,12 @@ const GridFooterContainerRoot = styled('div', {
name: 'MuiDataGrid',
slot: 'FooterContainer',
overridesResolver: (props, styles) => styles.footerContainer,
})<{ ownerState: OwnerState }>(() => {
return {
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
minHeight: 52, // Match TablePagination min height
borderTop: '1px solid',
};
})<{ ownerState: OwnerState }>({
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
minHeight: 52,
borderTop: '1px solid',
});

const GridFooterContainer = React.forwardRef<HTMLDivElement, GridFooterContainerProps>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { styled } from '@mui/material/styles';
import { styled } from '@mui/system';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { DataGridProcessedProps } from '../../models/props/DataGridProps';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { SxProps } from '@mui/system';
import { Theme, alpha, styled } from '@mui/material/styles';
import { Theme, SxProps, styled } from '@mui/system';
import type { DataGridProcessedProps } from '../../models/props/DataGridProps';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
Expand All @@ -28,17 +27,15 @@ const GridOverlayRoot = styled('div', {
name: 'MuiDataGrid',
slot: 'Overlay',
overridesResolver: (_, styles) => styles.overlay,
})<{ ownerState: OwnerState }>(({ theme }) => ({
})<{ ownerState: OwnerState }>({
width: '100%',
height: '100%',
display: 'flex',
alignSelf: 'center',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: theme.vars
? `rgba(${theme.vars.palette.background.defaultChannel} / ${theme.vars.palette.action.disabledOpacity})`
: alpha(theme.palette.background.default, theme.palette.action.disabledOpacity),
}));
backgroundColor: 'var(--unstable_DataGrid-overlayBackground)',
});

const GridOverlay = React.forwardRef<HTMLDivElement, GridOverlayProps>(function GridOverlay(
props: GridOverlayProps,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,21 @@ export const GridRootStyles = styled('div', {
],
})<{ ownerState: OwnerState }>(({ theme }) => {
const borderColor = getBorderColor(theme);
const radius = theme.shape.borderRadius;

const gridStyle: CSSInterpolation = {
'--unstable_DataGrid-radius': typeof radius === 'number' ? `${radius}px` : radius,
'--unstable_DataGrid-headWeight': theme.typography.fontWeightMedium,
'--unstable_DataGrid-overlayBackground': theme.vars
? `rgba(${theme.vars.palette.background.defaultChannel} / ${theme.vars.palette.action.disabledOpacity})`
: alpha(theme.palette.background.default, theme.palette.action.disabledOpacity),
flex: 1,
boxSizing: 'border-box',
position: 'relative',
borderWidth: '1px',
borderStyle: 'solid',
borderColor,
borderRadius: theme.shape.borderRadius,
borderRadius: 'var(--unstable_DataGrid-radius)',
color: (theme.vars || theme).palette.text.primary,
...theme.typography.body2,
outline: 'none',
Expand Down Expand Up @@ -432,13 +438,13 @@ export const GridRootStyles = styled('div', {
[`& .${gridClasses['columnHeader--dragging']}, & .${gridClasses['row--dragging']}`]: {
background: (theme.vars || theme).palette.background.paper,
padding: '0 12px',
borderRadius: theme.shape.borderRadius,
borderRadius: 'var(--unstable_DataGrid-radius)',
opacity: (theme.vars || theme).palette.action.disabledOpacity,
},
[`& .${gridClasses['row--dragging']}`]: {
background: (theme.vars || theme).palette.background.paper,
padding: '0 12px',
borderRadius: theme.shape.borderRadius,
borderRadius: 'var(--unstable_DataGrid-radius)',
opacity: (theme.vars || theme).palette.action.disabledOpacity,

[`& .${gridClasses.rowReorderCellPlaceholder}`]: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
import type { DataGridProcessedProps } from '../../models/props/DataGridProps';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import type { DataGridProcessedProps } from '../../models/props/DataGridProps';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import type { DataGridProcessedProps } from '../../models/props/DataGridProps';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import clsx from 'clsx';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import type { DataGridProcessedProps } from '../../models/props/DataGridProps';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import clsx from 'clsx';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import clsx from 'clsx';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as React from 'react';
import clsx from 'clsx';
import { styled, SxProps, Theme } from '@mui/material/styles';
import { styled, SxProps, Theme } from '@mui/system';
import { unstable_composeClasses as composeClasses } from '@mui/utils';
import { useGridRootProps } from '../../hooks/utils/useGridRootProps';
import { getDataGridUtilityClass } from '../../constants/gridClasses';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import { unstable_useForkRef as useForkRef } from '@mui/utils';
import { styled, useTheme } from '@mui/material/styles';
import { styled, useTheme } from '@mui/system';
import { defaultMemoize } from 'reselect';
import { useGridPrivateApiContext } from '../../utils/useGridPrivateApiContext';
import { useGridRootProps } from '../../utils/useGridRootProps';
Expand Down

0 comments on commit 7dd77b7

Please sign in to comment.