-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a75a281
Showing
18 changed files
with
16,073 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
covid.code-workspace | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "react-globe-311", | ||
"version": "1.0.0", | ||
"description": "TODO", | ||
"keywords": [ | ||
"react-globe", | ||
"webgl", | ||
"visualization", | ||
"globe", | ||
"react" | ||
], | ||
"main": "src/index.tsx", | ||
"dependencies": { | ||
"es6-tween": "5.5.11", | ||
"react": "16.13.1", | ||
"react-dom": "16.13.1", | ||
"react-globe": "4.0.0", | ||
"react-scripts": "3.4.1", | ||
"three": "0.116.1" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "16.8.8", | ||
"@types/react-dom": "16.8.2", | ||
"typescript": "3.3.3" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
}, | ||
"browserslist": [ | ||
">0.2%", | ||
"not dead", | ||
"not ie <= 11", | ||
"not op_mini all" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta | ||
name="viewport" | ||
content="width=device-width, shrink-to-fit=yes,initial-scale=1.0" | ||
/> | ||
<meta name="theme-color" content="#000000" /> | ||
<!-- | ||
manifest.json provides metadata used when your web app is added to the | ||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
</head> | ||
|
||
<body> | ||
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import * as React from "react"; | ||
import ReactGlobe, { Marker } from "react-globe"; | ||
|
||
import markers from "./markers"; | ||
import markerRenderer from "./markerRenderer"; | ||
import worldTexture from "./assets/world.jpg"; | ||
import "./styles.css"; | ||
import { useState, useEffect } from "react"; | ||
import { Object3D } from "three"; | ||
import { Spinner } from "./Spinner"; | ||
import globalData from "./assets/global.json"; | ||
|
||
export default function App() { | ||
const [details, setDetails] = useState<any>(null); | ||
const [isLoaded, onTextureLoaded] = useState(false); | ||
function getTooltipContent(marker: Marker) { | ||
return `Location: ${marker.Country} (Active Cases: ${marker.activeCases})`; | ||
} | ||
|
||
function onClickMarker( | ||
marker: Marker, | ||
markerObject?: Object3D, | ||
event?: PointerEvent | ||
) { | ||
setDetails(getTooltipContent(marker)); | ||
} | ||
|
||
function onDefocus(previousCoordinates: any, event?: PointerEvent) { | ||
setDetails(null); | ||
} | ||
|
||
return ( | ||
<React.Fragment> | ||
<Spinner loaded={isLoaded} /> | ||
<div className="header1">COVID19 Globe Tracker</div> | ||
<div className="header2">Active Cases</div> | ||
<div className="globe"> | ||
<ReactGlobe | ||
markers={markers} | ||
markerOptions={{ renderer: markerRenderer }} | ||
onDefocus={onDefocus} | ||
onClickMarker={onClickMarker} | ||
onMouseOverMarker={onClickMarker} | ||
onMouseOutMarker={() => setDetails(null)} | ||
cameraOptions={{ | ||
maxDistanceRadiusScale: 10, | ||
autoRotateSpeed: 1.1, | ||
distanceRadiusScale: 10, | ||
}} | ||
focusOptions={{ | ||
distanceRadiusScale: 5, | ||
}} | ||
globeOptions={{ | ||
texture: worldTexture, | ||
glowColor: "red", | ||
enableClouds: false, | ||
}} | ||
onTextureLoaded={() => onTextureLoaded(true)} | ||
/> | ||
{details && ( | ||
<div className="details"> | ||
<p> {details}</p> | ||
</div> | ||
)} | ||
</div> | ||
{isLoaded ? ( | ||
<div className="footer"> | ||
<Counter /> | ||
</div> | ||
) : null} | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
function Counter() { | ||
const [total, setTotal] = useState(globalData.totalCount); | ||
const [counter, setCounter] = useState(0); | ||
useEffect(() => { | ||
setTimeout(() => null, 5000); | ||
}, []); | ||
useEffect(() => { | ||
if (counter != total) { | ||
if (total - counter == 10000) setCounter(counter + 1); | ||
else if (counter < 10000) setCounter(counter + 100); | ||
else if (counter < 100000) setCounter(counter + 50); | ||
} | ||
}, [counter]); | ||
|
||
function numberWithCommas(x: number) { | ||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | ||
} | ||
|
||
return <p>{numberWithCommas(counter)}</p>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.spinbody { | ||
position: fixed; /* Sit on top of the page content */ | ||
width: 100%; /* Full width (cover the whole page) */ | ||
height: 100%; /* Full height (cover the whole page) */ | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: rgba(0, 0, 0, 1); /* Black background with opacity */ | ||
z-index: 1; /* Specify a stack order in case you're using a different order for other elements */ | ||
cursor: pointer; /* Add a pointer on hover */ | ||
} | ||
|
||
.spinner { | ||
border: 16px solid rgba(0, 0, 0, 0.8); /* Light grey */ | ||
border-top: 16px solid red; /* Blue */ | ||
border-radius: 50%; | ||
width: 120px; | ||
height: 120px; | ||
animation: spin 2s linear infinite; | ||
position: absolute; | ||
left: 45%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
} | ||
|
||
@media only screen and (min-device-width: 320px) and (max-device-width: 750px) { | ||
.spinner { | ||
left: 35%; | ||
top: 50%; | ||
transform: translate(-50%, -50%); | ||
} | ||
} | ||
@keyframes spin { | ||
0% { | ||
transform: rotate(0deg); | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from "react"; | ||
import "./Spinner.css"; | ||
export function Spinner(props: { loaded: boolean }) { | ||
return !props.loaded ? ( | ||
<div className="spinbody"> | ||
<div className="spinner"></div> | ||
</div> | ||
) : null; | ||
} |
Oops, something went wrong.