From 935b47bbf86317cdcd64c1dd5fb4ff2fdee53009 Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Fri, 24 Jan 2020 22:31:23 +0100 Subject: [PATCH] random recipe ok --- src/App.css | 37 ++++----------------------------- src/App.js | 34 +++++++++++++++++++++++++----- src/components/CopyrightText.js | 9 +++++++- src/components/Navbar.js | 2 +- src/components/RandomButton.js | 9 ++++++-- src/pages/Home.js | 29 +++++++++++--------------- src/pages/Meal.js | 14 ++++++------- 7 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/App.css b/src/App.css index 74b5e05..c94ab51 100644 --- a/src/App.css +++ b/src/App.css @@ -1,38 +1,9 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; +body { display: flex; + min-height: 100vh; flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; } -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } +main { + flex: 1 0 auto; } diff --git a/src/App.js b/src/App.js index 5328c90..682520d 100644 --- a/src/App.js +++ b/src/App.js @@ -6,11 +6,11 @@ import SearchPage from "./pages/Search"; import NotFound from "./pages/NotFound"; import Navbar from "./components/Navbar"; import Footer from "./components/Footer"; +// import "./App.css"; const App = () => { const [searchString, setSearchString] = useState(""); - - const mealItem = { + const mealDef = { meals: [ { idMeal: "52837", @@ -69,24 +69,48 @@ const App = () => { } ] }; + const [mealItem, setMeal] = useState(mealDef); + const URI = "https://www.themealdb.com/api/json/v1/1/random.php"; + + const getMeal = () => { + fetch(URI) + .then(response => response.json()) + .then(mealItem => setMeal(mealItem)); + }; + + // const { mealItem } = meal; const handleChange = ev => { const { value } = ev.target; setSearchString(value); }; + const handleClick = () => { + getMeal(); + }; + return ( - + - + ( + + )} + /> } /> - {/* We'll have to input searchString somewhere */} + {/* We'll have to input searchResults somewhere */}