-
Notifications
You must be signed in to change notification settings - Fork 3
Add shop countdown #12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
750d231
965835a
220513c
6f549ef
ad9df88
393c586
b0b570f
652a126
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,11 +1,66 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <script lang="ts"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import Head from '$lib/components/Head.svelte'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { onMount, onDestroy } from 'svelte'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let { data } = $props(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let timeLeft = $state({ days: 0, hours: 0, minutes: 0, seconds: 0 }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let interval: ReturnType<typeof setInterval>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const targetDate = new Date('2025-12-15T23:59:00-05:00').getTime(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
4
to
+10
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let { data } = $props(); | |
| let timeLeft = $state({ days: 0, hours: 0, minutes: 0, seconds: 0 }); | |
| let interval: ReturnType<typeof setInterval>; | |
| const targetDate = new Date('2025-12-15T23:59:00-05:00').getTime(); | |
| import { PUBLIC_SHOP_OPEN_DATE } from '$env/static/public'; | |
| let { data } = $props(); | |
| let timeLeft = $state({ days: 0, hours: 0, minutes: 0, seconds: 0 }); | |
| let interval: ReturnType<typeof setInterval>; | |
| const targetDate = new Date(PUBLIC_SHOP_OPEN_DATE).getTime(); |
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the countdown reaches zero, the message "Shop Opens In" may be confusing since the shop should now be open. Consider conditionally rendering different content after the countdown completes, such as "Shop is Now Open!" or hiding the countdown entirely.
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The countdown timer updates every second, which may cause screen readers to constantly announce changes. Consider adding aria-live="polite" to the countdown container and possibly throttling announcements (e.g., only announcing significant changes like minute updates) for better accessibility.
Copilot
AI
Dec 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The four time unit boxes have duplicated markup. Consider refactoring this into a reusable component or using an array with {#each} block to reduce code duplication and improve maintainability. For example:
{#each [
{ value: timeLeft.days, label: 'DAYS' },
{ value: timeLeft.hours, label: 'HOURS' },
{ value: timeLeft.minutes, label: 'MINS' },
{ value: timeLeft.seconds, label: 'SECS' }
] as unit}
<div class="themed-box flex min-w-[120px] flex-col items-center justify-center p-4">
<span class="mb-2 text-4xl md:text-5xl">{unit.value}</span>
<span class="text-xs text-primary-400 md:text-sm">{unit.label}</span>
</div>
{/each}| <div class="themed-box flex min-w-[120px] flex-col items-center justify-center p-4"> | |
| <span class="mb-2 text-4xl md:text-5xl">{timeLeft.days}</span> | |
| <span class="text-xs text-primary-400 md:text-sm">DAYS</span> | |
| </div> | |
| <div class="themed-box flex min-w-[120px] flex-col items-center justify-center p-4"> | |
| <span class="mb-2 text-4xl md:text-5xl">{timeLeft.hours}</span> | |
| <span class="text-xs text-primary-400 md:text-sm">HOURS</span> | |
| </div> | |
| <div class="themed-box flex min-w-[120px] flex-col items-center justify-center p-4"> | |
| <span class="mb-2 text-4xl md:text-5xl">{timeLeft.minutes}</span> | |
| <span class="text-xs text-primary-400 md:text-sm">MINS</span> | |
| </div> | |
| <div class="themed-box flex min-w-[120px] flex-col items-center justify-center p-4"> | |
| <span class="mb-2 text-4xl md:text-5xl">{timeLeft.seconds}</span> | |
| <span class="text-xs text-primary-400 md:text-sm">SECS</span> | |
| </div> | |
| {#each [ | |
| { value: timeLeft.days, label: 'DAYS' }, | |
| { value: timeLeft.hours, label: 'HOURS' }, | |
| { value: timeLeft.minutes, label: 'MINS' }, | |
| { value: timeLeft.seconds, label: 'SECS' } | |
| ] as unit} | |
| <div class="themed-box flex min-w-[120px] flex-col items-center justify-center p-4"> | |
| <span class="mb-2 text-4xl md:text-5xl">{unit.value}</span> | |
| <span class="text-xs text-primary-400 md:text-sm">{unit.label}</span> | |
| </div> | |
| {/each} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
intervalvariable is declared but not initialized, which may cause TypeScript strict mode errors. Consider either initializing it asundefinedexplicitly (let interval: ReturnType<typeof setInterval> | undefined;) or using TypeScript's definite assignment assertion (let interval!: ReturnType<typeof setInterval>;). The first approach is generally safer and more explicit.