DataGrid - Joy UI integration #6811
Replies: 8 comments 26 replies
-
|
As an alternative to 1., assuming that Grid subcomponents work with themes and they have configurable slots, there could be a theme provider setting the default values of function MaterialUIThemeProvider({children}) {
const materialUiTheme = createTheme({
components: {
GridPanel: {
defaultProps: {
slots: {
paper: MaterialPaper
...
}
}
}
}
});
return <ThemeProvider theme={materialUiTheme}>
{children}
</ThemeProvider>
} |
Beta Was this translation helpful? Give feedback.
-
This would work, but another option would be to keep adapters in the data grid packages and use nested imports: // Community
import { components as materialDataGridcomponents } from '@mui/x-data-grid/material';
import { components as joyDataGridcomponents } from '@mui/x-data-grid/joy';
// Pro
import { components as materialDataGridcomponents } from '@mui/x-data-grid-pro/material';
import { components as joyDataGridcomponents } from '@mui/x-data-grid-pro/joy';
// Premium
import { components as materialDataGridcomponents } from '@mui/x-data-grid-premium/material';
import { components as joyDataGridcomponents } from '@mui/x-data-grid-premium/joy';The Pros:
Cons:
What do you think? |
Beta Was this translation helpful? Give feedback.
-
Not sure I follow this one. |
Beta Was this translation helpful? Give feedback.
-
Nice, this looks great! |
Beta Was this translation helpful? Give feedback.
-
Does it mean that data grid has to export it's own theme? |
Beta Was this translation helpful? Give feedback.
-
If we follow https://www.notion.so/mui-org/Weekly-meeting-2022-10-18-0566064ded784ef786b163b1c8dff280#318f195cd796489bb3448cb9772cc1c4. I think that it's also an opportunity to use |
Beta Was this translation helpful? Give feedback.
-
|
One more problem to solve: How to get the theme inside of the It won't be possible once we decouple the data grid from the @mui/material package...
|
Beta Was this translation helpful? Give feedback.
-
|
Is this closed as no longer planned? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
@mui/material-nextis another design library)Ideal goals
Small breaking changes as much as possibleWe won't have a breaking change because@mui/materialis already a peer dependency. Need to update the build script to addpackage.jsontoDataGridJoyfolder.Direct usage of Material UI
Here is the list of the direct Material UI usage in DataGrid that should be extracted, so that DataGrid does not depend on Material UI:
1.
@mui/material/utilsThis should be safe to switch to
@mui/utilsand mark it as a dependency of DataGrid.Components on top of Material UI
For example, GridMenu is created by Popper, Grow, ...Material UI components.
mui-x/packages/grid/x-data-grid/src/components/menu/GridMenu.tsx
Line 110 in 514ed0d
Migration:
Convert these components into slots (DataGrid already provides a React context for doing this, so this should be fine).
Then create the mapping slots that use Material UI or Joy UI components. It could look like this:
Material UI Adapter package:
Joy UI Adapter package:
2. Material UI's
styledFor example, GridRowCount. These components are design-agnostic, so there is no need for them to move to slots.
mui-x/packages/grid/x-data-grid/src/components/GridRowCount.tsx
Line 33 in 2f186c3
Migration:
Switch to
styledfrom MUI System. The theming API does not differ, except thesxprop which will be fixed from the core repo. mui/material-ui#35150 moves thesxlogic to the theme, which allows each adapter to configure its ownsxlogic.Meaning, developers can use
sxprop for DataGrid components that are not slots:3. Material UI theme tokens
For example, GridOverlay
mui-x/packages/grid/x-data-grid/src/components/containers/GridOverlay.tsx
Line 38 in 2f186c3
Migration:
Move palette usage to CSS variables (the values will be defined in the GridRootStyles of each design adapter).
const GridOverlayRoot = styled('div', { name: 'MuiDataGrid', slot: 'Overlay', overridesResolver: (props, styles) => styles.overlay, })(({ theme }) => ({ ..., - backgroundColor: alpha(theme.palette.background.default, theme.palette.action.disabledOpacity), + backgroundColor: 'var(--mui-data-grid-overlay-bg)', }));For
theme.typography.*usage, we can set the specific typography system for the DataGrid:const GridEditInputCellRoot = styled(InputBase, { name: 'MuiDataGrid', slot: 'EditInputCell', overridesResolver: (props, styles) => styles.editInputCell, })(({ theme }) => ({ - ...theme.typography.body2, + ...theme.typography.datagrid?.small, // naming can be different. padding: '1px 0', '& input': { padding: '0 16px', height: '100%', }, }));Beta Was this translation helpful? Give feedback.
All reactions