From 7c69c7207d9754130a84619d910feaf66754dd04 Mon Sep 17 00:00:00 2001 From: Galen Guyer Date: Fri, 13 Nov 2020 21:09:41 -0500 Subject: Add cards for total cases --- src/App.css | 34 +++------------------------------- src/App.js | 10 ++++++++-- src/Card.css | 3 +++ src/Card.js | 24 ++++++++++++++++++++++++ 4 files changed, 38 insertions(+), 33 deletions(-) create mode 100644 src/Card.css create mode 100644 src/Card.js (limited to 'src') diff --git a/src/App.css b/src/App.css index 78b8850..0f57d9d 100644 --- a/src/App.css +++ b/src/App.css @@ -2,37 +2,9 @@ text-align: center; } -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; +.Section { display: flex; - flex-direction: column; - align-items: center; justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } + margin-left: auto; + margin-right: auto; } diff --git a/src/App.js b/src/App.js index 0600437..e7137a2 100644 --- a/src/App.js +++ b/src/App.js @@ -1,5 +1,5 @@ import useSWR from "swr"; -import logo from "./logo.svg"; +import Card from "./Card"; import "./App.css"; const url = "https://rcpoller.galenguyer.com/api/v0/history"; @@ -22,10 +22,16 @@ function App() { ); + const latest = data[data.length - 1]; + const prior = data[data.length - 2]; + return (

RIT Covid Dashboard

-

Data Loaded

+
+ + +
); } diff --git a/src/Card.css b/src/Card.css new file mode 100644 index 0000000..68d41ed --- /dev/null +++ b/src/Card.css @@ -0,0 +1,3 @@ +.Card { + padding: 16px; +} diff --git a/src/Card.js b/src/Card.js new file mode 100644 index 0000000..310848d --- /dev/null +++ b/src/Card.js @@ -0,0 +1,24 @@ +import React from "react"; +import "./Card.css"; + +const Card = (props) => { + let diff = props.latest - props.prior; + if (diff >= 0) { + diff = "+" + diff.toString(); + } + return ( +
+

{props.name}

+

+ {props.latest} + {props.suffix}{" "} + + ({diff} + {props.suffix}) + +

+
+ ); +}; + +export default Card; -- cgit v1.2.3