Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into campfire/splitio
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Sep 2, 2020
2 parents 3b0ffa2 + 32cef38 commit af4267a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 35 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [1.15.3](https://github.com/newrelic/developer-website/compare/v1.15.2...v1.15.3) (2020-09-02)


### Bug Fixes

* fix lint errors preventing pushes ([9c600d7](https://github.com/newrelic/developer-website/commit/9c600d7e196a164300328c498664735637118b78))
* lint warnings in countdown container ([ca14b49](https://github.com/newrelic/developer-website/commit/ca14b49f5a4575ed95655a7edcd810c5ac92730c))

## [1.15.2](https://github.com/newrelic/developer-website/compare/v1.15.1...v1.15.2) (2020-08-31)


Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "developer-website",
"private": true,
"version": "1.15.2",
"version": "1.15.3",
"dependencies": {
"@emotion/core": "^10.0.28",
"@emotion/styled": "^10.0.27",
Expand Down
56 changes: 26 additions & 30 deletions src/components/Countdown/CountdownContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,56 @@ import Countdown from './Countdown';
import PropTypes from 'prop-types';
import styles from './CountdownContainer.module.scss';

const getRemainingTime = (targetDate) => {
const countDownDate = new Date(targetDate).getTime();
const now = new Date().getTime();

const milliseconds = countDownDate - now;

const days = Math.floor(milliseconds / (1000 * 60 * 60 * 24));
const hours = Math.floor(
(milliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);
const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((milliseconds % (1000 * 60)) / 1000);

return { days, hours, minutes, seconds, milliseconds };
};

const CountdownContainer = ({ targetDate, inactiveMessage }) => {
const [countdown, setCountdown] = React.useState(() => getRemainingTime());
let active = countdown.milliseconds > 0;
const [countdown, setCountdown] = React.useState(() =>
getRemainingTime(targetDate)
);
const active = countdown.milliseconds > 0;

useEffect(() => {
const hasRemainingTime = () => {
const { milliseconds } = getRemainingTime();
const { milliseconds } = getRemainingTime(targetDate);
return milliseconds > 0;
};

if (!hasRemainingTime()) {
active = false;
return;
}

const interval = setInterval(() => {
const {
days,
hours,
minutes,
seconds,
milliseconds,
} = getRemainingTime();
const { days, hours, minutes, seconds, milliseconds } = getRemainingTime(
targetDate
);

if (milliseconds < 0) {
active = false;
clearInterval(interval);
} else {
setCountdown({ days, hours, minutes, seconds, milliseconds });
}
}, 1000);

return () => clearInterval(interval);
}, []);

function getRemainingTime() {
const countDownDate = new Date(targetDate).getTime();
const now = new Date().getTime();

const milliseconds = countDownDate - now;

const days = Math.floor(milliseconds / (1000 * 60 * 60 * 24));
const hours = Math.floor(
(milliseconds % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
);
const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((milliseconds % (1000 * 60)) / 1000);

return { days, hours, minutes, seconds, milliseconds };
}
}, [targetDate]);

return (
<div className={styles.container}>
{active === true ? (
{active ? (
<div className={styles.countdownContainer}>
<Countdown countdown={countdown} />
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/all-things-open.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const allThingsOpenPage = () => {
</section>
<section className={styles.section}>
<h2>Visit us in the virtual expo hall</h2>
<hr></hr>
<hr />
</section>
<section className={cx(styles.section, styles.assetTable)}>
<div>
Expand All @@ -86,7 +86,7 @@ const allThingsOpenPage = () => {
</div>
</section>
<h2>Explore resources</h2>
<hr></hr>
<hr />
<section className={cx(styles.section, styles.assetTable)}>
<div className={styles.point}>
<h4>How to use the Kubernetes cluster explorer</h4>
Expand Down
1 change: 0 additions & 1 deletion src/pages/nerd-days.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import { Link } from 'gatsby';
import cx from 'classnames';
import PageLayout from '../components/PageLayout';
import MarketoForm from '../components/MarketoForm';
Expand Down

0 comments on commit af4267a

Please sign in to comment.