Added a loading spinner

This commit is contained in:
Mitchell McCaffrey 2020-04-14 17:36:25 +10:00
parent cf814c77f1
commit 29a0851c08
5 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,26 @@
import React from "react";
import { Box } from "theme-ui";
import Spinner from "./Spinner";
function LoadingOverlay() {
return (
<Box
sx={{
position: "absolute",
width: "100%",
height: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center",
top: 0,
left: 0,
}}
bg="muted"
>
<Spinner />
</Box>
);
}
export default LoadingOverlay;

View File

@ -0,0 +1,13 @@
.spinner {
width: 32px;
height: 32px;
position: relative;
animation: rotate 2s infinite linear;
}
@keyframes rotate {
100% {
transform: rotate(360deg);
}
}

24
src/components/Spinner.js Normal file
View File

@ -0,0 +1,24 @@
import React from "react";
import { Box } from "theme-ui";
import "./Spinner.css";
import spinnerImage from "../images/Loading.png";
function Spinner() {
return (
<Box className="spinner">
<Box
sx={{
backgroundImage: `url(${spinnerImage})`,
width: "100%",
height: "100%",
position: "absolute",
top: 0,
backgroundSize: "contain",
}}
></Box>
</Box>
);
}
export default Spinner;

BIN
src/images/Loading.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

View File

@ -16,6 +16,7 @@ import Party from "../components/Party";
import Tokens from "../components/Tokens";
import Map from "../components/Map";
import Banner from "../components/Banner";
import LoadingOverlay from "../components/LoadingOverlay";
import AuthModal from "../modals/AuthModal";
@ -249,6 +250,7 @@ function Game() {
</Box>
</Banner>
<AuthModal isOpen={authenticationStatus === "unauthenticated"} />
{authenticationStatus === "unknown" && <LoadingOverlay />}
</>
);
}