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

feat(mui): added loading spinner to <Create/>, <Edit/> and <Show/> components. #6271

Merged
merged 5 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
9 changes: 9 additions & 0 deletions .changeset/nasty-glasses-care.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"@refinedev/mui": minor
---

feat(mui): added loading spinner to `<Create />`, `<Edit />` and `<Show />` components

This change introduces a loading spinner to the `<Create />`, `<Edit />` and `<Show />` components in the `@refinedev/mui` package. The spinner provides a visual indication that data is being loaded, improving the user experience bym giving clear feedback during loading states.

[Resolves #5668](https://github.com/refinedev/refine/issues/5668)
Original file line number Diff line number Diff line change
Expand Up @@ -9866,7 +9866,7 @@ exports[`MuiInferencer should match the snapshot 2`] = `
<DocumentFragment>
<div>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-bhp9pd-MuiPaper-root-MuiCard-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-4ob670-MuiPaper-root-MuiCard-root"
>
<nav
aria-label="breadcrumb"
Expand Down Expand Up @@ -24770,7 +24770,7 @@ exports[`MuiInferencer should match the snapshot 3`] = `
<DocumentFragment>
<div>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-bhp9pd-MuiPaper-root-MuiCard-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-4ob670-MuiPaper-root-MuiCard-root"
>
<nav
aria-label="breadcrumb"
Expand Down Expand Up @@ -40779,7 +40779,7 @@ exports[`MuiInferencer should match the snapshot 4`] = `
<DocumentFragment>
<div>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-bhp9pd-MuiPaper-root-MuiCard-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-4ob670-MuiPaper-root-MuiCard-root"
>
<nav
aria-label="breadcrumb"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`MuiCreateInferencer should match the snapshot 1`] = `
<DocumentFragment>
<div>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-bhp9pd-MuiPaper-root-MuiCard-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-4ob670-MuiPaper-root-MuiCard-root"
>
<div
class="MuiCardHeader-root css-94f51d-MuiCardHeader-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`MuiEditInferencer should match the snapshot 1`] = `
<DocumentFragment>
<div>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-bhp9pd-MuiPaper-root-MuiCard-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-4ob670-MuiPaper-root-MuiCard-root"
>
<div
class="MuiCardHeader-root css-94f51d-MuiCardHeader-root"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`MuiShowInferencer should match the snapshot 1`] = `
<DocumentFragment>
<div>
<div
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-bhp9pd-MuiPaper-root-MuiCard-root"
class="MuiPaper-root MuiPaper-elevation MuiPaper-rounded MuiPaper-elevation1 MuiCard-root css-4ob670-MuiPaper-root-MuiCard-root"
>
<div
class="MuiCardHeader-root css-94f51d-MuiCardHeader-root"
Expand Down
27 changes: 26 additions & 1 deletion packages/mui/src/components/crud/create/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import CardContent from "@mui/material/CardContent";
import IconButton from "@mui/material/IconButton";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import CircularProgress from "@mui/material/CircularProgress";

import { alpha } from "@mui/system";

import ArrowBackIcon from "@mui/icons-material/ArrowBack";

Expand Down Expand Up @@ -78,7 +81,29 @@ export const Create: React.FC<CreateProps> = ({
const defaultFooterButtons = <SaveButton {...saveButtonProps} />;

return (
<Card {...(wrapperProps ?? {})}>
<Card
{...(wrapperProps ?? {})}
sx={{
position: "relative",
...wrapperProps?.sx,
}}
>
{isLoading && (
<Box
sx={{
position: "absolute",
inset: 0,
display: "flex",
justifyContent: "center",
alignItems: "center",
zIndex: (theme) => theme.zIndex.drawer + 1,
// this is needed to support custom themes, dark mode etc.
bgcolor: (theme) => alpha(theme.palette.background.paper, 0.4),
}}
>
<CircularProgress />
</Box>
)}
{breadcrumbComponent}
<CardHeader
sx={{
Expand Down
27 changes: 26 additions & 1 deletion packages/mui/src/components/crud/edit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ import CardContent from "@mui/material/CardContent";
import CardActions from "@mui/material/CardActions";
import Typography from "@mui/material/Typography";
import Box from "@mui/material/Box";
import CircularProgress from "@mui/material/CircularProgress";

import { alpha } from "@mui/system";

import ArrowBackIcon from "@mui/icons-material/ArrowBack";

Expand Down Expand Up @@ -165,7 +168,29 @@ export const Edit: React.FC<EditProps> = ({
);

return (
<Card {...(wrapperProps ?? {})}>
<Card
{...(wrapperProps ?? {})}
sx={{
position: "relative",
...wrapperProps?.sx,
}}
>
{isLoading && (
<Box
sx={{
position: "absolute",
inset: 0,
display: "flex",
justifyContent: "center",
alignItems: "center",
zIndex: (theme) => theme.zIndex.drawer + 1,
// this is needed to support custom themes, dark mode etc.
bgcolor: (theme) => alpha(theme.palette.background.paper, 0.4),
}}
>
<CircularProgress />
</Box>
)}
{breadcrumbComponent}
<CardHeader
sx={{
Expand Down
27 changes: 26 additions & 1 deletion packages/mui/src/components/crud/show/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import CardHeader from "@mui/material/CardHeader";
import IconButton from "@mui/material/IconButton";
import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography";
import CircularProgress from "@mui/material/CircularProgress";

import { alpha } from "@mui/system";

import ArrowBackIcon from "@mui/icons-material/ArrowBack";

Expand Down Expand Up @@ -148,7 +151,29 @@ export const Show: React.FC<ShowProps> = ({
);

return (
<Card {...(wrapperProps ?? {})}>
<Card
{...(wrapperProps ?? {})}
sx={{
position: "relative",
...wrapperProps?.sx,
}}
>
{isLoading && (
<Box
sx={{
position: "absolute",
inset: 0,
display: "flex",
justifyContent: "center",
alignItems: "center",
zIndex: (theme) => theme.zIndex.drawer + 1,
// this is needed to support custom themes, dark mode etc.
bgcolor: (theme) => alpha(theme.palette.background.paper, 0.4),
}}
>
<CircularProgress />
</Box>
)}
{breadcrumbComponent}
<CardHeader
sx={{
Expand Down
Loading