From efae088a0f78eaa0e483c7709bb331809db9cbff Mon Sep 17 00:00:00 2001 From: Brian Cully Date: Mon, 10 Mar 2025 12:10:29 -0400 Subject: implement test hover behavior on key selector's note list --- index.html | 96 +++++++++++++++++++++++++++++----------------------------- key-picker.mjs | 18 +++++++++++ main.css | 4 +++ 3 files changed, 70 insertions(+), 48 deletions(-) diff --git a/index.html b/index.html index 44b0f8b..d1ecafb 100644 --- a/index.html +++ b/index.html @@ -26,69 +26,69 @@ - E - - - - - - - + E + + + + + + + - A - - - - - - - + A + + + + + + + - D - - - - - - - + D + + + + + + + - G - - - - - - - + G + + + + + + + - B - - - - - - - + B + + + + + + + - E - - - - - - - + E + + + + + + + diff --git a/key-picker.mjs b/key-picker.mjs index 431fdcd..3b4a378 100644 --- a/key-picker.mjs +++ b/key-picker.mjs @@ -11,6 +11,24 @@ function scaleFrom(tonic, scale) { } } +function handleNoteEnter(e) { + const n = e.target.innerText; + // todo: this should be delegated. the key selector shouldn't know + // about the fretboard at all. + document.querySelectorAll(`#fretboard [x-data-note="${n}"]`).forEach(elt => { + console.debug('wow! found elt', elt); + elt.classList.add('hover'); + }) +} +function handleNoteLeave(e) { + const n = e.target.innerText; + // ibid. + document.querySelectorAll(`#fretboard [x-data-note="${n}"]`).forEach(elt => { + console.debug('wow! found elt', elt); + elt.classList.remove('hover'); + }) +} + function formChanged(form) { const formData = new FormData(form); const scale = scaleFrom(formData.get('tonic'), formData.get('scale')); diff --git a/main.css b/main.css index 717fdfb..7f81ea8 100644 --- a/main.css +++ b/main.css @@ -3,6 +3,10 @@ body { background-color: white; } +.hover { + background-color: yellow; +} + #fretboard { float: left; padding-right: 1em; -- cgit v1.3