Skip to content

Commit

Permalink
feat(app): added loading screen (passportxyz#1177)
Browse files Browse the repository at this point in the history
* feat(app): added loading screen

* fix(app): use context loading state to show loader

---------

Co-authored-by: schultztimothy <[email protected]>
  • Loading branch information
lucianHymer and tim-schultz authored Apr 24, 2023
1 parent b89ea7d commit ee65229
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 16 deletions.
12 changes: 12 additions & 0 deletions app/components/LoadingScreen.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";

const LoadingScreen = () => {
return (
<div className="flex h-1/2 flex-col place-content-center text-center text-3xl text-color-2">
Loading...
<img className="mt-2 h-12 animate-bounce" src={"/assets/passportLogoWhite.svg"} alt="Gitcoin Logo" />
</div>
);
};

export default LoadingScreen;
38 changes: 22 additions & 16 deletions app/pages/Welcome.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ import { PossibleEVMProvider } from "../signer/utils";
import { useDisclosure } from "@chakra-ui/react";

// --- Contexts
import { CeramicContext } from "../context/ceramicContext";
import { CeramicContext, IsLoadingPassportState } from "../context/ceramicContext";
import { UserContext } from "../context/userContext";
import { InitialWelcome } from "../components/InitialWelcome";
import LoadingScreen from "../components/LoadingScreen";

export default function Welcome() {
const { isOpen, onOpen, onClose } = useDisclosure();
const { passport, allPlatforms } = useContext(CeramicContext);
const { passport, allPlatforms, isLoadingPassport } = useContext(CeramicContext);
const { wallet, address } = useContext(UserContext);

const navigate = useNavigate();
Expand Down Expand Up @@ -191,21 +192,26 @@ export default function Welcome() {
</div>
<PageWidthGrid>
<div className="col-span-4 flex flex-col items-center text-center md:col-start-2 lg:col-start-3 xl:col-span-6 xl:col-start-4">
{passport && passport.stamps.length > 0 ? (
<WelcomeBack
handleFetchPossibleEVMStamps={handleFetchPossibleEVMStamps}
onOpen={onOpen}
resetStampsAndProgressState={resetStampsAndProgressState}
/>
{isLoadingPassport === IsLoadingPassportState.Idle ||
isLoadingPassport === IsLoadingPassportState.FailedToConnect ? (
passport && passport.stamps.length > 0 ? (
<WelcomeBack
handleFetchPossibleEVMStamps={handleFetchPossibleEVMStamps}
onOpen={onOpen}
resetStampsAndProgressState={resetStampsAndProgressState}
/>
) : (
<InitialWelcome
onBoardFinished={async () => {
if (address) {
await handleFetchPossibleEVMStamps(address, allPlatforms);
onOpen();
}
}}
/>
)
) : (
<InitialWelcome
onBoardFinished={async () => {
if (address) {
await handleFetchPossibleEVMStamps(address, allPlatforms);
onOpen();
}
}}
/>
<LoadingScreen />
)}
</div>
</PageWidthGrid>
Expand Down

0 comments on commit ee65229

Please sign in to comment.