Skip to content

Commit dd149b3

Browse files
committed
big changes
1 parent bb06b5a commit dd149b3

File tree

10 files changed

+95
-31
lines changed

10 files changed

+95
-31
lines changed

package-lock.json

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"classnames": "^2.2.6",
1313
"react": "^16.13.1",
1414
"react-chartjs-2": "^2.9.0",
15-
"react-device-detect": "^1.11.14",
15+
"react-countup": "^4.3.3",
1616
"react-dom": "^16.13.1",
1717
"react-scripts": "3.4.1"
1818
},

src/App.css

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,22 @@
33
margin-top: 20px !important;
44
}
55

6+
.container {
7+
display: flex;
8+
align-items: center;
9+
flex-direction: column;
10+
}
11+
12+
.link {
13+
cursor: pointer;
14+
}
15+
16+
.image-covid {
17+
width: 370px;
18+
}
19+
620
body {
7-
background-color: rgb(250, 250,250)
21+
background-color: rgb(250, 250,250);
822
}
923

1024
.intro-container {

src/App.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import React from 'react';
22

33
import './App.css';
4-
import { Container, Typography } from '@material-ui/core';
4+
import { Typography } from '@material-ui/core';
55

6-
import {isMobile} from 'react-device-detect';
6+
import CoronaLogo from './images/image.png';
77

88
import Info from './components/Info/Info';
99
import Countries from './components/Countries/Countries';
@@ -33,14 +33,14 @@ class App extends React.Component {
3333
const { data, country } = this.state;
3434

3535
return (
36-
<Container>
37-
<Typography variant="h2" className="heading">Corona Statistics</Typography>
36+
<div className="container">
37+
<span className="link" onClick={() => this.handleCountryChange('')}><img className="image-covid" src={CoronaLogo} alt="logo" /></span>
3838
<div className="intro-container">
3939
<Info data={data} />
4040
<Countries handleCountryChange={this.handleCountryChange} />
4141
</div>
4242
{ window.innerWidth > 500 ? <Chart data={data} country={country} /> : <Typography align="center" variant="h5">Rotate your device and reload the page to see the chart</Typography>}
43-
</Container>
43+
</div>
4444
);
4545
}
4646
}

src/api/fetchData.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import axios from 'axios';
33
const fetchData = (country) => {
44
let url = 'https://covid19.mathdro.id/api';
55

6+
console.log(country);
7+
68
if(country) {
79
url = `${url}/countries/${country}`;
810
}

src/components/Chart/Chart.css

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,20 @@
22
.chart-container {
33
display: flex;
44
justify-content: center;
5-
margin: 0 15%;
5+
width: 45%;
66
}
77

88
canvas {
99
width: 100%;
1010
}
1111

12-
@media only screen and (max-width: 820px) {
12+
@media only screen and (max-width: 1000px) {
1313
.chart-container {
14-
margin: 0 5%;
14+
width: 70%;
15+
}
16+
}
17+
@media only screen and (max-width: 1441px) {
18+
.chart-container {
19+
width: 60%;
1520
}
1621
}

src/components/Chart/Chart.jsx

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
import React, { useState, useEffect } from 'react'
22
import { Line, Bar } from 'react-chartjs-2';
33

4-
import { Container } from '@material-ui/core';
5-
64
import './Chart.css'
75

8-
96
import fetchDaily from '../../api/fetchDaily';
107

118
const Chart = ({ data, country }) => {
129
const [dailyData, setDailyData] = useState({});
1310

1411
useEffect(() => {
15-
async function fetchMyAPI() {
12+
const fetchMyAPI = async () => {
1613
const dailyData = await fetchDaily();
1714

1815
setDailyData(dailyData)
@@ -28,18 +25,15 @@ const Chart = ({ data, country }) => {
2825
datasets: [
2926
{
3027
label: "People",
31-
backgroundColor: ["rgb(0,0,205)", "rgb(0,205, 0)", "rgb(205,0, 0)"],
28+
backgroundColor: ["rgba(0, 0, 255, 0.5)", "rgba(0, 255, 0, 0.5)", "rgba(255, 0, 0, 0.5)"],
3229
data: [data.confirmed, data.recovered, data.deaths]
3330
}
3431
]
3532
}}
3633
options={{
3734
legend: { display: false },
38-
title: {
39-
display: true,
40-
text: `Current state in ${country}`
41-
}
42-
}}
35+
title: { display: true, text: `Current state in ${country}` },
36+
}}
4337
/> : null
4438
)
4539

@@ -55,7 +49,7 @@ const Chart = ({ data, country }) => {
5549
data: dailyData.map(({ deaths }) => deaths),
5650
label: "Deaths",
5751
borderColor: "red",
58-
backgroundColor: "#ff9999",
52+
backgroundColor: "rgba(255, 0, 0, 0.5)",
5953
fill: true
6054
}
6155
]

src/components/Info/Info.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ img {
1313
width: 200px;
1414
}
1515

16-
.confirmed {
17-
background-color: rgba(0, 0, 255, 0.5);
16+
.infected {
17+
border-bottom: 10px solid rgba(0, 0, 255, 0.5);
1818
}
1919

2020
.recovered {
21-
background-color: rgba(0, 255, 0, 0.5);
21+
border-bottom: 10px solid rgba(0, 255, 0, 0.5);
2222
}
2323

2424
.deaths {
25-
background-color: rgba(255, 0, 0, 0.5);
25+
border-bottom: 10px solid rgba(255, 0, 0, 0.5);
2626
}
2727

2828
@media only screen and (max-width: 820px) {

src/components/Info/Info.jsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import React from 'react';
22

33
import { Card, CardActions, CardContent, Button, Typography, Grid } from '@material-ui/core';
4+
import CountUp from 'react-countup';
5+
46

57
import './Info.css';
68

@@ -14,13 +16,18 @@ const Info = ({ data }) => {
1416
return (
1517
<div className="container">
1618
<Grid container spacing={3} justify="center">
17-
<Grid item xs={12} md={3} component={Card} className="card">
19+
<Grid item xs={12} md={3} component={Card} className="card infected">
1820
<CardContent>
1921
<Typography color="textSecondary" gutterBottom>
2022
Infected
2123
</Typography>
2224
<Typography variant="h5" component="h2">
23-
{data.confirmed.toLocaleString()}
25+
<CountUp
26+
start={0}
27+
end={data.confirmed}
28+
duration={2.75}
29+
separator=","
30+
/>
2431
</Typography>
2532
<Typography color="textSecondary">
2633
{new Date(data.lastUpdate).toDateString()}
@@ -31,13 +38,18 @@ const Info = ({ data }) => {
3138
</CardContent>
3239

3340
</Grid>
34-
<Grid item xs={12} md={3} component={Card} className="card">
41+
<Grid item xs={12} md={3} component={Card} className="card recovered">
3542
<CardContent>
3643
<Typography color="textSecondary" gutterBottom>
3744
Recovered
3845
</Typography>
3946
<Typography variant="h5" component="h2">
40-
{data.recovered.toLocaleString()}
47+
<CountUp
48+
start={0}
49+
end={data.recovered}
50+
duration={2.75}
51+
separator=","
52+
/>
4153
</Typography>
4254
<Typography color="textSecondary">
4355
{new Date(data.lastUpdate).toDateString()}
@@ -48,13 +60,18 @@ const Info = ({ data }) => {
4860
</CardContent>
4961

5062
</Grid>
51-
<Grid item xs={12} md={3} component={Card} className="card">
63+
<Grid item xs={12} md={3} component={Card} className="card deaths">
5264
<CardContent>
5365
<Typography color="textSecondary" gutterBottom>
5466
Deaths
5567
</Typography>
5668
<Typography variant="h5" component="h2">
57-
{data.deaths.toLocaleString()}
69+
<CountUp
70+
start={0}
71+
end={data.deaths}
72+
duration={2.75}
73+
separator=","
74+
/>
5875
</Typography>
5976
<Typography color="textSecondary">
6077
{new Date(data.lastUpdate).toDateString()}

src/images/image.png

13.3 KB
Loading

0 commit comments

Comments
 (0)