Skip to content

Commit c8c9cde

Browse files
committed
KoFi support modal
1 parent 8a123d3 commit c8c9cde

2 files changed

Lines changed: 76 additions & 3 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<script lang="ts">
2+
import { onMount } from 'svelte';
3+
import { running } from '../../states';
4+
5+
let ref: HTMLDialogElement;
6+
let timedOut = false;
7+
let showed = false;
8+
9+
onMount(() => {
10+
if (localStorage.getItem('kofi-support-shown')) {
11+
return;
12+
}
13+
14+
setTimeout(() => {
15+
timedOut = true;
16+
}, 5 * 60 * 1000);
17+
});
18+
19+
$: if (!$running && timedOut && !showed) {
20+
ref.showModal();
21+
showed = true;
22+
}
23+
24+
const handleClick = () => {
25+
localStorage.setItem('kofi-support-shown', 'true');
26+
ref.close();
27+
};
28+
29+
const handleDismiss = () => {
30+
localStorage.setItem('kofi-support-shown', 'true');
31+
ref.close();
32+
};
33+
</script>
34+
35+
<dialog
36+
id="kofi_support"
37+
class="modal modal-bottom sm:modal-middle"
38+
{...$$restProps}
39+
bind:this={ref}
40+
>
41+
<div class="modal-box">
42+
<h3 class="text-lg font-bold">
43+
☕ Glad You're Here!
44+
</h3>
45+
<p class="py-4">
46+
Hey! I'm Mateusz, and I'm passionate about creating interactive projects
47+
that combine education with visual joy. If Visual Sorting brings you happiness
48+
and you'd like to see more projects like this, consider supporting me on Ko-Fi.
49+
</p>
50+
<p class="text-sm opacity-70 pb-2">
51+
Your support allows me to dedicate more time to creating and sharing
52+
tools like this with the community. Every coffee really makes a difference! 🚀
53+
</p>
54+
<div class="modal-action">
55+
<a
56+
href="https://ko-fi.com/mszula"
57+
target="_blank"
58+
rel="noopener noreferrer"
59+
class="btn btn-primary"
60+
on:click={handleClick}
61+
>
62+
☕ Buy Me a Coffee
63+
</a>
64+
<form method="dialog">
65+
<button class="btn" on:click={handleDismiss}>Maybe Later</button>
66+
</form>
67+
</div>
68+
</div>
69+
</dialog>

src/routes/+page.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import { browser } from '$app/environment';
2323
import MobileAlgorithmSelector from '$lib/components/mobile/MobileAlgorithmSelector.svelte';
2424
import LeaveAStarModal from '$lib/components/LeaveAStarModal.svelte';
25+
import KoFiSupportModal from '$lib/components/KoFiSupportModal.svelte';
2526
import { algorithms } from '$lib/sort-algorithms/algorithms';
2627
2728
let selectedTheme: Theme = 'dim';
@@ -51,7 +52,8 @@
5152
const algo = algorithms
5253
.flat()
5354
.find(
54-
(a) => a.name.toLowerCase().replace(/ /g, '-') === selectedAlgorithm
55+
(a: AlgorithmDefinition) =>
56+
a.name.toLowerCase().replace(/ /g, '-') === selectedAlgorithm
5557
);
5658
5759
if (algo) {
@@ -60,7 +62,8 @@
6062
}
6163
});
6264
63-
$: theme = daisyuiColors[selectedTheme];
65+
$: theme =
66+
(daisyuiColors as any)[selectedTheme] || (daisyuiColors as any).dim;
6467
$: {
6568
$arrayToSort = shuffle(generateArray(size));
6669
reset();
@@ -81,7 +84,7 @@
8184
if (next.done) {
8285
window.clearInterval(intervalRef);
8386
reset();
84-
87+
8588
break;
8689
}
8790
next.value && updateBars($arrayToSort, next.value);
@@ -187,4 +190,5 @@
187190
<Footer />
188191
</div>
189192
<LeaveAStarModal />
193+
<KoFiSupportModal />
190194
</main>

0 commit comments

Comments
 (0)