isle.pizza/src/lib/GoodbyePopup.svelte
Christian Semmler 804a87e687
Migrate frontend to Svelte 5
- Replace vanilla JS with Svelte 5 components
- Add Vite build system with Terser optimization
- Reorganize assets into src/ and public/ directories
- Update README with setup instructions
2026-01-11 19:10:16 -07:00

60 lines
1.7 KiB
Svelte
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script>
import { showGoodbyePopup, goodbyeProgress } from '../stores.js';
let timeout = null;
let interval = null;
$: if ($showGoodbyePopup) {
startCountdown();
}
function startCountdown() {
const duration = 4000;
const startTime = performance.now();
function animate(currentTime) {
const elapsed = currentTime - startTime;
const progress = Math.min(elapsed / duration, 1);
goodbyeProgress.set(progress * 100);
if (progress < 1) {
interval = requestAnimationFrame(animate);
}
}
interval = requestAnimationFrame(animate);
timeout = setTimeout(() => {
window.location.href = 'https://legoisland.org';
}, duration);
}
function cancel() {
if (timeout) {
clearTimeout(timeout);
timeout = null;
}
if (interval) {
cancelAnimationFrame(interval);
interval = null;
}
goodbyeProgress.set(0);
showGoodbyePopup.set(false);
}
</script>
{#if $showGoodbyePopup}
<div id="goodbye-popup" class="notification-popup">
<div class="notification-popup-content">
<button class="update-dismiss-btn" aria-label="Cancel" onclick={cancel}>×</button>
<div class="update-speech-bubble">
<p class="update-message">See you later, Brickulator!</p>
<div class="goodbye-progress">
<div class="goodbye-progress-bar" style="width: {$goodbyeProgress}%"></div>
</div>
</div>
</div>
<img src="later.webp" alt="Goodbye" class="update-character" width="150" height="187">
</div>
{/if}