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

Ref/change-loading-folder #937

Closed
Closed
Show file tree
Hide file tree
Changes from all 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
44 changes: 0 additions & 44 deletions app/loading.tsx

This file was deleted.

60 changes: 60 additions & 0 deletions components/skeletons/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React from "react";
import { Skeleton, CircularProgress } from "@mui/material";
import { Lock } from "@mui/icons-material";

type LoadingType = "skeleton" | "spinner";

interface LoadingWrapperProps {
isLoading: boolean;
loadingType?: LoadingType;
children: React.ReactNode;
width?: string | number;
height?: string | number;
skeletonTextWidth?: string | number;
}

const Loading: React.FC<LoadingWrapperProps> = ({
isLoading,
loadingType = "skeleton",
children,
width = "100%",
height = 100,
skeletonTextWidth = 80,
}) => {
if (!isLoading) return <>{children}</>;
switch (loadingType) {
case "skeleton":
return (
<div style={{ position: 'relative', width, height }}>
<Skeleton
sx={{ bgcolor: "grey.600" }}
variant="rectangular"
width="100%"
height="100%"
aria-busy="true"
/>
<div style={{
position: 'absolute',
top: '50%',
left: '50%',
transform: 'translate(-50%, -50%)',
display: 'flex',
alignItems: 'center'
}}>
<Lock sx={{ marginRight: 1 }} aria-hidden="true" /> {/* Privacy Icon */}
<Skeleton variant="text" width={skeletonTextWidth} />
</div>
</div>
);
case "spinner":
return (
<div className="flex justify-center items-center w-full h-[350px]">
<CircularProgress aria-busy="true"/>
</div>
);
default:
return null;
}
};

export default Loading;