-
{`${valueInPercent.toLocaleString()} %`}
-
+ {`${valueInPercent.toLocaleString()} %`}
+ = 30 && valueInPercent <= 70,
high: valueInPercent > 70,
})}
style={{ maxWidth: `${valueInPercent}%` }}
/>
-
+
);
});
diff --git a/packages/grid/x-data-grid-generator/src/renderer/renderRating.tsx b/packages/grid/x-data-grid-generator/src/renderer/renderRating.tsx
index b48494aa2aa5..e28718af0b19 100644
--- a/packages/grid/x-data-grid-generator/src/renderer/renderRating.tsx
+++ b/packages/grid/x-data-grid-generator/src/renderer/renderRating.tsx
@@ -1,26 +1,8 @@
import * as React from 'react';
-import { createTheme } from '@mui/material/styles';
-import { createStyles, makeStyles } from '@mui/styles';
+import Box from '@mui/material/Box';
import { GridCellParams } from '@mui/x-data-grid-pro';
import Rating from '@mui/material/Rating';
-const defaultTheme = createTheme();
-const useStyles = makeStyles(
- (theme) =>
- createStyles({
- root: {
- display: 'flex',
- alignItems: 'center',
- lineHeight: '24px',
- color: theme.palette.text.secondary,
- '& .MuiRating-root': {
- marginRight: theme.spacing(1),
- },
- },
- }),
- { defaultTheme },
-);
-
interface RatingValueProps {
name: string;
value: number;
@@ -28,11 +10,18 @@ interface RatingValueProps {
const RatingValue = React.memo(function RatingValue(props: RatingValueProps) {
const { name, value } = props;
- const classes = useStyles();
return (
-
- {Math.round(Number(value) * 10) / 10}
-
+
+ {' '}
+ {Math.round(Number(value) * 10) / 10}
+
);
});
diff --git a/packages/grid/x-data-grid-generator/src/renderer/renderStatus.tsx b/packages/grid/x-data-grid-generator/src/renderer/renderStatus.tsx
index 11986b3c5346..15a75723d6af 100644
--- a/packages/grid/x-data-grid-generator/src/renderer/renderStatus.tsx
+++ b/packages/grid/x-data-grid-generator/src/renderer/renderStatus.tsx
@@ -1,54 +1,43 @@
import * as React from 'react';
-import clsx from 'clsx';
import ReportProblemIcon from '@mui/icons-material/ReportProblem';
import InfoIcon from '@mui/icons-material/Info';
import AutorenewIcon from '@mui/icons-material/Autorenew';
import DoneIcon from '@mui/icons-material/Done';
import Chip from '@mui/material/Chip';
import { GridCellParams } from '@mui/x-data-grid-pro';
-import { createTheme } from '@mui/material/styles';
-import { createStyles, makeStyles } from '@mui/styles';
+import { styled } from '@mui/material/styles';
-const defaultTheme = createTheme();
-const useStyles = makeStyles(
- (theme) =>
- createStyles({
- root: {
- justifyContent: 'left',
- '& .icon': {
- color: 'inherit',
- },
- },
- Open: {
- color: theme.palette.info.dark,
- border: `1px solid ${theme.palette.info.main}`,
- },
- Filled: {
- color: theme.palette.success.dark,
- border: `1px solid ${theme.palette.success.main}`,
- },
- PartiallyFilled: {
- color: theme.palette.warning.dark,
- border: `1px solid ${theme.palette.warning.main}`,
- },
- Rejected: {
- color: theme.palette.error.dark,
- border: `1px solid ${theme.palette.error.main}`,
- },
- }),
- { defaultTheme },
-);
-
-type Statuses = keyof ReturnType
;
+const StyledChip = styled(Chip)(({ theme }) => ({
+ justifyContent: 'left',
+ '& .icon': {
+ color: 'inherit',
+ },
+ '&.Open': {
+ color: theme.palette.info.dark,
+ border: `1px solid ${theme.palette.info.main}`,
+ },
+ '&.Filled': {
+ color: theme.palette.success.dark,
+ border: `1px solid ${theme.palette.success.main}`,
+ },
+ '&.PartiallyFilled': {
+ color: theme.palette.warning.dark,
+ border: `1px solid ${theme.palette.warning.main}`,
+ },
+ '&.Rejected': {
+ color: theme.palette.error.dark,
+ border: `1px solid ${theme.palette.error.main}`,
+ },
+}));
interface StatusProps {
- status: Statuses;
+ status: string;
}
const Status = React.memo((props: StatusProps) => {
const { status } = props;
+
let icon: any = null;
- const classes = useStyles();
if (status === 'Rejected') {
icon = ;
} else if (status === 'Open') {
@@ -58,18 +47,14 @@ const Status = React.memo((props: StatusProps) => {
} else if (status === 'Filled') {
icon = ;
}
+
let label: string = status;
if (status === 'PartiallyFilled') {
label = 'Partially Filled';
}
+
return (
-
+
);
});
@@ -78,5 +63,5 @@ export function renderStatus(params: GridCellParams) {
return '';
}
- return ;
+ return ;
}
diff --git a/packages/grid/x-data-grid-generator/src/renderer/renderTotalPrice.tsx b/packages/grid/x-data-grid-generator/src/renderer/renderTotalPrice.tsx
index 2861f2b03b22..a28a7fe3b4f8 100644
--- a/packages/grid/x-data-grid-generator/src/renderer/renderTotalPrice.tsx
+++ b/packages/grid/x-data-grid-generator/src/renderer/renderTotalPrice.tsx
@@ -1,27 +1,24 @@
import * as React from 'react';
import clsx from 'clsx';
-import { alpha, createTheme } from '@mui/material/styles';
-import { createStyles, makeStyles } from '@mui/styles';
+import { alpha, styled } from '@mui/material/styles';
import { GridCellParams } from '@mui/x-data-grid';
-const defaultTheme = createTheme();
-const useStyles = makeStyles(
- (theme) =>
- createStyles({
- root: {
- width: '100%',
- paddingRight: 8,
- fontVariantNumeric: 'tabular-nums',
- },
- good: {
- backgroundColor: alpha(theme.palette.success.main, 0.3),
- },
- bad: {
- backgroundColor: alpha(theme.palette.error.main, 0.3),
- },
- }),
- { defaultTheme },
-);
+const Value = styled('div')(({ theme }) => ({
+ width: '100%',
+ height: '100%',
+ lineHeight: '100%',
+ paddingRight: 8,
+ fontVariantNumeric: 'tabular-nums',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'flex-end',
+ '&.good': {
+ backgroundColor: alpha(theme.palette.success.main, 0.3),
+ },
+ '&.bad': {
+ backgroundColor: alpha(theme.palette.error.main, 0.3),
+ },
+}));
interface TotalPriceProps {
value: number;
@@ -34,16 +31,15 @@ const currencyFormatter = new Intl.NumberFormat('en-US', {
const TotalPrice = React.memo(function TotalPrice(props: TotalPriceProps) {
const { value } = props;
- const classes = useStyles();
return (
- 1000000,
- [classes.bad]: value < 1000000,
+ 1000000,
+ bad: value < 1000000,
})}
>
{currencyFormatter.format(value)}
-
+
);
});
diff --git a/packages/storybook/package.json b/packages/storybook/package.json
index 78d065faaded..6eb289c0fc0f 100644
--- a/packages/storybook/package.json
+++ b/packages/storybook/package.json
@@ -18,7 +18,6 @@
"dependencies": {
"@mui/icons-material": "^5.2.5",
"@mui/material": "^5.2.8",
- "@mui/styles": "^5.2.3",
"@mui/x-data-grid": "5.2.2",
"@mui/x-data-grid-generator": "5.2.2",
"@mui/x-data-grid-pro": "5.2.2",
diff --git a/packages/storybook/src/stories/grid-filter.stories.tsx b/packages/storybook/src/stories/grid-filter.stories.tsx
index ecffda8571a8..ca8706049c2e 100644
--- a/packages/storybook/src/stories/grid-filter.stories.tsx
+++ b/packages/storybook/src/stories/grid-filter.stories.tsx
@@ -1,6 +1,7 @@
+import * as React from 'react';
import Button from '@mui/material/Button';
+import Box from '@mui/material/Box';
import InputAdornment from '@mui/material/InputAdornment';
-import { makeStyles } from '@mui/styles';
import { DataGrid } from '@mui/x-data-grid';
import Rating from '@mui/material/Rating';
import {
@@ -19,7 +20,6 @@ import {
} from '@mui/x-data-grid-pro';
import { useDemoData, randomArrayItem } from '@mui/x-data-grid-generator';
import { action } from '@storybook/addon-actions';
-import * as React from 'react';
import { randomInt } from '../data/random-generator';
import { useData } from '../hooks/useData';
@@ -431,18 +431,7 @@ export function CommodityWithNewRowsViaApi() {
);
}
-const useStyles = makeStyles({
- ratingContainer: {
- display: 'inline-flex',
- flexDirection: 'row',
- alignItems: 'center',
- height: 48,
- paddingLeft: 20,
- },
-});
-
function RatingInputValue(props: GridFilterInputValueProps) {
- const classes = useStyles();
const { item, applyValue } = props;
const onFilterChange = React.useCallback(
@@ -454,14 +443,22 @@ function RatingInputValue(props: GridFilterInputValueProps) {
);
return (
-
+
-
+
);
}
diff --git a/packages/storybook/src/stories/grid-rows.stories.tsx b/packages/storybook/src/stories/grid-rows.stories.tsx
index 77178af7b406..69f20e77ea42 100644
--- a/packages/storybook/src/stories/grid-rows.stories.tsx
+++ b/packages/storybook/src/stories/grid-rows.stories.tsx
@@ -1,11 +1,11 @@
import * as React from 'react';
+import { styled } from '@mui/material/styles';
import Alert from '@mui/material/Alert';
import Typography from '@mui/material/Typography';
import Button from '@mui/material/Button';
import Popper from '@mui/material/Popper';
import Paper from '@mui/material/Paper';
-import { createTheme } from '@mui/material/styles';
-import { createStyles, makeStyles } from '@mui/styles';
+import Box from '@mui/material/Box';
import {
GridCellValue,
GridCellParams,
@@ -194,36 +194,12 @@ interface GridCellExpandProps {
width: number;
}
-const defaultTheme = createTheme();
-const useStyles = makeStyles(
- (theme) =>
- createStyles({
- root: {
- alignItems: 'center',
- lineHeight: '24px',
- width: '100%',
- height: '100%',
- position: 'relative',
- display: 'flex',
- '& .MuiRating-root': {
- marginRight: theme.spacing(1),
- },
- '& .cellValue': {
- whiteSpace: 'nowrap',
- overflow: 'hidden',
- textOverflow: 'ellipsis',
- },
- },
- }),
- { defaultTheme },
-);
const GridCellExpand = React.memo(function CellExpand(props: GridCellExpandProps) {
const { width, value } = props;
const wrapper = React.useRef(null);
const cellDiv = React.useRef(null);
const cellValue = React.useRef(null);
const [anchorEl, setAnchorEl] = React.useState(null);
- const classes = useStyles();
const [showFullCell, setShowFullCell] = React.useState(false);
const [showPopper, setShowPopper] = React.useState(false);
@@ -258,11 +234,18 @@ const GridCellExpand = React.memo(function CellExpand(props: GridCellExpandProps
}, [setShowFullCell, showFullCell]);
return (
-
-
+
{value}
-
+
{showPopper && (
)}
-
+
);
});
@@ -442,29 +432,26 @@ function validateEmail(email) {
return re.test(String(email).toLowerCase());
}
-const useEditCellStyles = makeStyles({
- root: {
- '& .MuiDataGrid-cell--editable': {
- backgroundColor: 'rgba(184,250,158,0.19)',
- color: '#1a3e72',
- },
- '& .MuiDataGrid-cell--editing': {
- backgroundColor: 'rgb(255,215,115, 0.19)',
- color: '#1a3e72',
- '& .MuiInputBase-root': {
- height: '100%',
- },
- },
- '& .Mui-error': {
- backgroundColor: 'rgb(126,10,15, 0.1)',
- color: '#750f0f',
+const StyledDataGridPro = styled(DataGridPro)({
+ '& .MuiDataGrid-cell--editable': {
+ backgroundColor: 'rgba(184,250,158,0.19)',
+ color: '#1a3e72',
+ },
+ '& .MuiDataGrid-cell--editing': {
+ backgroundColor: 'rgb(255,215,115, 0.19)',
+ color: '#1a3e72',
+ '& .MuiInputBase-root': {
+ height: '100%',
},
},
+ '& .Mui-error': {
+ backgroundColor: 'rgb(126,10,15, 0.1)',
+ color: '#750f0f',
+ },
});
export function EditRowsControl() {
const apiRef = useGridApiRef();
- const classes = useEditCellStyles();
const [selectedCell, setSelectedCell] = React.useState<[string, string, GridCellValue] | null>(
null,
@@ -540,8 +527,7 @@ export function EditRowsControl() {