Skip to content

Commit

Permalink
[Grid2] Add container class to Grid2Classes (#44562)
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 authored Nov 26, 2024
1 parent dfe7067 commit 6b96951
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
15 changes: 14 additions & 1 deletion docs/pages/material-ui/api/grid-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,20 @@
},
"name": "Grid2",
"imports": ["import Grid2 from '@mui/material/Grid2';", "import { Grid2 } from '@mui/material';"],
"classes": [],
"classes": [
{
"key": "container",
"className": "MuiGrid2-container",
"description": "Styles applied to the root element if `container={true}`.",
"isGlobal": false
},
{
"key": "root",
"className": "MuiGrid2-root",
"description": "Styles applied to the root element.",
"isGlobal": false
}
],
"spread": true,
"themeDefaultProps": true,
"muiName": "MuiGrid2",
Expand Down
9 changes: 8 additions & 1 deletion docs/translations/api-docs/grid-2/grid-2.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,12 @@
"description": "Defines the <code>flex-wrap</code> style property. It&#39;s applied for all screen sizes."
}
},
"classDescriptions": {}
"classDescriptions": {
"container": {
"description": "Styles applied to {{nodeName}} if {{conditions}}.",
"nodeName": "the root element",
"conditions": "<code>container={true}</code>"
},
"root": { "description": "Styles applied to the root element." }
}
}
2 changes: 0 additions & 2 deletions packages/mui-material/src/Grid2/Grid2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import requirePropFactory from '../utils/requirePropFactory';
import { Theme, styled, Breakpoint } from '../styles';
import { useDefaultProps } from '../DefaultPropsProvider';

export type Grid2Slot = 'root';

type ResponsiveStyleValue<T> = T | Array<T | null> | { [key in Breakpoint]?: T | null };

export type GridDirection = 'row' | 'row-reverse' | 'column' | 'column-reverse';
Expand Down
12 changes: 9 additions & 3 deletions packages/mui-material/src/Grid2/grid2Classes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import { GridClasses } from '@mui/system/Grid';
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
import generateUtilityClass from '@mui/utils/generateUtilityClass';

export type Grid2ClassKey = keyof GridClasses;
export interface Grid2Classes {
/** Styles applied to the root element. */
root: string;
/** Styles applied to the root element if `container={true}`. */
container: string;
}

export type Grid2ClassKey = keyof Grid2Classes;

export function getGrid2UtilityClass(slot: string): string {
return generateUtilityClass('MuiGrid2', slot);
Expand All @@ -13,7 +19,7 @@ const DIRECTIONS = ['column-reverse', 'column', 'row-reverse', 'row'] as const;
const WRAPS = ['nowrap', 'wrap-reverse', 'wrap'] as const;
const GRID_SIZES = ['auto', true, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] as const;

const grid2Classes: GridClasses = generateUtilityClasses('MuiGrid2', [
const grid2Classes: Grid2Classes = generateUtilityClasses('MuiGrid2', [
'root',
'container',

Expand Down
10 changes: 10 additions & 0 deletions packages/mui-material/src/styles/createTheme.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ const theme = createTheme();
},
},
},
MuiGrid2: {
styleOverrides: {
root: {
justifyContent: 'space-between',
},
container: {
justifyContent: 'space-between',
},
},
},
},
});
}
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-material/src/styles/overrides.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import { FormGroupClassKey } from '../FormGroup';
import { FormHelperTextClassKey } from '../FormHelperText';
import { FormLabelClassKey } from '../FormLabel';
import { GridClassKey } from '../Grid';
import { Grid2Slot } from '../Grid2';
import { Grid2ClassKey } from '../Grid2';
import { IconButtonClassKey } from '../IconButton';
import { IconClassKey } from '../Icon';
import { ImageListClassKey } from '../ImageList';
Expand Down Expand Up @@ -190,7 +190,7 @@ export interface ComponentNameToClassKey {
MuiFormHelperText: FormHelperTextClassKey;
MuiFormLabel: FormLabelClassKey;
MuiGrid: GridClassKey;
MuiGrid2: Grid2Slot;
MuiGrid2: Grid2ClassKey;
MuiIcon: IconClassKey;
MuiIconButton: IconButtonClassKey;
MuiImageList: ImageListClassKey;
Expand Down

0 comments on commit 6b96951

Please sign in to comment.