-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
formats timer to prevent changes glitching on screen, adds location t…
…o change date for timer (#92)
- Loading branch information
1 parent
50591a3
commit 7bc0862
Showing
4 changed files
with
58 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,56 @@ | ||
<script> | ||
import { onMount, onDestroy } from 'svelte'; | ||
let days = 41; | ||
let hours = 14; | ||
let minutes = 54; | ||
let seconds = 19; | ||
onMount(() => { | ||
const countDownDate = new Date('August 1, 2024 23:59:59').getTime(); | ||
const interval = setInterval(() => { | ||
const now = new Date().getTime(); | ||
const distance = countDownDate - now; | ||
days = Math.floor(distance / (1000 * 60 * 60 * 24)); | ||
hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | ||
minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); | ||
seconds = Math.floor((distance % (1000 * 60)) / 1000); | ||
if (distance < 0) { | ||
clearInterval(interval); | ||
days = 0; | ||
hours = 0; | ||
minutes = 0; | ||
seconds = 0; | ||
} | ||
}, 1000); | ||
onDestroy(() => { | ||
import { onMount, onDestroy } from 'svelte'; | ||
import { timerCountdown } from '@content/externalLinks.js'; | ||
let days = 41; | ||
let hours = 14; | ||
let minutes = 54; | ||
let seconds = 19; | ||
onMount(() => { | ||
const countDownDate = new Date(timerCountdown.formatedDate).getTime(); | ||
const interval = setInterval(() => { | ||
const now = new Date().getTime(); | ||
const distance = countDownDate - now; | ||
days = Math.floor(distance / (1000 * 60 * 60 * 24)); | ||
hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | ||
minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); | ||
seconds = Math.floor((distance % (1000 * 60)) / 1000); | ||
if (distance < 0) { | ||
clearInterval(interval); | ||
}); | ||
days = 0; | ||
hours = 0; | ||
minutes = 0; | ||
seconds = 0; | ||
} | ||
}, 1000); | ||
onDestroy(() => { | ||
clearInterval(interval); | ||
}); | ||
</script> | ||
|
||
<div class="grid w-full grid-cols-1 gap-3 mt-8 lg:grid-cols-4 lg:inline-flex sm:justify-between"> | ||
<div class="hidden my-auto bg-red-600 w-42 lg:w-60 md:block"> | ||
<hr class="h-[1px] bg-white border-none" /> | ||
</div> | ||
{#each [days, hours, minutes, seconds] as time, index} | ||
<div class="items-center text-center" key={index}> | ||
<div class="mt-8 sm:mt-4"> | ||
<h3 class="text-8xl md:text-6xl font-extrabold font-menobanner">{time}</h3> | ||
<p class="font-bold text-xl md:text-base text-mcswf-gold"> | ||
{index === 0 ? 'DAYS' : index === 1 ? 'HOURS' : index === 2 ? 'MINUTES' : 'SECONDS'} | ||
</p> | ||
</div> | ||
}); | ||
</script> | ||
|
||
<div class="grid w-full grid-cols-1 gap-3 mt-8 lg:grid-cols-4 lg:inline-flex sm:justify-between"> | ||
<div class="invisible my-auto w-42 lg:w-60 lg:visible"> | ||
<hr class="h-1 bg-[#62040A] border-none" /> | ||
</div> | ||
{#each [days, hours, minutes, seconds] as time, index} | ||
<div | ||
class="items-center text-center" | ||
key={index}> | ||
<div class="mt-8 sm:mt-4 m-auto md:w-36"> | ||
<h3 class="text-[100px] font-extrabold font-menobanner">{time}</h3> | ||
<p class="font-semibold text-2xl md:text-[18px] text-mcswf-gold"> | ||
{index === 0 ? 'DAYS' : index === 1 ? 'HOURS' : index === 2 ? 'MINUTES' : 'SECONDS'} | ||
</p> | ||
</div> | ||
{/each} | ||
<div class="hidden my-auto w-42 lg:w-60 md:block"> | ||
<hr /> | ||
</div> | ||
</div> | ||
{/each} | ||
<div class="invisible lg:visible my-auto w-42 lg:w-60"> | ||
<hr class="h-1 bg-[#62040A] border-none" /> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters