Notice: rename Warn -> Notice and add composability

The Notice component can now act as a general indicator component,
exposing four types: "wait", "help", "warn", or "none". These types
display different icons and make this a much more reusable element.

We also render children passed to us, making this even more extendable.
In future, we may wish to extract all message props altogether as
children instead.
This commit is contained in:
rektdeckard
2020-10-07 15:43:00 -04:00
parent 3b0ef72c40
commit 757f12d2f3
3 changed files with 22 additions and 9 deletions

View File

@@ -6,7 +6,11 @@ import Toolbar from "../Toolbar/Toolbar";
import IconGrid from "../IconGrid/IconGrid";
import Footer from "../Footer/Footer";
import ErrorBoundary from "../ErrorBoundary/ErrorBoundary";
import Warn from "../Warn/Warn";
import Notice from "../Notice/Notice";
const errorFallback = <Notice message="Search error" />;
// const waitingFallback = <Notice type="wait" message="Loading..." />;
const waitingFallback = <Notice type="none" message="" />;
const App: React.FC<any> = () => {
return (
@@ -14,8 +18,8 @@ const App: React.FC<any> = () => {
<Header />
<main>
<Toolbar />
<ErrorBoundary fallback={<Warn message="Search error"/>}>
<Suspense fallback={<div>Loading...</div>}>
<ErrorBoundary fallback={errorFallback}>
<Suspense fallback={waitingFallback}>
<IconGrid />
</Suspense>
</ErrorBoundary>