ISS Position SPA launched! 🚀

This commit is contained in:
rzmk 2021-12-23 06:18:39 -05:00
parent 0ca5ddc97d
commit a697812315
14 changed files with 28082 additions and 27719 deletions

7
LICENSE Normal file
View file

@ -0,0 +1,7 @@
Copyright © 2021 Mueez Khan
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,70 +1,14 @@
# Getting Started with Create React App
# International Space Station Position SPA 🛰
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
![Webapp demo](demo.gif)
## Available Scripts
Fetches the latitude and longitude of the International Space Station (ISS) every 10 seconds and displays the position with a progress bar.
In the project directory, you can run:
## Technologies
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
The page will reload when you make changes.\
You may also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
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.
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.
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.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
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)
### Analyzing the Bundle Size
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)
### Making a Progressive Web App
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)
### Advanced Configuration
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)
### Deployment
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
### `npm run build` fails to minify
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)
- [React](https://reactjs.org/)
- [TailwindCSS](https://tailwindcss.com/)
- [react-icons](https://github.com/react-icons/react-icons)
- [ISS API](http://api.open-notify.org/iss-now.json)
- [uiGradients](https://uigradients.com/#VisionsofGrandeur)
- [GitHub Pages](https://pages.github.com/)

BIN
demo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 MiB

55413
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,38 +1,48 @@
{
"name": "iss-location-spa",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "5.0.0",
"web-vitals": "^2.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
"name": "iss-position-spa",
"homepage": "https://rzmk.github.io/iss-position-spa",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.1",
"@testing-library/react": "^12.1.2",
"@testing-library/user-event": "^13.5.0",
"gh-pages": "^3.2.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^4.3.1",
"react-scripts": "5.0.0",
"web-vitals": "^2.1.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"autoprefixer": "^10.4.0",
"postcss": "^8.4.5",
"tailwindcss": "^3.0.7"
}
}

6
postcss.config.js Normal file
View file

@ -0,0 +1,6 @@
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}

View file

@ -1,38 +1,37 @@
.App {
text-align: center;
text-align: center;
}
.App-logo {
height: 40vmin;
pointer-events: none;
height: 40vmin;
pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
}
}
.App-header {
background-color: #282c34;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: calc(10px + 2vmin);
color: white;
}
.App-link {
color: #61dafb;
color: #61dafb;
}
@keyframes App-logo-spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}

View file

@ -1,25 +1,60 @@
import logo from './logo.svg';
import './App.css';
// import logo from "../logo.svg";
import React, { useState, useEffect } from "react";
import { AiFillGithub } from "react-icons/ai";
import ProgressBar from "./components/ProgressBar";
import "./App.css";
function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
);
const [longitude, setLongitude] = useState(0);
const [latitude, setLatitude] = useState(0);
const [progress, setProgress] = useState(0);
async function fetchISSData() {
// const resp = await fetch("#"); // debugging
const resp = await fetch("http://api.open-notify.org/iss-now.json");
const data = await resp.json();
await setLongitude(data.iss_position.longitude);
await setLatitude(data.iss_position.latitude);
setProgress(0);
}
useEffect(() => {
fetchISSData();
setInterval(fetchISSData, 10000);
setInterval(() => {
setProgress((prev) => prev + 1);
}, 100);
}, []);
return (
<div className="App">
<header className="App-header">
{/* <img src={logo} className="App-logo" alt="logo" /> */}
<h1 className="text-4xl sm:text-6xl">
International Space Station Position
</h1>
<table className="my-8 text-3xl sm:text-4xl">
<tbody>
<tr>
<td className="text-left">Latitude:</td>
<td className="text-right">{latitude}</td>
</tr>
<tr>
<td className="text-left">Longitude:</td>
<td className="text-right pl-10">{longitude}</td>
</tr>
</tbody>
</table>
<ProgressBar progress={progress} />
<a
href="https://github.com/rzmk/iss-location-spa"
target="_blank"
>
<AiFillGithub className="mt-8 w-12 h-12 hover:scale-125 transition ease-in-out" />
</a>
</header>
</div>
);
}
export default App;

View file

@ -1,8 +0,0 @@
import { render, screen } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});

22
src/background.svg Normal file
View file

@ -0,0 +1,22 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:svgjs="http://svgjs.com/svgjs" width="1440" height="560" preserveAspectRatio="none" viewBox="0 0 1440 560">
<g mask="url(&quot;#SvgjsMask1002&quot;)" fill="none">
<rect width="1440" height="560" x="0" y="0" fill="url(#SvgjsLinearGradient1003)"></rect>
<path d="M1440 0L1169.67 0L1440 127.71z" fill="rgba(255, 255, 255, .1)"></path>
<path d="M1169.67 0L1440 127.71L1440 165.54L958.5600000000001 0z" fill="rgba(255, 255, 255, .075)"></path>
<path d="M958.56 0L1440 165.54L1440 365.90999999999997L362.28999999999996 0z" fill="rgba(255, 255, 255, .05)"></path>
<path d="M362.28999999999996 0L1440 365.90999999999997L1440 372.4L230.05999999999997 0z" fill="rgba(255, 255, 255, .025)"></path>
<path d="M0 560L689.41 560L0 469.35z" fill="rgba(0, 0, 0, .1)"></path>
<path d="M0 469.35L689.41 560L931.0899999999999 560L0 213.34000000000003z" fill="rgba(0, 0, 0, .075)"></path>
<path d="M0 213.34000000000003L931.0899999999999 560L1146.3 560L0 170.77000000000004z" fill="rgba(0, 0, 0, .05)"></path>
<path d="M0 170.77000000000004L1146.3 560L1251.08 560L0 92.22000000000004z" fill="rgba(0, 0, 0, .025)"></path>
</g>
<defs>
<mask id="SvgjsMask1002">
<rect width="1440" height="560" fill="#ffffff"></rect>
</mask>
<linearGradient x1="15.28%" y1="-39.29%" x2="84.72%" y2="139.29%" gradientUnits="userSpaceOnUse" id="SvgjsLinearGradient1003">
<stop stop-color="#0e2a47" offset="0"></stop>
<stop stop-color="#00459e" offset="1"></stop>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -0,0 +1,14 @@
const ProgressBar = ({ progress }) => {
return (
<div className="w-1/4">
<div className="w-full bg-gray-600 rounded-full h-4 dark:bg-gray-500">
<div
className="bg-gray-200 h-4 rounded-full transition-all ease-in-out"
style={{ width: `${progress}%`, maxWidth: "100%" }}
></div>
</div>
</div>
);
};
export default ProgressBar;

View file

@ -1,13 +1,29 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans",
"Helvetica Neue", sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
background: #000046; /* fallback for old browsers */
background: #000046; /* fallback for old browsers */
background: -webkit-linear-gradient(
to right,
#1cb5e0,
#000046
); /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(
to right,
#1cb5e0,
#000046
); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New",
monospace;
}

View file

@ -1,14 +1,14 @@
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import React from "react";
import ReactDOM from "react-dom";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById("root")
);
// If you want to start measuring performance in your app, pass a function

7
tailwind.config.js Normal file
View file

@ -0,0 +1,7 @@
module.exports = {
content: ["./src/**/*.{js,jsx,ts,tsx}"],
theme: {
extend: {},
},
plugins: [],
};