diff --git a/OliverBooth/Pages/Shared/_Layout.cshtml b/OliverBooth/Pages/Shared/_Layout.cshtml index a2908c3..0b9c4d0 100644 --- a/OliverBooth/Pages/Shared/_Layout.cshtml +++ b/OliverBooth/Pages/Shared/_Layout.cshtml @@ -95,7 +95,12 @@
-

00 : 00 : 00 : 00

+
+
00
+
00
+
00
+
00
+
diff --git a/src/scss/app.scss b/src/scss/app.scss index 34872a3..7e0c9aa 100644 --- a/src/scss/app.scss +++ b/src/scss/app.scss @@ -365,25 +365,27 @@ td.trim-p p:last-child { background-position: center; background-repeat: no-repeat; background-size: cover; - - p { + border-radius: 10px; + cursor: pointer; + * { + cursor: pointer; + } + + .usa-countdown-element { + margin: 10px 0; + padding: 5px; font-family: "Gabarito", sans-serif; font-weight: 500; text-align: center; font-size: 3em; - margin: 0; - padding: 0; - - a { - transition: color 250ms; - } + border-right: 2px solid #fff; + border-left: 2px solid #fff; - a:link, a:visited, a:active { - color: #fff; + &:first-child { + border-left: none; } - - a:hover { - color: #03A9F4; + &:last-child { + border-right: none; } } } diff --git a/src/ts/UI.ts b/src/ts/UI.ts index 969fde3..34310f8 100644 --- a/src/ts/UI.ts +++ b/src/ts/UI.ts @@ -82,6 +82,33 @@ class UI { UI.updateProjectCards(element); } + public static updateUsaCountdown(element?: Element){ + element = element || document.getElementById("usa-countdown"); + + const daysElement = element.querySelector("#usa-countdown-days"); + const hoursElement = element.querySelector("#usa-countdown-hours"); + const minutesElement = element.querySelector("#usa-countdown-minutes"); + const secondsElement = element.querySelector("#usa-countdown-seconds"); + + const start = new Date().getTime(); + const end = Date.UTC(2024, 2, 7, 13, 20); + const diff = end - start; + let days = Math.floor(diff / (1000 * 60 * 60 * 24)); + let hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); + let minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)); + let seconds = Math.floor((diff % (1000 * 60)) / 1000); + + if (days < 0) days = 0 + if (hours < 0) hours = 0; + if (minutes < 0) minutes = 0; + if (seconds < 0) seconds = 0; + + daysElement.innerHTML = days.toString().padStart(2, '0'); + hoursElement.innerHTML = hours.toString().padStart(2, '0'); + minutesElement.innerHTML = minutes.toString().padStart(2, '0'); + secondsElement.innerHTML = seconds.toString().padStart(2, '0'); + } + /** * Adds Bootstrap tooltips to all elements with a title attribute. * @param element The element to search for elements with a title attribute in. diff --git a/src/ts/app.ts b/src/ts/app.ts index 75782ac..33d0cab 100644 --- a/src/ts/app.ts +++ b/src/ts/app.ts @@ -97,27 +97,9 @@ declare const Prism: any; } UI.updateUI(); - - setInterval(() => { - const countdown = document.querySelector("#usa-countdown p"); - const start = new Date().getTime(); - const end = Date.UTC(2024, 2, 7, 13, 20); - const diff = end - start; - let days = Math.floor(diff / (1000 * 60 * 60 * 24)); - let hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); - let minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60)); - let seconds = Math.floor((diff % (1000 * 60)) / 1000); - if (days < 0) days = 0 - if (hours < 0) hours = 0; - if (minutes < 0) minutes = 0; - if (seconds < 0) seconds = 0; - - const blogUrl = '/blog/2024/02/19/the-american'; - const dayStr = days.toString().padStart(2, '0'); - const hourStr = hours.toString().padStart(2, '0'); - const minuteStr = minutes.toString().padStart(2, '0'); - const secondStr = seconds.toString().padStart(2, '0'); - countdown.innerHTML = `${dayStr} : ${hourStr} : ${minuteStr} : ${secondStr}`; - }, 1000); + const usaCountdown = document.getElementById("usa-countdown"); + usaCountdown.addEventListener("click", () => window.location.href = "/blog/2024/02/19/the-american"); + UI.updateUsaCountdown(usaCountdown); + setInterval(() => UI.updateUsaCountdown(usaCountdown), 1000); })();