-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSystemSelector.svelte
More file actions
61 lines (55 loc) · 1.82 KB
/
Copy pathSystemSelector.svelte
File metadata and controls
61 lines (55 loc) · 1.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script>
import { cagedPositionMapping } from "../frets/system/patterns.js";
let { system = $bindable(), position = $bindable() } = $props();
// Get position key for CAGED in correct letter order
let cagedMap = "CAGED".split("").map((char) => {
return Object.entries(cagedPositionMapping).find(
([, label]) => label === char,
);
});
</script>
<div class="flex gap-5">
<div>
<select bind:value={system}>
<option value="CAGED">CAGED</option>
<option value="Pentatonic">Pentatonic</option>
</select>
</div>
<div class="flex items-start space-x-2">
{#if system === "CAGED"}
{#each cagedMap as [pos, label]}
<label
><input
type="radio"
name="position"
bind:group={position}
value={parseInt(pos)} />
<span>{label}</span></label>
{/each}
{:else if system === "Pentatonic"}
{#each Array(5) as _, index}
<label
><input
type="radio"
name="position"
bind:group={position}
value={index + 1} />
<span>{index + 1}</span></label>
{/each}
{/if}
{#if position !== null}
<button
class="flex justify-center items-center text-xs text-gray-500 bg-gray-300 border border-gray-500 rounded-full size-5 scale-75 cursor-pointer hover:bg-gray-100"
onclick={() => (position = null)}>✕</button>
{/if}
</div>
</div>
<style>
@reference "tailwindcss";
input[type="radio"] {
@apply border-gray-400 checked:bg-sky-600 checked:border-sky-600 active:bg-sky-200 focus:ring-1 focus:ring-sky-500 dark:bg-blue-900 dark:border-blue-500 dark:active:bg-blue-700 dark:checked:bg-blue-400 dark:checked:border-blue-200;
}
label {
@apply flex-col flex gap-1 items-center justify-center text-xs font-bold;
}
</style>