Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: add accessible fretbox voicing descriptions (#5556)

[._.]/ Adam Eivybc725b77ea23
diff --git a/client/src/components/songbook/ChordDiagram.jsx b/client/src/components/songbook/ChordDiagram.jsx
index 0835ef4d72..a653c334b5 100644
--- a/client/src/components/songbook/ChordDiagram.jsx
+++ b/client/src/components/songbook/ChordDiagram.jsx
@@ -20,6 +20,23 @@ const SIZES = {
md: { cell: 16, row: 15, dot: 4.5, font: 8.5 },
};
+const formatFretPosition = (fret, baseFret) => {
+ if (fret < 0) return 'muted';
+ if (fret === 0) return 'open';
+ const absoluteFret = baseFret > 1 ? baseFret + fret - 1 : fret;
+ return `fret ${absoluteFret}`;
+};
+
+const fretboxDescription = (voicing) => {
+ const { frets, baseFret, instrument, bass } = voicing;
+ const strings = frets
+ .map((fret, index) => `string ${frets.length - index}: ${formatFretPosition(fret, baseFret)}`)
+ .join(', ');
+ const base = baseFret > 1 ? ` Base fret ${baseFret}.` : '';
+ const bassHint = bass ? ` Bass note ${bass}.` : '';
+ return `${instrument} chord voicing. ${strings}.${base}${bassHint}`;
+};
+
const FretboxDiagram = ({ voicing, size }) => {
const s = SIZES[size] || SIZES.md;
const { frets, baseFret } = voicing;
@@ -32,13 +49,15 @@ const FretboxDiagram = ({ voicing, size }) => {
const stringX = (i) => left + i * s.cell;
return (
- <svg
- width={width}
- height={height}
- viewBox={`0 0 ${width} ${height}`}
- aria-hidden="true"
- className="text-gray-400"
- >
+ <>
+ <span className="sr-only">{fretboxDescription(voicing)}</span>
+ <svg
+ width={width}
+ height={height}
+ viewBox={`0 0 ${width} ${height}`}
+ aria-hidden="true"
+ className="text-gray-400"
+ >
{/* Nut (thick at first position) + frets */}
{Array.from({ length: rows + 1 }, (_, j) => (
<line
@@ -113,7 +132,8 @@ const FretboxDiagram = ({ voicing, size }) => {
/>
) : null))}
</g>
- </svg>
+ </svg>
+ </>
);
};
diff --git a/client/src/components/songbook/ChordDiagram.test.jsx b/client/src/components/songbook/ChordDiagram.test.jsx
index 5c6d6ecca7..187b7cde5e 100644
--- a/client/src/components/songbook/ChordDiagram.test.jsx
+++ b/client/src/components/songbook/ChordDiagram.test.jsx
@@ -15,6 +15,14 @@ describe('ChordDiagram', () => {
expect(container.textContent).not.toMatch(/fr/);
});
+ it('provides an accessible fret description for guitar voicings', () => {
+ const { container } = render(<ChordDiagram name="Am" instrument="guitar" />);
+ const description = container.querySelector('.sr-only');
+ expect(description).toHaveTextContent(
+ 'guitar chord voicing. string 6: muted, string 5: open, string 4: fret 2, string 3: fret 2, string 2: fret 1, string 1: open.',
+ );
+ });
+
it('labels the fret window for shapes above the nut', () => {
// C#m7 = A-form barre at fret 4.
const { container } = render(<ChordDiagram name="C#m7" instrument="guitar" />);
@@ -30,6 +38,13 @@ describe('ChordDiagram', () => {
expect(container.textContent).not.toContain('×');
});
+ it('provides an accessible fret description for ukulele voicings', () => {
+ const { container } = render(<ChordDiagram name="G7" instrument="ukulele" />);
+ expect(container.querySelector('.sr-only')).toHaveTextContent(
+ 'ukulele chord voicing. string 4: open, string 3: fret 2, string 2: fret 1, string 1: fret 2.',
+ );
+ });
+
it('renders piano voicings as note chips, prepending the slash bass', () => {
const { container } = render(<ChordDiagram name="Am/G" instrument="piano" />);
expect(container.querySelector('svg')).toBeNull();