import { getPentatonicScale, getFullScale, getChordTones, NOTES } from '../lib/theory' // Standard bass tuning (top of diagram = highest string) const STRINGS = [ { label: 'G', root: 7, thickness: 1.5 }, { label: 'D', root: 2, thickness: 2 }, { label: 'A', root: 9, thickness: 2.5 }, { label: 'E', root: 4, thickness: 3 }, ] const NUM_FRETS = 13 const FRET_MARKERS = [3, 5, 7, 9] const DOUBLE_MARKER = 12 // Layout const NUT_X = 40 const OPEN_X = 18 const FRET_W = 52 const STRING_H = 36 // wider spacing than guitar — 4 strings feel more spread const PAD_T = 28 const PAD_B = 18 const BOARD_W = NUT_X + (NUM_FRETS - 1) * FRET_W + 10 const BOARD_H = PAD_T + 3 * STRING_H + PAD_B const DOT_R = 10 const fretX = f => NUT_X + (f - 0.5) * FRET_W const stringY = si => PAD_T + si * STRING_H function noteColor(isChordTone, isPenta, isScale, mono = false) { if (isChordTone) return { fill: '#a855f7', text: '#fff' } if (isPenta) return mono ? { fill: '#c084fc', text: '#1e1b4b' } : { fill: '#f59e0b', text: '#000' } if (isScale) return mono ? { fill: '#e9d5ff', text: '#581c87' } : { fill: '#374151', text: '#d1d5db' } return null } export default function BassFretboard({ keyInfo, currentChord, monoColor = false }) { const { root, mode } = keyInfo ?? {} if (!root) return null const pentaSet = new Set(getPentatonicScale(root, mode).map(n => NOTES.indexOf(n))) const scaleSet = new Set(getFullScale(root, mode).map(n => NOTES.indexOf(n))) const chordSet = currentChord ? new Set(getChordTones(currentChord).map(n => NOTES.indexOf(n))) : new Set() return (

Bass — {root} {mode} {currentChord && / {currentChord}}

{/* Fretboard background */} {/* Position marker dots (centred between strings 1–2) */} {FRET_MARKERS.map(f => ( ))} {/* Double dot at 12 */} {/* Fret lines */} {Array.from({ length: NUM_FRETS - 1 }, (_, i) => i + 1).map(f => ( ))} {/* Nut */} {/* Strings — thicker as pitch drops */} {STRINGS.map((s, si) => ( ))} {/* Fret numbers */} {[3, 5, 7, 9, 12].map(f => ( {f} ))} {/* String labels */} {STRINGS.map((s, si) => ( {s.label} ))} {/* Note dots */} {STRINGS.flatMap((str, si) => Array.from({ length: NUM_FRETS }, (_, fi) => { const pc = (str.root + fi) % 12 const color = noteColor(chordSet.has(pc), pentaSet.has(pc), scaleSet.has(pc), monoColor) if (!color) return null const cx = fi === 0 ? OPEN_X : fretX(fi) const cy = stringY(si) return ( {NOTES[pc]} ) }) )}
Chord tone Pentatonic Scale
) }