Skip to content

Commit

Permalink
Added leaving a star modal
Browse files Browse the repository at this point in the history
  • Loading branch information
mszula committed Nov 12, 2024
1 parent 550bfab commit 12e6f34
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
58 changes: 58 additions & 0 deletions src/lib/components/LeaveAStarModal.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<script lang="ts">
import { onMount } from 'svelte';
import { running } from '../../states';
let ref: HTMLDialogElement;
let timedOut = false;
onMount(() => {
if (localStorage.getItem('leaved-a-star')) {
return;
}
setTimeout(() => {
timedOut = true;
}, 60 * 1000);
});
$: if (!$running && timedOut) {
ref.showModal();
}
const click = () => {
localStorage.setItem('leaved-a-star', 'yup');
ref.close();
};
</script>

<dialog
id="leave_a_star"
class="modal modal-bottom sm:modal-middle"
{...$$restProps}
bind:this={ref}
>
<div class="modal-box">
<h3 class="text-lg font-bold">
⭐️ Support This Project by Leaving a Star!
</h3>
<p class="py-4">
If you find this project helpful or inspiring, consider showing your
support by leaving a star on GitHub. Your feedback motivates us to keep
improving!
</p>
<div class="modal-action">
<a
href="https://github.com/mszula/visual-sorting"
target="_blank"
rel="noopener noreferrer"
class="btn btn-primary"
on:click={click}
>
⭐️ Star on GitHub
</a>
<form method="dialog">
<button class="btn">Maybe Later</button>
</form>
</div>
</div>
</dialog>
2 changes: 2 additions & 0 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import { soundStart, soundStop, type OscillatorType } from '../lib/sound';
import { browser } from '$app/environment';
import MobileAlgorithmSelector from '$lib/components/mobile/MobileAlgorithmSelector.svelte';
import LeaveAStarModal from '$lib/components/LeaveAStarModal.svelte';
let selectedTheme: Theme = 'dim';
let size = 300;
Expand Down Expand Up @@ -151,4 +152,5 @@
</div>
<Footer />
</div>
<LeaveAStarModal />
</main>

0 comments on commit 12e6f34

Please sign in to comment.