Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ export default function App() {
}}
/>
</span>
<span className="time-to-herd-date">
&nbsp;(<TimeToHerdCount
selectedCountry={selectedCountry}
allVaccineData={allVaccineData}
requestedData="timetoherd"
requestedDataAsPercent={false}
herdImmunityThresholdPercentage={
herdImmunityThresholdPercentage
}
addDays={true}
/>)
</span>
</div>
<p className="subheader">
until {herdImmunityThresholdPercentage}% of the population is
Expand Down
21 changes: 13 additions & 8 deletions src/components/time-to-herd/time-to-herd.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ import React, { useState, useEffect } from "react";
import CountUp from "react-countup";
import "./country-section.css";
import { CountriesMasterList } from "../../shared/data-factory.js";
import moment from 'moment';

export const TimeToHerdCount = ({
selectedCountry,
allVaccineData,
requestedData,
requestedDataAsPercent,
herdImmunityThresholdPercentage,
addDays = false,
}) => {
const [
herdImmunityVaccinationThreshold,
Expand Down Expand Up @@ -154,14 +156,17 @@ export const TimeToHerdCount = ({

return (
<>
{requestedDataAsPercent ? (
<CountUp end={requestedDataValue || 0} duration={1} decimals={3} />
) : (
<CountUp
className="datapoint-value"
end={requestedDataValue || 0}
separator=","
/>
{addDays ?
(moment().add(requestedDataValue, 'days').format("YYYY MMMM DD"))
: (requestedDataAsPercent ? (
<CountUp end={requestedDataValue || 0} duration={1} decimals={3} />
) : (
<CountUp
className="datapoint-value"
end={requestedDataValue || 0}
separator=","
/>
)
)}
</>
);
Expand Down