Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions src/frets/Chord.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script>
import { getChordVariations } from "../frets/chordFingerings.js";
import { tunings } from "$lib";
import { getContext } from "svelte";
import { getContext, onMount } from "svelte";
import { SVGuitarChord } from "svguitar";

let {
Expand All @@ -16,11 +16,15 @@
let el = $state(null);
let width = $state(0);
let height = $state(0);
let isDarkMode = $state(false);

const variations = $derived(getChordVariations(chordName, tuning));
// Use the first variation
const chordData = $derived(variations.positions[position]);

// Colors based on color scheme
const chordColor = $derived(isDarkMode ? "#e5e7eb" : "#333");

function playChord() {
if (chordData?.midi) {
console.log("Playing chord:", chordName, "MIDI:", chordData.midi);
Expand All @@ -32,6 +36,17 @@
}
}

onMount(() => {
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
isDarkMode = mediaQuery.matches;

const handler = (e) => {
isDarkMode = e.matches;
};
mediaQuery.addEventListener("change", handler);
return () => mediaQuery.removeEventListener("change", handler);
});

$effect(() => {
// Redraw the chord whenever props or chordData changes
if (!el || !chordData) return;
Expand All @@ -49,11 +64,12 @@
position: chordData.position,
strokeWidth: 1,
fingerSize: 0.5,
fingerColor: "#333",
fingerColor: chordColor,
fingerTextColor: isDarkMode ? "#374151" : "#fff",
fingerTextSize: 20,
fretSize: 1.1,
fretColor: "#333",
color: "#333",
fretColor: chordColor,
color: chordColor,
titleFontSize: 28,
titleBottomMargin: 10,
fretLabelFontSize: 20,
Expand Down Expand Up @@ -87,7 +103,7 @@

<style>
:global(.barre-rectangle) {
fill: #333 !important;
@apply fill-[#333] dark:fill-[#e5e7eb];
}

:global(.tuning) {
Expand Down
9 changes: 9 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,12 @@
--color-purple-900: #581c87;
--color-purple-950: #3b0764;
}

/* Base styles for light/dark mode */
html {
@apply bg-white text-gray-900 dark:bg-gray-900 dark:text-gray-100;
}

select {
@apply w-fit border border-gray-200 rounded-sm dark:border-blue-700/50 dark:bg-blue-900/50 dark:text-blue-50 dark:hover:bg-blue-800 dark:hover:border-blue-700;
}
6 changes: 3 additions & 3 deletions src/lib/FretBoard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<line
x1={fretX(1) - margin.left}
x2={width - margin.right - margin.left}
class="stroke-gray-100"
class="stroke-gray-100 dark:stroke-blue-950"
stroke-width={lineW(i)} />
{#each notes as stringNote}
<g
Expand Down Expand Up @@ -99,12 +99,12 @@
@reference "tailwindcss";

.fret-label {
@apply text-xs fill-gray-800 text-center -translate-y-2;
@apply text-xs fill-gray-800 text-center -translate-y-2 dark:fill-blue-500;
text-anchor: middle;
dominant-baseline: ideographic;
}

.fret-line {
@apply fill-gray-400 stroke-0;
@apply fill-gray-400 stroke-0 dark:fill-blue-950;
}
</style>
16 changes: 10 additions & 6 deletions src/lib/FretNote.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,38 @@
@reference "tailwindcss";

.fret-note-background {
@apply fill-white;
@apply fill-transparent;
}

.fret-note-text {
@apply text-xs fill-gray-500;
@apply text-xs fill-gray-500 dark:fill-blue-500;
}

.fret-note:not(.in-position):is(.in-scale) .fret-note-background {
@apply hidden;
}

.fret-note:not(.in-position):is(.in-scale) .fret-note-text {
@apply font-normal fill-gray-500;
@apply font-normal fill-gray-500 dark:fill-blue-500;
}

.in-scale .fret-note-background {
@apply fill-sky-600 stroke-1 stroke-sky-800;
@apply fill-sky-600 stroke-0 stroke-sky-800 dark:fill-blue-900 dark:stroke-sky-800;
}

.in-scale .fret-note-text {
@apply fill-white font-black;
}

.in-scale[data-interval="1P"] circle {
@apply fill-gray-800 stroke-gray-900 stroke-2;
@apply fill-gray-800 stroke-1 stroke-gray-900 dark:fill-blue-600 dark:stroke-blue-300;
}

.in-scale[data-interval="1P"] .fret-note-text {
@apply dark:fill-blue-100;
}

.in-scale:is([data-interval^="3"], [data-interval^="5"]) circle {
@apply fill-sky-800;
@apply fill-blue-700 stroke-1 stroke-blue-600;
}
</style>
2 changes: 1 addition & 1 deletion src/lib/KeySelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
let notes = ["C", "C#", "D", "Eb", "E", "F", "F#", "G", "Ab", "A", "Bb", "B"];
</script>

<select bind:value class="border-gray-300 w-fit">
<select bind:value>
{#each notes as note}
<option value={note}>
{note}
Expand Down
6 changes: 4 additions & 2 deletions src/lib/ScaleChords.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
});
</script>

<div class="text-xs text-gray-500 grid grid-cols-4 md:grid-cols-7 gap-5">
<div
class="text-xs text-gray-500 grid grid-cols-4 md:grid-cols-7 gap-5 dark:text-gray-400">
{#each chords as chord}
<div class="bg-gray-100 py-5">
<div
class="bg-gray-100 py-5 transition-all dark:bg-blue-900/20 dark:border dark:border-blue-900/50 dark:hover:bg-blue-900/40 rounded">
<Chord chordName={chord} />
</div>
{/each}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ScaleInfo.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
text-anchor="middle"
dy="25"
font-size="10"
class="text-black"
class="text-black dark:text-gray-200"
fill="currentColor">{note.interval}</text>
</g>
{/each}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ScaleSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
];
</script>

<select bind:value class="border-gray-300 w-fit">
<select bind:value>
{#each scales as scale}
<option value={scale}>
{scale}
Expand Down
4 changes: 2 additions & 2 deletions src/lib/SystemSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="flex gap-5">
<div>
<select bind:value={system} class="w-fit border border-gray-200">
<select bind:value={system}>
<option value="CAGED">CAGED</option>
<option value="Pentatonic">Pentatonic</option>
</select>
Expand Down Expand Up @@ -47,7 +47,7 @@
@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;
@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 {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/TuningSelector.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
let { value = $bindable() } = $props();
</script>

<select bind:value name="tuning" class="w-full border border-gray-200">
<select bind:value name="tuning">
{#each tunings as [name]}
<option value={name}>{name}</option>
{/each}
Expand Down
4 changes: 2 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
</svelte:head>

<div
class="flex bg-gray-50 *:p-5 *:border-r *:border-gray-200 border-b border-gray-300">
class="flex bg-gray-50 *:p-5 *:border-r *:border-gray-200 border-b border-gray-300 dark:bg-blue-950 dark:*:border-blue-900 dark:border-blue-900">
<div>
<TuningSelector bind:value={tuning} />
</div>
Expand All @@ -127,7 +127,7 @@
</div>

{#if triads.length > 0}
<div class="relative bg-gray-50 border-t border-gray-200 p-5">
<div class="relative bg-gray-50 p-5 dark:bg-transparent dark:border-blue-900">
<ScaleChords scale={scaleObj} />
</div>
{/if}