From d321f269c925e95a037275b392b9929a7a5c1d86 Mon Sep 17 00:00:00 2001 From: Sidney Alcantara Date: Mon, 6 Sep 2021 22:41:23 +1000 Subject: [PATCH] add ErrorBoundary, Loading in Navigation --- src/components/EmptyState.tsx | 61 ++++++++++++----------------- src/components/Loading.tsx | 48 ++++++++--------------- src/components/Navigation/index.tsx | 14 ++++++- 3 files changed, 53 insertions(+), 70 deletions(-) diff --git a/src/components/EmptyState.tsx b/src/components/EmptyState.tsx index 32e7da8b..ef5f919b 100644 --- a/src/components/EmptyState.tsx +++ b/src/components/EmptyState.tsx @@ -1,7 +1,5 @@ -import clsx from "clsx"; import Div100vh from "react-div-100vh"; -import { makeStyles, createStyles } from "@material-ui/styles"; import { Grid, GridProps, @@ -12,33 +10,6 @@ import { import { OverridableComponent } from "@material-ui/core/OverridableComponent"; import ErrorIcon from "@material-ui/icons/ErrorOutline"; -const useStyles = makeStyles((theme) => - createStyles({ - root: { - height: "100%", - width: "100%", - textAlign: "center", - - ...theme.typography.body2, - }, - - content: { - "&&": { maxWidth: "25em" }, - }, - - icon: { - color: theme.palette.action.active, - fontSize: "3rem", - }, - - message: { - marginTop: theme.spacing(1), - }, - - basicIcon: { display: "block" }, - }) -); - export interface IEmptyStateProps extends Partial { /** Primary message displayed under the icon */ message?: React.ReactNode; @@ -65,13 +36,11 @@ export default function EmptyState({ basic = false, ...props }: IEmptyStateProps) { - const classes = useStyles({}); - if (basic) return ( - + @@ -89,18 +58,36 @@ export default function EmptyState({ justifyContent="center" alignItems="center" component={fullScreen ? Div100vh : "div"} - style={{ height: fullScreen ? "100rvh" : "100%" }} {...props} - className={clsx(classes.root, props.className)} + style={{ + width: "100%", + height: fullScreen ? "100rvh" : "100%", + textAlign: "center", + ...props.style, + }} > - - + + {message} diff --git a/src/components/Loading.tsx b/src/components/Loading.tsx index 9209b03f..5333c9f8 100644 --- a/src/components/Loading.tsx +++ b/src/components/Loading.tsx @@ -1,21 +1,7 @@ import Div100vh from "react-div-100vh"; -import { makeStyles, createStyles } from "@material-ui/styles"; -import { Grid, CircularProgress, Typography } from "@material-ui/core"; - -const useStyles = makeStyles((theme) => - createStyles({ - root: { - height: "100%", - width: "100%", - textAlign: "center", - }, - progress: { color: theme.palette.action.active }, - content: { maxWidth: "25em" }, - message: { marginTop: theme.spacing(1) }, - }) -); -interface ILoading { +import { Stack, StackProps,CircularProgress, Typography } from "@material-ui/core"; +interface ILoadingProps extends Partial { message?: string; fullScreen?: boolean; } @@ -23,25 +9,25 @@ interface ILoading { export default function Loading({ message = "Loading", fullScreen = false, -}: ILoading) { - const classes = useStyles({}); - + ...props +}: ILoadingProps) { return ( - - - - - {message} - - - + + + {message} + + ); } diff --git a/src/components/Navigation/index.tsx b/src/components/Navigation/index.tsx index 986689eb..9cfb6c0f 100644 --- a/src/components/Navigation/index.tsx +++ b/src/components/Navigation/index.tsx @@ -1,4 +1,4 @@ -import { ReactNode, useState } from "react"; +import { ReactNode, useState, Suspense } from "react"; import { useScrollTrigger, @@ -12,6 +12,8 @@ import MenuIcon from "@material-ui/icons/Menu"; import NavDrawer from "./NavDrawer"; import UserMenu from "./UserMenu"; +import ErrorBoundary from "components/ErrorBoundary"; +import Loading from "components/Loading"; import { name } from "@root/package.json"; import { projectId } from "@src/firebase"; @@ -103,7 +105,15 @@ export default function Navigation({ currentSection={currentSection} /> - {children} + + + } + > + {children} + + ); }