Path: blob/main/components/dashboard/src/app/AppLoading.tsx
2499 views
/**1* Copyright (c) 2022 Gitpod GmbH. All rights reserved.2* Licensed under the GNU Affero General Public License (AGPL).3* See License.AGPL.txt in the project root for license information.4*/56import { FunctionComponent, useEffect, useState } from "react";7import { Heading3, Subheading } from "../components/typography/headings";8import { Delayed } from "@podkit/loading/Delayed";9import { ProductLogo } from "../components/ProductLogo";1011function useDelay(wait: number) {12const [done, setDone] = useState(false);13useEffect(() => {14const timeout = setTimeout(() => setDone(true), wait);15return () => clearTimeout(timeout);16// eslint-disable-next-line react-hooks/exhaustive-deps17}, [wait]);18return done;19}2021export const AppLoading: FunctionComponent = () => {22const done = useDelay(8000);23const connectionProblems = useDelay(25000);24return (25<Delayed wait={3000}>26<div className="flex flex-col justify-center items-center w-full h-screen space-y-4">27<ProductLogo className={"h-16 flex-shrink-0 animate-fade-in"} />28{connectionProblems ? (29<Heading3 className={done ? "" : "invisible"}>This is taking longer than it should</Heading3>30) : (31<Heading3 className={done ? "animate-fade-in" : "invisible"}>32Just getting a few more things ready33</Heading3>34)}35{connectionProblems ? (36<Subheading className={done ? "max-w-xl text-center" : "invisible"}>37It seems like you are having connection issues. Please check your network connection. Sometimes38this problem can also be caused by a slow browser with too many tabs and/or extensions.39</Subheading>40) : (41<Subheading className={done ? "animate-fade-in" : "invisible"}>hang in there...</Subheading>42)}43</div>44</Delayed>45);46};474849