Skip to content

Commit 4fe8c95

Browse files
committed
Add KoFi support button and update SVG icons
1 parent 0c89f37 commit 4fe8c95

File tree

8 files changed

+87
-67
lines changed

8 files changed

+87
-67
lines changed

src/app.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
/>
1111
<link rel="manifest" href="%sveltekit.assets%/manifest.webmanifest" />
1212

13-
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
13+
<meta
14+
name="viewport"
15+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
16+
/>
1417
<title>Visual Sorting aka The Sound Of Sorting</title>
1518
%sveltekit.head%
1619
</head>

src/lib/components/Header.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import HeaderThemeControl from './HeaderThemeControl.svelte';
55
import { base } from '$app/paths';
66
import HeaderGitHubButton from './HeaderGitHubButton.svelte';
7+
import HeaderCoffeeButton from './HeaderCoffeeButton.svelte';
78
import MobileHeaderButtons from './mobile/MobileHeaderButtons.svelte';
89
910
export let selectedTheme: string;
@@ -25,6 +26,7 @@
2526
<li><HeaderThemeControl bind:selectedTheme /></li>
2627
</ul>
2728
<HeaderGitHubButton />
29+
<HeaderCoffeeButton />
2830
</div>
2931

3032
<MobileHeaderButtons bind:oscillatorType bind:selectedTheme />
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<script lang="ts">
2+
import { trackEvent } from '../umami';
3+
4+
const handleClick = () => {
5+
trackEvent('external-link', { destination: 'ko-fi' });
6+
};
7+
</script>
8+
9+
<a
10+
class="lg:btn lg:btn-square lg:btn-ghost"
11+
href="https://ko-fi.com/mszula"
12+
target="_blank"
13+
on:click={handleClick}
14+
>
15+
<svg
16+
xmlns="http://www.w3.org/2000/svg"
17+
class="w-[24px] h-[24px]"
18+
width="24"
19+
height="24"
20+
viewBox="0 0 24 24"
21+
fill="none"
22+
stroke="currentColor"
23+
stroke-width="2"
24+
stroke-linecap="round"
25+
stroke-linejoin="round"
26+
><path d="M10 2v2" /><path d="M14 2v2" /><path
27+
d="M16 8a1 1 0 0 1 1 1v8a4 4 0 0 1-4 4H7a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1h14a4 4 0 1 1 0 8h-1"
28+
/><path d="M6 2v2" /></svg
29+
>
30+
<span class="lg:hidden inline">https://ko-fi.com/mszula</span>
31+
</a>

src/lib/components/HeaderGitHubButton.svelte

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@
1313
on:click={handleClick}
1414
>
1515
<svg
16-
class="w-[24px] h-[24px]"
17-
aria-hidden="true"
18-
fill="currentColor"
19-
viewBox="0 0 20 20"
2016
xmlns="http://www.w3.org/2000/svg"
17+
width="24"
18+
height="24"
19+
viewBox="0 0 24 24"
20+
fill="none"
21+
stroke="currentColor"
22+
stroke-width="2"
23+
stroke-linecap="round"
24+
stroke-linejoin="round"
25+
class="w-[24px] h-[24px]"
26+
><path
27+
d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4"
28+
/><path d="M9 18c-4.51 2-5-2-7-2" /></svg
2129
>
22-
<path
23-
clip-rule="evenodd"
24-
d="M10 .333A9.911 9.911 0 0 0 6.866 19.65c.5.092.678-.215.678-.477 0-.237-.01-1.017-.014-1.845-2.757.6-3.338-1.169-3.338-1.169a2.627 2.627 0 0 0-1.1-1.451c-.9-.615.07-.6.07-.6a2.084 2.084 0 0 1 1.518 1.021 2.11 2.11 0 0 0 2.884.823c.044-.503.268-.973.63-1.325-2.2-.25-4.516-1.1-4.516-4.9A3.832 3.832 0 0 1 4.7 7.068a3.56 3.56 0 0 1 .095-2.623s.832-.266 2.726 1.016a9.409 9.409 0 0 1 4.962 0c1.89-1.282 2.717-1.016 2.717-1.016.366.83.402 1.768.1 2.623a3.827 3.827 0 0 1 1.02 2.659c0 3.807-2.319 4.644-4.525 4.889a2.366 2.366 0 0 1 .673 1.834c0 1.326-.012 2.394-.012 2.72 0 .263.18.572.681.475A9.911 9.911 0 0 0 10 .333Z"
25-
fill-rule="evenodd"
26-
/>
27-
</svg>
30+
2831
<span class="lg:hidden inline">https://github.com/mszula/visual-sorting</span>
2932
</a>

src/lib/components/HeaderSoundControl.svelte

Lines changed: 2 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -30,41 +30,9 @@
3030
on:click|stopPropagation={handleMenuOutsideClick(ref, 'soundSelect')}
3131
>
3232
{#if oscillatorType}
33-
<svg
34-
class="w-[28px] h-[28px]"
35-
aria-hidden="true"
36-
xmlns="http://www.w3.org/2000/svg"
37-
width="24"
38-
height="24"
39-
fill="none"
40-
viewBox="0 0 24 24"
41-
>
42-
<path
43-
stroke="currentColor"
44-
stroke-linecap="round"
45-
stroke-linejoin="round"
46-
stroke-width="2"
47-
d="M15.5 8.43A4.985 4.985 0 0 1 17 12a4.984 4.984 0 0 1-1.43 3.5m2.794 2.864A8.972 8.972 0 0 0 21 12a8.972 8.972 0 0 0-2.636-6.364M12 6.135v11.73a1 1 0 0 1-1.64.768L6 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1h2l4.36-3.633a1 1 0 0 1 1.64.768Z"
48-
/>
49-
</svg>
33+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="w-[28px] h-[28px]"><path d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path d="M16 9a5 5 0 0 1 0 6"/><path d="M19.364 18.364a9 9 0 0 0 0-12.728"/></svg>
5034
{:else}
51-
<svg
52-
class="w-[28px] h-[28px]"
53-
aria-hidden="true"
54-
xmlns="http://www.w3.org/2000/svg"
55-
width="24"
56-
height="24"
57-
fill="none"
58-
viewBox="0 0 24 24"
59-
>
60-
<path
61-
stroke="currentColor"
62-
stroke-linecap="round"
63-
stroke-linejoin="round"
64-
stroke-width="2"
65-
d="M15.5 8.43A4.985 4.985 0 0 1 17 12c0 1.126-.5 2.5-1.5 3.5m2.864-9.864A8.972 8.972 0 0 1 21 12c0 2.023-.5 4.5-2.5 6M7.8 7.5l2.56-2.133a1 1 0 0 1 1.64.768V12m0 4.5v1.365a1 1 0 0 1-1.64.768L6 15H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1m1-4 14 14"
66-
/>
67-
</svg>
35+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="w-[28px] h-[28px]"><path d="M16 9a5 5 0 0 1 .95 2.293"/><path d="M19.364 5.636a9 9 0 0 1 1.889 9.96"/><path d="m2 2 20 20"/><path d="m7 7-.587.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298V11"/><path d="M9.828 4.172A.686.686 0 0 1 11 4.657v.686"/></svg>
6836
{/if}
6937
{oscillatorType ? getOscillatorName(oscillatorType) : 'None'}
7038
</summary>

src/lib/components/HeaderThemeControl.svelte

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,32 @@
2020
</script>
2121

2222
<details bind:this={ref}>
23-
<summary on:click|stopPropagation={handleMenuOutsideClick(ref, 'setTheme')}
24-
><svg
25-
class="w-[24px] h-[24px]"
26-
aria-hidden="true"
27-
fill="none"
28-
viewBox="0 0 21 21"
23+
<summary on:click|stopPropagation={handleMenuOutsideClick(ref, 'setTheme')}>
24+
<svg
2925
xmlns="http://www.w3.org/2000/svg"
26+
width="24"
27+
height="24"
28+
viewBox="0 0 24 24"
29+
fill="none"
30+
stroke="currentColor"
31+
stroke-width="2"
32+
stroke-linecap="round"
33+
stroke-linejoin="round"
34+
class="w-[24px] h-[24px]"
35+
><path
36+
d="M12 22a1 1 0 0 1 0-20 10 9 0 0 1 10 9 5 5 0 0 1-5 5h-2.25a1.75 1.75 0 0 0-1.4 2.8l.3.4a1.75 1.75 0 0 1-1.4 2.8z"
37+
/><circle cx="13.5" cy="6.5" r=".5" fill="currentColor" /><circle
38+
cx="17.5"
39+
cy="10.5"
40+
r=".5"
41+
fill="currentColor"
42+
/><circle cx="6.5" cy="12.5" r=".5" fill="currentColor" /><circle
43+
cx="8.5"
44+
cy="7.5"
45+
r=".5"
46+
fill="currentColor"
47+
/></svg
3048
>
31-
<path
32-
d="M11.15 5.6h.01m3.337 1.913h.01m-6.979 0h.01M5.541 11h.01M15 15h2.706a1.957 1.957 0 0 0 1.883-1.325A9 9 0 1 0 2.043 11.89 9.1 9.1 0 0 0 7.2 19.1a8.62 8.62 0 0 0 3.769.9A2.013 2.013 0 0 0 13 18v-.857A2.034 2.034 0 0 1 15 15Z"
33-
stroke="currentColor"
34-
stroke-linecap="round"
35-
stroke-linejoin="round"
36-
stroke-width="2"
37-
/>
38-
</svg>
3949
<span class="md:hidden"
4050
>{selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1)}</span
4151
>

src/lib/sort-algorithms/tim-sort.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { SortingGenerator } from "./types";
1+
import type { SortingGenerator } from './types';
22

33
/**
44
* The size at or below which a run is considered "small" and
@@ -25,7 +25,7 @@ function minRunLength(n: number): number {
2525
/**
2626
* Sorts a subarray using insertion sort.
2727
* This is used by Timsort to extend small runs to ensure they are at least minRun long.
28-
*
28+
*
2929
* @param arr - The array to sort.
3030
* @param start - Start index of the subarray.
3131
* @param end - End index of the subarray (inclusive).
@@ -51,7 +51,7 @@ function* insertionSort(
5151
* Scans forward from `start` to find a run (ascending or strictly descending).
5252
* If run is descending, it is reversed.
5353
* Returns the end index of the run (inclusive).
54-
*
54+
*
5555
* @param arr - The array.
5656
* @param start - Start index to detect run.
5757
* @param n - Total length of the array.
@@ -99,10 +99,10 @@ function* countRunAndMakeAscending(
9999
/**
100100
* Merges two sorted sub-runs:
101101
* arr[start..mid] and arr[mid+1..end]
102-
*
102+
*
103103
* This is a standard merging procedure but may be enhanced with Timsort's "galloping" optimization.
104104
* For simplicity, we will not implement galloping here, just a standard merge.
105-
*
105+
*
106106
* @param arr - The array.
107107
* @param start - Start index of first run.
108108
* @param mid - End index of first run.
@@ -145,7 +145,7 @@ function* merge(
145145

146146
/**
147147
* Timsort main function:
148-
*
148+
*
149149
* Steps:
150150
* 1. Calculate minRun.
151151
* 2. Identify natural runs, extend them to length at least minRun with insertion sort.
@@ -191,7 +191,7 @@ export function* timSort(arr: number[]): SortingGenerator {
191191
const shouldMerge =
192192
(n > 2 &&
193193
runStack[n - 3][1] <= runStack[n - 2][1] + runStack[n - 1][1]) ||
194-
(lenY <= lenZ);
194+
lenY <= lenZ;
195195

196196
if (!shouldMerge) break;
197197

src/lib/umami.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
export const trackEvent = (eventName: string, eventData?: Record<string, string | number>) => {
1+
export const trackEvent = (
2+
eventName: string,
3+
eventData?: Record<string, string | number>
4+
) => {
25
if (typeof window !== 'undefined' && (window as any).umami) {
36
(window as any).umami.track(eventName, eventData);
47
}

0 commit comments

Comments
 (0)