├── src ├── neon.jpg ├── reportWebVitals.js ├── index.js ├── App.css ├── App.js └── index.css ├── public ├── robots.txt ├── work-time.png ├── manifest.json └── index.html ├── README.md ├── .gitignore └── package.json /src/neon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatachaKey/havefun-app-API/HEAD/src/neon.jpg -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /public/work-time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/NatachaKey/havefun-app-API/HEAD/public/work-time.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # React App fetching data from API, async/await, React hooks. Responsive for all mobile devices. 2 | 3 | ## In the project directory, you can run: 4 | 5 | ## npm i 6 | ## npm start 7 | 8 | -------------------------------------------------------------------------------- /.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/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom/client'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | const root = ReactDOM.createRoot(document.getElementById('root')); 8 | root.render( 9 | 10 | 11 | 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /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/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | 2 | import { useEffect, useState } from 'react'; 3 | import './App.css'; 4 | 5 | function App() { 6 | 7 | const [activity, setActivity] = useState(''); 8 | 9 | useEffect(()=>{ 10 | getActivity() 11 | }, []) 12 | 13 | const getActivity = async() => { 14 | const response= await fetch('https://www.boredapi.com/api/activity/') 15 | const data = await response.json(); 16 | setActivity(data); 17 | } 18 | 19 | return ( 20 |
21 |
22 |

{activity.activity}

23 |
Activity type: {activity.type}
24 |
Participants: {activity.participants}
25 |
Price: $ {activity.price}
26 |
27 | 28 |
29 | 30 |
31 |
32 | ); 33 | } 34 | 35 | export default App; 36 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "antiboringapp", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.5", 7 | "@testing-library/react": "^13.4.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "react": "^18.2.0", 10 | "react-dom": "^18.2.0", 11 | "react-scripts": "5.0.1", 12 | "web-vitals": "^2.1.4" 13 | }, 14 | "scripts": { 15 | "start": "react-scripts start", 16 | "build": "react-scripts build", 17 | "test": "react-scripts test", 18 | "eject": "react-scripts eject" 19 | }, 20 | "eslintConfig": { 21 | "extends": [ 22 | "react-app", 23 | "react-app/jest" 24 | ] 25 | }, 26 | "browserslist": { 27 | "production": [ 28 | ">0.2%", 29 | "not dead", 30 | "not op_mini all" 31 | ], 32 | "development": [ 33 | "last 1 chrome version", 34 | "last 1 firefox version", 35 | "last 1 safari version" 36 | ] 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 19 | 20 | 21 | 30 | 31 | Are you bored? 32 | 33 | 34 | 35 |
36 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | background-image: url('neon.jpg'); 4 | background-position: center; 5 | background-repeat: no-repeat; 6 | background-size: cover; 7 | width:100vw; 8 | height:90vh; 9 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif; 10 | -webkit-font-smoothing: antialiased; 11 | -moz-osx-font-smoothing: grayscale; 12 | } 13 | .App{ 14 | margin-top: 60px; 15 | } 16 | code { 17 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; 18 | } 19 | h5{ 20 | font-size: 25px; 21 | color: aliceblue; 22 | text-shadow: 0 0 3px #FF0000; 23 | font-family: 'Poppins', sans-serif; 24 | } 25 | h3{ 26 | color: aliceblue; 27 | font-size: 30px; 28 | text-shadow: 1px 1px 2px #fff; 29 | font-family: 'Poppins', sans-serif; 30 | } 31 | h6{ 32 | color: aliceblue; 33 | font-size: 18px; 34 | text-shadow: 0 0 3px #FF0000; 35 | font-family: 'Poppins', sans-serif; 36 | margin-bottom:10px; 37 | } 38 | h3 { 39 | margin: 0; 40 | grid-column: 1; 41 | grid-row: 1; 42 | z-index: 1; 43 | font-size: 2.5rem; 44 | animation: glow 2s ease-in-out infinite alternate; 45 | text-align: center; 46 | } 47 | @keyframes glow { 48 | from { 49 | text-shadow: 0 0 20px #2d9da9; 50 | } 51 | to { 52 | text-shadow: 0 0 30px #34b3c1, 0 0 10px #4dbbc7; 53 | } 54 | } 55 | :root { 56 | --btn-color-bg: rgb(95, 184, 211); 57 | --btn-color-hover: rgb(233, 235, 133); 58 | --btn-scale: 4; 59 | --btn-size: 10vmin; 60 | --btn-transition: all 375ms ease-in-out; 61 | --container-color-bg: hsla(223, 12%, 59%, 1); 62 | } 63 | #btn{ 64 | border:none; 65 | color:#212121; 66 | margin-top: 30px; 67 | } 68 | .box { 69 | box-shadow: 20px 20px 50px 10px pink inset; 70 | display: block; 71 | left: 50%; 72 | outline: none; 73 | position: absolute; 74 | top: 40%; 75 | transform: translate(-50%, -50%); 76 | font-family: 'Poppins', sans-serif; 77 | } 78 | .before { 79 | background-color: var(--btn-color-bg); 80 | border-radius: var(--btn-size); 81 | height: var(--btn-size); 82 | transition: var(--btn-transition); 83 | width: var(--btn-size); 84 | } 85 | .before:hover { 86 | background-color: var(--btn-color-hover); 87 | width: calc(var(--btn-size) * var(--btn-scale)); 88 | --btn-scale: 3; 89 | font-size:14px; 90 | } 91 | @media all and (max-width:500px){ 92 | h3{ 93 | font-size: 20px; 94 | text-transform: uppercase; 95 | margin-bottom:20px; 96 | } 97 | h5, h6{ 98 | font-size: 12px; 99 | margin-top:10px; 100 | margin-bottom:10px; 101 | text-transform: uppercase; 102 | } 103 | button{ 104 | height:40px; 105 | font-size: 7px; 106 | margin-top:20px; 107 | margin-bottom:20px; 108 | } 109 | :root { 110 | --btn-size: 20vmin; 111 | } 112 | button{ 113 | font-size:12px; 114 | text-transform: uppercase; 115 | } 116 | } 117 | --------------------------------------------------------------------------------