├── src ├── key.js ├── components │ ├── index.js │ └── recipe-tile │ │ ├── style.css │ │ └── index.js ├── index.js ├── index.css ├── app.css └── App.js ├── public ├── robots.txt ├── favicon.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── .gitignore ├── package.json └── README.md /src/key.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/components/index.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theindianappguy/recipe-app-reactjs/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theindianappguy/recipe-app-reactjs/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/theindianappguy/recipe-app-reactjs/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import ReactDOM from "react-dom"; 3 | import "./index.css"; 4 | import App from "./App"; 5 | 6 | ReactDOM.render( 7 | 8 | 9 | , 10 | document.getElementById("root") 11 | ); 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/components/recipe-tile/style.css: -------------------------------------------------------------------------------- 1 | .recipeTile { 2 | display: flex; 3 | flex-direction: column; 4 | justify-content: center; 5 | align-items: center; 6 | cursor: pointer; 7 | } 8 | 9 | .recipeTile__img { 10 | height: 200px; 11 | width: 200px; 12 | object-fit: cover; 13 | border-radius: 4px; 14 | } 15 | 16 | .recipeTile__name { 17 | max-width: 200px; 18 | text-align: center; 19 | margin: 12px 0px; 20 | } 21 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | @import url("https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap"); 2 | 3 | body { 4 | margin: 0; 5 | font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", 6 | "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", 7 | "Helvetica Neue", sans-serif; 8 | -webkit-font-smoothing: antialiased; 9 | -moz-osx-font-smoothing: grayscale; 10 | } 11 | 12 | * { 13 | margin: 0px; 14 | padding: 0px; 15 | } 16 | 17 | code { 18 | font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", 19 | monospace; 20 | } 21 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /src/components/recipe-tile/index.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect } from "react"; 2 | import "./style.css"; 3 | import { v4 as uuidv4 } from "uuid"; 4 | 5 | export default function RecipeTile({ recipe }) { 6 | return ( 7 | recipe["recipe"]["image"].match(/\.(jpeg|jpg|gif|png)$/) != null && ( 8 |
window.open(recipe["recipe"]["url"])} 11 | > 12 | 13 |

14 | {recipe["recipe"]["label"]} 15 |

16 |
17 | ) 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /src/app.css: -------------------------------------------------------------------------------- 1 | .app { 2 | display: flex; 3 | justify-content: center; 4 | flex-direction: column; 5 | align-items: center; 6 | padding: 40px 24px; 7 | } 8 | 9 | .app__searchForm { 10 | margin-top: 18px; 11 | } 12 | 13 | .app__input { 14 | padding: 6px 16px; 15 | min-width: 200px; 16 | max-width: 100vw; 17 | font-size: 15px; 18 | } 19 | 20 | .app__submit { 21 | padding: 6px 16px; 22 | font-size: 15px; 23 | margin-left: 6px; 24 | background-color: #02aff0; 25 | border: 2px solid #02aff0; 26 | border-radius: 4px; 27 | color: white; 28 | cursor: pointer; 29 | } 30 | 31 | .app__submit:hover { 32 | padding: 6px 16px; 33 | font-size: 15px; 34 | margin-left: 6px; 35 | background-color: white; 36 | border: 2px solid #02aff0; 37 | border-radius: 4px; 38 | color: #02aff0; 39 | cursor: pointer; 40 | } 41 | 42 | .app__recipes { 43 | margin-top: 24px; 44 | display: grid; 45 | grid-template-columns: 220px 220px; 46 | align-items: baseline; 47 | } 48 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "reactapi", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.4", 7 | "@testing-library/react": "^11.1.0", 8 | "@testing-library/user-event": "^12.1.10", 9 | "axios": "^0.21.1", 10 | "react": "^17.0.1", 11 | "react-dom": "^17.0.1", 12 | "react-scripts": "4.0.2", 13 | "uuid": "^8.3.2", 14 | "web-vitals": "^1.0.1" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test", 20 | "eject": "react-scripts eject" 21 | }, 22 | "eslintConfig": { 23 | "extends": [ 24 | "react-app", 25 | "react-app/jest" 26 | ] 27 | }, 28 | "browserslist": { 29 | "production": [ 30 | ">0.2%", 31 | "not dead", 32 | "not op_mini all" 33 | ], 34 | "development": [ 35 | "last 1 chrome version", 36 | "last 1 firefox version", 37 | "last 1 safari version" 38 | ] 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import Axios from "axios"; 2 | import { useState } from "react"; 3 | import "./app.css"; 4 | import RecipeTile from "./components/recipe-tile"; 5 | 6 | function App() { 7 | const [query, setquery] = useState(""); 8 | const [recipes, setrecipes] = useState([]); 9 | 10 | const YOUR_APP_ID = `82e453da`; 11 | const YOUR_APP_KEY = "3bb5d1a3b992f408b9003effd74c9c22"; 12 | 13 | const url = `https://api.edamam.com/search?q=${query}&app_id=${YOUR_APP_ID}&app_key=${YOUR_APP_KEY}`; 14 | 15 | const getRecipeInfo = async () => { 16 | var result = await Axios.get(url); 17 | setrecipes(result.data.hits); 18 | console.log(result.data.hits); 19 | }; 20 | 21 | const onSubmit = (e) => { 22 | e.preventDefault(); 23 | getRecipeInfo(); 24 | }; 25 | 26 | return ( 27 |
28 |

Food Recipe Plaza 🍔

29 |
30 | setquery(e.target.value)} 37 | /> 38 | 39 |
40 | 41 |
42 | {recipes !== [] && 43 | recipes.map((recipe) => { 44 | return ; 45 | })} 46 |
47 |
48 | ); 49 | } 50 | 51 | export default App; 52 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Let's Build a Food Recipe App 2 | React API Project Tutorial Using Hooks, Axios and Firebase 3 | 4 | ![recipe app reactjs api project sanskar tiwari](https://user-images.githubusercontent.com/55942632/109449230-e829a780-7a6d-11eb-9934-a9c82cce1e12.jpg) 5 | 6 | ### Created & Maintained By 7 | 8 | [Sanskar Tiwari](https://github.com/theindianappguy) ([@indianappguy](https://twitter.com/indianappguy)) ([YouTube](https://www.youtube.com/c/SanskarTiwari)) 9 | 10 | > If you found this project helpful or you learned something from the source code and want to thank me, 11 | > consider checking out what i am building at [MagicSlides.app](https://www.magicslides.app), [MagicForm.app](https://www.magicform.app) & [SheetAI.app](https://www.sheetai.app) 12 | 13 | ### License 14 | 15 | Copyright 2020 Sanskar Tiwari 16 | 17 | Licensed under the Apache License, Version 2.0 (the "License"); 18 | you may not use this file except in compliance with the License. 19 | You may obtain a copy of the License at 20 | 21 | http://www.apache.org/licenses/LICENSE-2.0 22 | 23 | Unless required by applicable law or agreed to in writing, software 24 | distributed under the License is distributed on an "AS IS" BASIS, 25 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 26 | See the License for the specific language governing permissions and 27 | limitations under the License. 28 | 29 | 30 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 31 | 32 | ## Available Scripts 33 | 34 | In the project directory, you can run: 35 | 36 | ### `yarn start` 37 | 38 | Runs the app in the development mode.\ 39 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 40 | 41 | The page will reload if you make edits.\ 42 | You will also see any lint errors in the console. 43 | 44 | ### `yarn test` 45 | 46 | Launches the test runner in the interactive watch mode.\ 47 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 48 | 49 | ### `yarn build` 50 | 51 | Builds the app for production to the `build` folder.\ 52 | It correctly bundles React in production mode and optimizes the build for the best performance. 53 | 54 | The build is minified and the filenames include the hashes.\ 55 | Your app is ready to be deployed! 56 | 57 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 58 | 59 | ### `yarn eject` 60 | 61 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 62 | 63 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 64 | 65 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 66 | 67 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 68 | 69 | ## Learn More 70 | 71 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 72 | 73 | To learn React, check out the [React documentation](https://reactjs.org/). 74 | 75 | ### Code Splitting 76 | 77 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 78 | 79 | ### Analyzing the Bundle Size 80 | 81 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 82 | 83 | ### Making a Progressive Web App 84 | 85 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 86 | 87 | ### Advanced Configuration 88 | 89 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 90 | 91 | ### Deployment 92 | 93 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 94 | 95 | ### `yarn build` fails to minify 96 | 97 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 98 | --------------------------------------------------------------------------------