From 2e19128324781f454de19c8688e783e817effd35 Mon Sep 17 00:00:00 2001 From: Eray C Date: Mon, 1 Nov 2021 13:25:19 +0100 Subject: [PATCH] ref: Initialize App with a loading page --- public/public.css | 3 +++ src/App.css | 4 ++-- src/App.jsx | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 public/public.css create mode 100644 src/App.jsx diff --git a/public/public.css b/public/public.css new file mode 100644 index 0000000..b5c61c9 --- /dev/null +++ b/public/public.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/src/App.css b/src/App.css index 1f088a0..d4b4e80 100644 --- a/src/App.css +++ b/src/App.css @@ -16,7 +16,7 @@ code { monospace; } -.App { +/* .App { text-align: center; } @@ -53,4 +53,4 @@ code { to { transform: rotate(360deg); } -} +} */ diff --git a/src/App.jsx b/src/App.jsx new file mode 100644 index 0000000..a76ca64 --- /dev/null +++ b/src/App.jsx @@ -0,0 +1,60 @@ +import * as React from "react"; +import "./index.css"; + +// Components +import { Loading } from "./components/Loading"; +import { Navbar } from "./components/Navbar"; + +// Views +import { ChooseBread } from "./views/ChooseBread"; +import { ChooseMeat } from "./views/ChooseMeat"; +import { ChooseVegetables } from "./views/ChooseVegetables"; +import { ChooseSauces } from "./views/ChooseSauces"; + +import { defaultOrder } from "./data"; + +class App extends React.Component { + constructor() { + super(); + this.state = { + currentOrder: defaultOrder, + isLoading: true, + timerHandle: null, + }; + } + + componentDidMount() { + this.timerHandle = setTimeout( + () => this.setState({ isLoading: false }), + 2500 + ); + } + + componentWillUnmount() { + if (this.timerHandle) { + clearTimeout(this.timerHandle); + this.timerHandle = null; + } + } + + render() { + if (this.state.isLoading) { + return ( + // +
its loading
+ ); + } + + return ( +
+ {/* */} + {/* */} + + {/* */} + {/* */} +
+ ); + } +} + +export default App;