);
};
diff --git a/src/components/SearchBar.jsx b/src/components/SearchBar.jsx
index 68a636a..82a55f9 100644
--- a/src/components/SearchBar.jsx
+++ b/src/components/SearchBar.jsx
@@ -4,28 +4,38 @@ import { Link } from "react-router-dom";
export const SearchBar = props => {
return (
-
);
diff --git a/src/components/SideNav.jsx b/src/components/SideNav.jsx
new file mode 100644
index 0000000..f7239ec
--- /dev/null
+++ b/src/components/SideNav.jsx
@@ -0,0 +1,59 @@
+import React, { useState } from "react";
+import { Link } from "react-router-dom";
+// import { useAuth0 } from "../utils/auth0-spa";
+// import { Logo } from "./Logo";
+// import { RandomButton } from "./RandomButton";
+// import { FooterLink } from "./FooterLink";
+// import { LogInButton } from "./LogInButton";
+// import { LogOutButton } from "./LogOutButton";
+
+export const SideNav = props => {
+ const { showNav } = props;
+
+ let transformStyle = {
+ transform: showNav ? "translateX(0%)" : "translateX(-105%)"
+ };
+ // let sideNavStyle = { width: showNav ? "250px" : "0" };
+
+ return (
+ <>
+
+ >
+ );
+};
diff --git a/src/index.js b/src/index.js
index de7f2d0..50556c8 100644
--- a/src/index.js
+++ b/src/index.js
@@ -1,7 +1,7 @@
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
-import { App } from "./App";
+import { App } from "./pages/App.jsx";
import * as serviceWorker from "./serviceWorker";
import { Auth0Provider } from "./utils/auth0-spa";
import history from "./utils/history";
diff --git a/src/App.js b/src/pages/App.jsx
similarity index 51%
rename from src/App.js
rename to src/pages/App.jsx
index 109a2d7..f9fbb97 100644
--- a/src/App.js
+++ b/src/pages/App.jsx
@@ -1,23 +1,24 @@
import React, { useState } from "react";
-import { Router } from "./utils/router";
+import { Router } from "../utils/router";
import { Switch, Route, Redirect } from "react-router-dom";
-import { useAuth0 } from "./utils/auth0-spa";
-import { Home } from "./pages/Home";
-import { Meal } from "./pages/Meal";
-import { SearchPage } from "./pages/Search";
-import { CategoryListPage } from "./pages/CategoryList";
-import { CategoryPage } from "./pages/Category";
-import { ContactPage } from "./pages/Contact";
-import { NotFoundPage } from "./pages/NotFound";
-import { Navbar } from "./components/Navbar";
-import { SearchBar } from "./components/SearchBar";
-import { Footer } from "./components/Footer";
-import "./index.css";
-import { getData } from "./utils/methods";
-import history from "./utils/history";
-import { Profile } from "./pages/Profile";
-import { PrivateRoute } from "./components/PrivateRoute";
-import { PreLoader } from "./components/PreLoader";
+import { useAuth0 } from "../utils/auth0-spa";
+import { Home } from "./Home";
+import { Meal } from "./Meal";
+import { SearchPage } from "./Search";
+import { CategoryListPage } from "./CategoryList";
+import { CategoryPage } from "./Category";
+import { ContactPage } from "./Contact";
+import { NotFoundPage } from "./NotFound";
+import { Navbar } from "../components/Navbar";
+import { SearchBar } from "../components/SearchBar";
+import { Footer } from "../components/Footer";
+import { getData } from "../utils/methods";
+import history from "../utils/history";
+import { Profile } from "./Profile";
+import { PrivateRoute } from "../components/PrivateRoute";
+import { PreLoader } from "../components/PreLoader";
+import { SideNav } from "../components/SideNav";
+import "../index.css";
export const App = () => {
const { loading } = useAuth0();
@@ -35,7 +36,7 @@ export const App = () => {
strArea: "Mine",
strInstructions:
"Cook the pasta following pack instructions.\r\n\r\nHeat the oil in a non-stick frying pan and cook the onion, garlic and chilli for 3-4 mins to soften. Stir in the tomato pur\u00e9e and cook for 1 min, then add the pilchards with their sauce. Cook, breaking up the fish with a wooden spoon, then add the olives and continue to cook for a few more mins.\r\n\r\nDrain the pasta and add to the pan with 2-3 tbsp of the cooking water. Toss everything together well, then divide between plates and serve, scattered with Parmesan.",
- strMealThumb: require("./images/breakfast.svg"),
+ strMealThumb: require("../images/breakfast.svg"),
// "https://www.themealdb.com/images/media/meals/vvtvtr1511180578.jpg",
strTags: null,
strYoutube: "#",
@@ -109,80 +110,108 @@ export const App = () => {
const buttonUrl = "/random";
+ const [showNav, setShowNav] = useState(false);
+ const openNavClick = ev => {
+ ev.preventDefault();
+ setShowNav(true);
+ document.addEventListener("keydown", handleEscKey);
+ };
+ const closeNavClick = ev => {
+ ev.preventDefault();
+ setShowNav(false);
+ document.removeEventListener("keydown", handleEscKey);
+ };
+ const handleEscKey = ev => {
+ if (ev.key === "Escape") {
+ setShowNav(false);
+ }
+ };
+
return loading ? (
) : (
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {meal !== undefined && meal.meals !== null ? (
-
- ) : (
-
- )}
-
-
-
-
-
-
-
-
+
+
-
-
-
+
+
-
-
-
+
+
+
+
-
-
-
+
+
+
-
- {meal !== undefined && meal.meals !== null ? (
-
- ) : (
+
+ {meal !== undefined && meal.meals !== null ? (
+
+ ) : (
+
+ )}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
- )}
-
+
-
-
-
-
+
+ {meal !== undefined && meal.meals !== null ? (
+
+ ) : (
+
+ )}
+
-
-
+
+
+
+
+
+
+
+ >
);
};
diff --git a/src/pages/Contact.jsx b/src/pages/Contact.jsx
index 9444fa2..a8c6617 100644
--- a/src/pages/Contact.jsx
+++ b/src/pages/Contact.jsx
@@ -16,8 +16,8 @@ export const ContactPage = props => {
);
};
diff --git a/src/utils/inputHook.js b/src/utils/inputHook.js
new file mode 100644
index 0000000..77b8781
--- /dev/null
+++ b/src/utils/inputHook.js
@@ -0,0 +1,17 @@
+import { useState } from "react";
+
+export const useInput = initialValue => {
+ const [value, setValue] = useState(initialValue);
+
+ return {
+ value,
+ setValue,
+ reset: () => setValue(""),
+ bind: {
+ value,
+ onChange: ev => {
+ setValue(ev.target.value);
+ }
+ }
+ };
+};