Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DataGrid] Add Skeleton loading overlay support #13293

Merged
merged 35 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5242c9a
[DataGrid] Add GridSkeletonLoadingOverlay
KenanYusuf May 27, 2024
a2b1bb0
allow users to set a variant and noRowsVariant through loadingOverlay…
KenanYusuf May 29, 2024
d32fa8b
fix selector usage
KenanYusuf May 29, 2024
d45dfdd
use useGridApiEventHandler for event subscriptions
KenanYusuf May 29, 2024
e8c9e0f
remove skeleton export
KenanYusuf May 29, 2024
e05cf1d
apply solid background colour to skeleton overlay
KenanYusuf May 30, 2024
4373460
rename random number generator function and expand on comment
KenanYusuf May 30, 2024
f9d5442
Update packages/x-data-grid/src/components/GridSkeletonLoadingOverlay…
KenanYusuf May 31, 2024
d745a3e
update GridLoadingOverlay to use props destructuring convention
KenanYusuf May 31, 2024
6cf0ffa
update RNG comments
KenanYusuf May 31, 2024
e91886f
Update packages/x-data-grid/src/components/GridSkeletonLoadingOverlay…
KenanYusuf May 31, 2024
721e78a
reuse GridSkeletonCell component in skeleton loading overlay
KenanYusuf May 31, 2024
ceb9c7e
make skeleton loader flow with scroll container
KenanYusuf Jun 3, 2024
e98680e
import syntax
KenanYusuf Jun 3, 2024
09118fb
update classes docs
KenanYusuf Jun 4, 2024
650ae4e
overlays documentation
KenanYusuf Jun 4, 2024
7c226b6
remove skeleton overlay class from public api
KenanYusuf Jun 4, 2024
bdbfeb5
support pinned columns
KenanYusuf Jun 5, 2024
6413802
remove row hover style and expose rowSkeleton class
KenanYusuf Jun 5, 2024
5d54f01
add filler cell if the columns do not take up the full width of the row
KenanYusuf Jun 5, 2024
5e736e9
Merge branch 'master' into skeleton-loading-overlay
KenanYusuf Jun 6, 2024
eda2557
set width var directly on skeleton cell
KenanYusuf Jun 21, 2024
7de9a56
fix pinned cell offset position during resize
KenanYusuf Jun 21, 2024
027cf4b
Merge branch 'master' into skeleton-loading-overlay
KenanYusuf Jun 21, 2024
78641bc
Merge branch 'master' into skeleton-loading-overlay
KenanYusuf Jun 24, 2024
5f295da
Merge branch 'master' into skeleton-loading-overlay
KenanYusuf Jun 26, 2024
0e0e8cc
Update custom loading overlay example
KenanYusuf Jun 26, 2024
5567ef3
add scrollbar filler cell
KenanYusuf Jun 26, 2024
be974f5
separate variant demo into multiple demos
KenanYusuf Jun 26, 2024
7bd1b49
Update docs/data/data-grid/overlays/LoadingOverlaySkeleton.tsx
KenanYusuf Jul 1, 2024
c6f6617
Merge branch 'mui:master' into skeleton-loading-overlay
KenanYusuf Jul 2, 2024
6dc2f5d
update demos
KenanYusuf Jul 2, 2024
65da878
optimizations from code review
KenanYusuf Jul 3, 2024
c92a3a3
fix sectionLength and sectionIndex for middle section skeleton cells
KenanYusuf Jul 3, 2024
ba615d4
Merge branch 'mui:master' into skeleton-loading-overlay
KenanYusuf Jul 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/data/data-grid/overlays/LoadingOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function LoadingOverlay() {
});

return (
<Box sx={{ width: '100%', height: 340 }}>
<Box sx={{ width: '100%', height: 400 }}>
<DataGrid {...data} loading />
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion docs/data/data-grid/overlays/LoadingOverlay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function LoadingOverlay() {
});

return (
<Box sx={{ width: '100%', height: 340 }}>
<Box sx={{ width: '100%', height: 400 }}>
<DataGrid {...data} loading />
</Box>
);
Expand Down
60 changes: 58 additions & 2 deletions docs/data/data-grid/overlays/LoadingOverlayCustom.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,63 @@
import * as React from 'react';
import { DataGrid } from '@mui/x-data-grid';
import LinearProgress from '@mui/material/LinearProgress';
import { useDemoData } from '@mui/x-data-grid-generator';
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import CircularProgress from '@mui/material/CircularProgress';

const StyledGridOverlay = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
height: '100%',
backgroundColor:
theme.palette.mode === 'light'
? 'rgba(255, 255, 255, 0.9)'
: 'rgba(18, 18, 18, 0.9)',
}));

function CircularProgressWithLabel(props) {
return (
<Box sx={{ position: 'relative', display: 'inline-flex' }}>
<CircularProgress variant="determinate" {...props} />
<Box
sx={{
position: 'absolute',
inset: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Typography variant="caption" component="div" color="text.primary">
{`${Math.round(props.value)}%`}
</Typography>
</Box>
</Box>
);
}

function CustomLoadingOverlay() {
const [progress, setProgress] = React.useState(10);

React.useEffect(() => {
const timer = setInterval(() => {
setProgress((prevProgress) => (prevProgress >= 100 ? 0 : prevProgress + 10));
}, 800);
return () => {
clearInterval(timer);
};
}, []);

return (
<StyledGridOverlay>
<CircularProgressWithLabel value={progress} />
<Box sx={{ mt: 2 }}>Loading rows…</Box>
</StyledGridOverlay>
);
}

export default function LoadingOverlayCustom() {
const { data } = useDemoData({
Expand All @@ -14,7 +70,7 @@ export default function LoadingOverlayCustom() {
<div style={{ height: 400, width: '100%' }}>
<DataGrid
slots={{
loadingOverlay: LinearProgress,
loadingOverlay: CustomLoadingOverlay,
KenanYusuf marked this conversation as resolved.
Show resolved Hide resolved
}}
loading
{...data}
Expand Down
68 changes: 65 additions & 3 deletions docs/data/data-grid/overlays/LoadingOverlayCustom.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,69 @@
import * as React from 'react';
import { DataGrid, GridSlots } from '@mui/x-data-grid';
import LinearProgress from '@mui/material/LinearProgress';
import { DataGrid } from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Typography from '@mui/material/Typography';
import CircularProgress, {
CircularProgressProps,
} from '@mui/material/CircularProgress';

const StyledGridOverlay = styled('div')(({ theme }) => ({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
height: '100%',
backgroundColor:
theme.palette.mode === 'light'
? 'rgba(255, 255, 255, 0.9)'
: 'rgba(18, 18, 18, 0.9)',
}));

function CircularProgressWithLabel(
props: CircularProgressProps & { value: number },
) {
return (
<Box sx={{ position: 'relative', display: 'inline-flex' }}>
<CircularProgress variant="determinate" {...props} />
<Box
sx={{
position: 'absolute',
inset: 0,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
}}
>
<Typography
variant="caption"
component="div"
color="text.primary"
>{`${Math.round(props.value)}%`}</Typography>
</Box>
</Box>
);
}

function CustomLoadingOverlay() {
const [progress, setProgress] = React.useState(10);

React.useEffect(() => {
const timer = setInterval(() => {
setProgress((prevProgress) => (prevProgress >= 100 ? 0 : prevProgress + 10));
}, 800);
return () => {
clearInterval(timer);
};
}, []);

return (
<StyledGridOverlay>
<CircularProgressWithLabel value={progress} />
<Box sx={{ mt: 2 }}>Loading rows…</Box>
</StyledGridOverlay>
);
}

export default function LoadingOverlayCustom() {
const { data } = useDemoData({
Expand All @@ -14,7 +76,7 @@ export default function LoadingOverlayCustom() {
<div style={{ height: 400, width: '100%' }}>
<DataGrid
slots={{
loadingOverlay: LinearProgress as GridSlots['loadingOverlay'],
loadingOverlay: CustomLoadingOverlay,
}}
loading
{...data}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<DataGrid
slots={{
loadingOverlay: LinearProgress as GridSlots['loadingOverlay'],
loadingOverlay: CustomLoadingOverlay,
}}
loading
{...data}
Expand Down
27 changes: 27 additions & 0 deletions docs/data/data-grid/overlays/LoadingOverlayLinearProgress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { useDemoData } from '@mui/x-data-grid-generator';
import { DataGrid } from '@mui/x-data-grid';

export default function LoadingOverlayLinearProgress() {
const { data } = useDemoData({
dataSet: 'Commodity',
rowLength: 100,
maxColumns: 6,
});

return (
<Box sx={{ width: '100%', height: 400 }}>
<DataGrid
{...data}
loading
slotProps={{
loadingOverlay: {
variant: 'linear-progress',
noRowsVariant: 'linear-progress',
},
}}
/>
</Box>
);
}
27 changes: 27 additions & 0 deletions docs/data/data-grid/overlays/LoadingOverlayLinearProgress.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { useDemoData } from '@mui/x-data-grid-generator';
import { DataGrid } from '@mui/x-data-grid';

export default function LoadingOverlayLinearProgress() {
const { data } = useDemoData({
dataSet: 'Commodity',
rowLength: 100,
maxColumns: 6,
});

return (
<Box sx={{ width: '100%', height: 400 }}>
<DataGrid
{...data}
loading
slotProps={{
loadingOverlay: {
variant: 'linear-progress',
noRowsVariant: 'linear-progress',
},
}}
/>
</Box>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<DataGrid
{...data}
loading
slotProps={{
loadingOverlay: {
variant: 'linear-progress',
noRowsVariant: 'linear-progress',
},
}}
/>
32 changes: 32 additions & 0 deletions docs/data/data-grid/overlays/LoadingOverlaySkeleton.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { useDemoData } from '@mui/x-data-grid-generator';
import { DataGridPro } from '@mui/x-data-grid-pro';

export default function LoadingOverlaySkeleton() {
const { data } = useDemoData({
dataSet: 'Commodity',
rowLength: 100,
maxColumns: 9,
});

return (
<Box sx={{ width: '100%', height: 400 }}>
<DataGridPro
{...data}
loading
slotProps={{
loadingOverlay: {
variant: 'skeleton',
noRowsVariant: 'skeleton',
},
}}
initialState={{
pinnedColumns: {
left: ['desk'],
},
}}
/>
</Box>
);
}
32 changes: 32 additions & 0 deletions docs/data/data-grid/overlays/LoadingOverlaySkeleton.tsx
MBilalShafi marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import * as React from 'react';
import Box from '@mui/material/Box';
import { useDemoData } from '@mui/x-data-grid-generator';
import { DataGridPro } from '@mui/x-data-grid-pro';

export default function LoadingOverlaySkeleton() {
const { data } = useDemoData({
dataSet: 'Commodity',
rowLength: 100,
maxColumns: 9,
});

return (
<Box sx={{ width: '100%', height: 400 }}>
<DataGridPro
{...data}
loading
slotProps={{
loadingOverlay: {
variant: 'skeleton',
noRowsVariant: 'skeleton',
},
}}
initialState={{
pinnedColumns: {
left: ['desk'],
},
}}
/>
</Box>
);
}
15 changes: 15 additions & 0 deletions docs/data/data-grid/overlays/LoadingOverlaySkeleton.tsx.preview
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<DataGridPro
{...data}
loading
slotProps={{
loadingOverlay: {
variant: 'skeleton',
noRowsVariant: 'skeleton',
},
}}
initialState={{
pinnedColumns: {
left: ['desk'],
},
}}
/>
Loading
Loading