+
@@ -657,7 +672,7 @@ export default function App() {
- OpenStand
+ OpenStand
Practice with a band in your browser
@@ -694,6 +709,16 @@ export default function App() {
>
)}
+ setChordFont((f) => (f === 'Plain' ? 'Handwritten' : 'Plain'))}
+ >
+ Aa
+
setLibraryOpen(!libraryOpen)}>
Tunes
@@ -732,6 +757,7 @@ export default function App() {
barBeats={position?.barBeats ?? 4}
range={picking && picking !== 'first' ? [picking.from, picking.from] : draft ? null : practice.loop}
selectedBar={draft ? editBar : null}
+ plain={chordFont === 'Plain'}
onBarClick={draft ? setEditBar : picking ? pickBar : undefined}
onChordClick={
!draft && !picking
diff --git a/src/index.css b/src/index.css
index 66aab9a..f1a1dac 100644
--- a/src/index.css
+++ b/src/index.css
@@ -181,6 +181,13 @@ button:disabled {
border-color: var(--ink-2);
}
+.topbar-chord-font {
+ font-family: var(--sans);
+ font-weight: 600;
+ letter-spacing: -0.02em;
+ padding: 0 9px;
+}
+
.topbar-link svg {
width: 15px;
height: 15px;
@@ -618,6 +625,26 @@ button:disabled {
color: var(--danger);
}
+/* Plain chord font (sans-serif) */
+[data-chord-font='plain'] .chord,
+[data-chord-font='plain'] .chord-accidental,
+[data-chord-font='plain'] .chord-quality,
+[data-chord-font='plain'] .chord-ext,
+[data-chord-font='plain'] .chord-bass {
+ font-family: var(--sans);
+ font-weight: 600;
+}
+
+[data-chord-font='plain'] .chord-accidental {
+ font-size: 0.65em;
+ translate: 0 -0.4em;
+}
+
+[data-chord-font='plain'] .chord-ext {
+ font-size: 0.55em;
+ translate: 0 -0.6em;
+}
+
/* ---------- Transport ---------- */
.transport {
@@ -703,6 +730,13 @@ button:disabled {
flex: 1;
}
+/* Practice, Chords and Mixer stay together on one row */
+.transport-band {
+ display: flex;
+ align-items: center;
+ gap: 20px;
+}
+
.control {
position: relative;
display: grid;
@@ -1371,12 +1405,45 @@ input.fader::-moz-range-thumb {
/* ---------- Narrow screens ---------- */
-@media (max-width: 1100px) {
- .topbar-tag,
+/* Key, Mode, Reads in, Tempo and the band buttons need about 1430px; below that, save room */
+@media (max-width: 1500px) {
.control-tempo input[type='range'] {
display: none;
}
+ .transport,
+ .controls,
+ .transport-band {
+ gap: 12px;
+ }
+
+ .transport-main {
+ min-width: 0;
+ }
+}
+
+@media (max-width: 1240px) {
+ :root {
+ --transport-h: auto;
+ }
+
+ .transport {
+ flex-wrap: wrap;
+ row-gap: 8px;
+ padding-block: 10px;
+ }
+
+ /* On the second row the band buttons sit at the right, so their panels open away from Play */
+ .transport-band {
+ margin-left: auto;
+ }
+}
+
+@media (max-width: 1100px) {
+ .topbar-tag {
+ display: none;
+ }
+
.transport,
.controls {
gap: 12px;
@@ -1422,6 +1489,10 @@ input.fader::-moz-range-thumb {
padding: 0 9px;
}
+ .topbar-chord-font {
+ padding: 0 7px;
+ }
+
.wordmark {
margin-right: auto;
}
@@ -1629,6 +1700,31 @@ input.fader::-moz-range-thumb {
}
}
+@media (max-width: 500px) {
+ .topbar {
+ gap: 4px;
+ padding: 0 8px;
+ }
+
+ .topbar-link,
+ .topbar-button,
+ .tunes-toggle,
+ .share .band-toggle {
+ padding: 0 7px;
+ }
+
+ .topbar-chord-font {
+ padding: 0 5px;
+ }
+}
+
+/* On the narrowest phones the logo mark alone is enough */
+@media (max-width: 360px) {
+ .wordmark-name {
+ display: none;
+ }
+}
+
@media (prefers-reduced-motion: reduce) {
* {
transition: none !important;
@@ -1717,6 +1813,15 @@ input.fader::-moz-range-thumb {
.bar-highlight {
display: none !important;
}
+
+ [data-chord-font='plain'] .chord,
+ [data-chord-font='plain'] .chord-accidental,
+ [data-chord-font='plain'] .chord-quality,
+ [data-chord-font='plain'] .chord-ext,
+ [data-chord-font='plain'] .chord-bass {
+ font-family: var(--sans);
+ font-weight: 600;
+ }
}
/* ---------- Style lab ---------- */
diff --git a/src/music/chordText.ts b/src/music/chordText.ts
new file mode 100644
index 0000000..1c289c7
--- /dev/null
+++ b/src/music/chordText.ts
@@ -0,0 +1,90 @@
+import { parseChord, spellRoot, type Chord } from './chords'
+
+export type ChordFont = 'Handwritten' | 'Plain'
+
+export const CHORD_FONT_KEY = 'openstand:chord-font'
+
+export function isChordFont(value: unknown): value is ChordFont {
+ return value === 'Handwritten' || value === 'Plain'
+}
+
+export function loadChordFont(): ChordFont {
+ try {
+ if (typeof localStorage === 'undefined') return 'Handwritten'
+ const saved = localStorage.getItem(CHORD_FONT_KEY)
+ return isChordFont(saved) ? saved : 'Handwritten'
+ } catch {
+ return 'Handwritten'
+ }
+}
+
+export interface ChordParts {
+ root: string
+ accidental: string
+ quality: string
+ extensions: string
+ bass: string
+}
+
+export function accidentalPlain(a: string): string {
+ return a === 'b' ? '♭' : a === '#' ? '♯' : ''
+}
+
+export function typesetPlain(suffix: string): { quality: string; extensions: string } {
+ const s = suffix
+ .replace('ø', 'h')
+ .replace('Δ', '^')
+ .replace(/^(min|mi|m)(?!aj)/, '-')
+ .replace(/^maj7?/, '^7')
+ .replace(/^dim/, 'o')
+ .replace(/^aug/, '+')
+
+ const match = /^([-^ho+])?(\d+)?(.*)$/.exec(s) ?? ['', '', '', s]
+ const markerType = match[1] ?? ''
+ const num = match[2] ?? ''
+ const rawExt = match[3] ?? ''
+
+ let extensions = rawExt
+ .replace(/\^7?/g, 'Δ7')
+ .replace(/b/g, '♭')
+ .replace(/#/g, '♯')
+
+ let quality = ''
+ if (markerType === 'h') {
+ quality = num ? 'm' + num : 'm7'
+ extensions = '♭5' + extensions
+ } else if (markerType === '^') {
+ quality = 'Δ' + (num || '7')
+ } else if (markerType === '-') {
+ quality = 'm' + num
+ } else if (markerType === 'o') {
+ quality = '°' + num
+ } else if (markerType === '+') {
+ quality = '+' + num
+ } else {
+ quality = num
+ }
+
+ return { quality, extensions }
+}
+
+export function plainChordParts(chord: Chord, keyPc = 0): ChordParts {
+ const name = spellRoot(chord.root, keyPc)
+ const root = name[0] ?? ''
+ const accidental = accidentalPlain(name[1] ?? '')
+ const { quality, extensions } = typesetPlain(chord.suffix)
+ let bass = ''
+ if (chord.bass !== chord.root) {
+ const bassName = spellRoot(chord.bass, keyPc)
+ bass = (bassName[0] ?? '') + accidentalPlain(bassName[1] ?? '')
+ }
+ return { root, accidental, quality, extensions, bass }
+}
+
+export function plainChordText(chord: Chord | string, keyPc = 0): string {
+ const c = typeof chord === 'string' ? parseChord(chord) : chord
+ if (!c) return typeof chord === 'string' ? chord : ''
+ const parts = plainChordParts(c, keyPc)
+ const bassPart = parts.bass ? `/${parts.bass}` : ''
+ return `${parts.root}${parts.accidental}${parts.quality}${parts.extensions}${bassPart}`
+}
diff --git a/src/ui/Chart.tsx b/src/ui/Chart.tsx
index 7951089..2a3c3ce 100644
--- a/src/ui/Chart.tsx
+++ b/src/ui/Chart.tsx
@@ -16,6 +16,7 @@ interface ChartProps {
barBeats: number
range?: [number, number] | null // looped bars
selectedBar?: number | null // the bar being edited
+ plain?: boolean
onBarClick?: (index: number) => void
onChordClick?: (chord: Chord) => void
header?: ReactNode // replaces the title block, e.g. with inputs in the editor
@@ -74,11 +75,12 @@ interface BarProps {
showTime: TimeSignature | null
inRange: boolean
selected: boolean
+ plain?: boolean
onClick?: (index: number) => void
onChordClick?: (chord: Chord) => void
}
-function Bar({ placed, prev, keyPc, active, progress, showTime, inRange, selected, onClick, onChordClick }: BarProps) {
+function Bar({ placed, prev, keyPc, active, progress, showTime, inRange, selected, plain, onClick, onChordClick }: BarProps) {
const { bar, chords, column, closesRow, index } = placed
const classes = ['bar']
if (bar.spacer) classes.push('bar-spacer')
@@ -148,7 +150,7 @@ function Bar({ placed, prev, keyPc, active, progress, showTime, inRange, selecte
{active && }
{chords.map(({ chord, symbol }, j) =>
chord ? (
-
+
) : symbol === null ? (
N.C.
@@ -170,7 +172,7 @@ function Bar({ placed, prev, keyPc, active, progress, showTime, inRange, selecte
}
export function Chart(props: ChartProps) {
- const { chart, style, transpose, activeMeasure, beatInBar, barBeats, range, selectedBar, onBarClick, onChordClick, header } = props
+ const { chart, style, transpose, activeMeasure, beatInBar, barBeats, range, selectedBar, plain, onBarClick, onChordClick, header } = props
const keyPc = (chart.key + transpose + 12) % 12
const layout = useMemo(() => rows(chart, transpose), [chart, transpose])
const keyName = prettyKey(noteName(keyPc, keyPrefersFlats(keyPc))) + (chart.minor ? '−' : '')
@@ -199,6 +201,7 @@ export function Chart(props: ChartProps) {
showTime={placed.index === 0 ? chart.time : (placed.bar.time ?? null)}
inRange={!!range && placed.index >= Math.min(...range) && placed.index <= Math.max(...range)}
selected={selectedBar === placed.index}
+ plain={plain}
onClick={onBarClick}
onChordClick={onChordClick}
/>
diff --git a/src/ui/ChordSymbol.tsx b/src/ui/ChordSymbol.tsx
index 8c20115..c797aae 100644
--- a/src/ui/ChordSymbol.tsx
+++ b/src/ui/ChordSymbol.tsx
@@ -1,4 +1,5 @@
import { spellRoot, type Chord } from '../music/chords'
+import { plainChordParts } from '../music/chordText'
// SMuFL chord-symbol glyphs (rendered with Petaluma Text), so symbols look hand-copied
const GLYPH = {
@@ -38,13 +39,53 @@ function typeset(suffix: string): { quality: string; extensions: string } {
export function ChordSymbol({
chord,
keyPc,
+ plain = false,
onSelect,
}: {
chord: Chord
keyPc: number
+ plain?: boolean
onSelect?: (chord: Chord) => void
}) {
const name = spellRoot(chord.root, keyPc)
+
+ if (plain) {
+ const parts = plainChordParts(chord, keyPc)
+ return (
+ {
+ e.stopPropagation()
+ onSelect(chord)
+ }
+ : undefined
+ }
+ onKeyDown={
+ onSelect
+ ? (e) => {
+ if (e.key !== 'Enter' && e.key !== ' ') return
+ e.preventDefault()
+ e.stopPropagation()
+ onSelect(chord)
+ }
+ : undefined
+ }
+ >
+ {parts.root}
+ {parts.accidental && {parts.accidental} }
+ {parts.quality && {parts.quality} }
+ {parts.extensions && {parts.extensions} }
+ {parts.bass && /{parts.bass} }
+
+ )
+ }
+
const { quality, extensions } = typeset(chord.suffix)
return (
- {props.children}
+
{props.children}
)
}
diff --git a/tests/chordText.test.ts b/tests/chordText.test.ts
new file mode 100644
index 0000000..3eff0e5
--- /dev/null
+++ b/tests/chordText.test.ts
@@ -0,0 +1,182 @@
+import { describe, expect, test } from 'vitest'
+import { parseChord } from '../src/music/chords'
+import {
+ CHORD_FONT_KEY,
+ isChordFont,
+ loadChordFont,
+ plainChordParts,
+ plainChordText,
+ typesetPlain,
+} from '../src/music/chordText'
+
+describe('chordText - plain chord text generation', () => {
+ test('converts standard jazz chord symbols to plain notation', () => {
+ // Required examples from issue specification
+ const cMaj7 = parseChord('C^7')!
+ expect(plainChordText(cMaj7, 0)).toBe('CΔ7')
+
+ const dMin7 = parseChord('D-7')!
+ expect(plainChordText(dMin7, 0)).toBe('Dm7')
+
+ const eHalfDim = parseChord('Eh7')!
+ expect(plainChordText(eHalfDim, 0)).toBe('Em7♭5')
+
+ const bDim7 = parseChord('Bo7')!
+ expect(plainChordText(bDim7, 0)).toBe('B°7')
+
+ const bb7b9 = parseChord('Bb7b9')!
+ expect(plainChordText(bb7b9, 0)).toBe('B♭7♭9')
+ })
+
+ test('accepts chord strings directly as input', () => {
+ expect(plainChordText('C^7', 0)).toBe('CΔ7')
+ expect(plainChordText('D-7', 0)).toBe('Dm7')
+ expect(plainChordText('Eh7', 0)).toBe('Em7♭5')
+ expect(plainChordText('Bo7', 0)).toBe('B°7')
+ expect(plainChordText('Bb7b9', 0)).toBe('B♭7♭9')
+ })
+
+ test('handles minor variants (- and min)', () => {
+ expect(plainChordText('A-', 0)).toBe('Am')
+ expect(plainChordText('Amin', 0)).toBe('Am')
+ expect(plainChordText('C-6', 0)).toBe('Cm6')
+ expect(plainChordText('C-9', 0)).toBe('Cm9')
+ expect(plainChordText('C-11', 0)).toBe('Cm11')
+ })
+
+ test('handles major 7th variants (^, maj, maj7)', () => {
+ expect(plainChordText('C^', 0)).toBe('CΔ7')
+ expect(plainChordText('Cmaj', 0)).toBe('CΔ7')
+ expect(plainChordText('Cmaj7', 0)).toBe('CΔ7')
+ expect(plainChordText('C^9', 0)).toBe('CΔ9')
+ })
+
+ test('handles half-diminished variants (h, h7, -7b5, m7b5, ø7)', () => {
+ expect(plainChordText('Eh', 0)).toBe('Em7♭5')
+ expect(plainChordText('Eh7', 0)).toBe('Em7♭5')
+ expect(plainChordText('E-7b5', 0)).toBe('Em7♭5')
+ expect(plainChordText('Em7b5', 0)).toBe('Em7♭5')
+ expect(plainChordText('Eø7', 0)).toBe('Em7♭5')
+ })
+
+ test('handles diminished variants (o, o7, dim, dim7)', () => {
+ expect(plainChordText('Bo', 0)).toBe('B°')
+ expect(plainChordText('Bo7', 0)).toBe('B°7')
+ expect(plainChordText('Bdim', 0)).toBe('B°')
+ expect(plainChordText('Bdim7', 0)).toBe('B°7')
+ })
+
+ test('handles augmented chords (+, aug, +7)', () => {
+ expect(plainChordText('C+', 0)).toBe('C+')
+ expect(plainChordText('Caug', 0)).toBe('C+')
+ expect(plainChordText('C+7', 0)).toBe('C+7')
+ })
+
+ test('handles dominant and altered extensions', () => {
+ expect(plainChordText('C7', 0)).toBe('C7')
+ expect(plainChordText('G7alt', 0)).toBe('G7alt')
+ expect(plainChordText('C7#9', 0)).toBe('C7♯9')
+ expect(plainChordText('C7b9#11', 0)).toBe('C7♭9♯11')
+ expect(plainChordText('C7b13', 0)).toBe('C7♭13')
+ expect(plainChordText('C7sus', 0)).toBe('C7sus')
+ })
+
+ test('handles slash chords and key context', () => {
+ // In key 0 (C), chromatic bass notes default to flats
+ expect(plainChordText('Bb7/D', 0)).toBe('B♭7/D')
+ expect(plainChordText('C/E', 0)).toBe('C/E')
+
+ // In key 9 (A major), written key has C#
+ expect(plainChordText('A/C#', 9)).toBe('A/C♯')
+
+ // In key 7 (G major), root is F#
+ expect(plainChordText('F#7', 7)).toBe('F♯7')
+ })
+
+ test('plainChordParts decomposes chord components accurately', () => {
+ const parts = plainChordParts(parseChord('Bb7b9')!, 0)
+ expect(parts).toEqual({
+ root: 'B',
+ accidental: '♭',
+ quality: '7',
+ extensions: '♭9',
+ bass: '',
+ })
+
+ const halfDimParts = plainChordParts(parseChord('Eh7')!, 0)
+ expect(halfDimParts).toEqual({
+ root: 'E',
+ accidental: '',
+ quality: 'm7',
+ extensions: '♭5',
+ bass: '',
+ })
+
+ const slashParts = plainChordParts(parseChord('A/C#')!, 9)
+ expect(slashParts).toEqual({
+ root: 'A',
+ accidental: '',
+ quality: '',
+ extensions: '',
+ bass: 'C♯',
+ })
+ })
+
+ test('typesetPlain extracts quality and extensions', () => {
+ expect(typesetPlain('^7')).toEqual({ quality: 'Δ7', extensions: '' })
+ expect(typesetPlain('-7')).toEqual({ quality: 'm7', extensions: '' })
+ expect(typesetPlain('h7')).toEqual({ quality: 'm7', extensions: '♭5' })
+ expect(typesetPlain('o7')).toEqual({ quality: '°7', extensions: '' })
+ expect(typesetPlain('7b9')).toEqual({ quality: '7', extensions: '♭9' })
+ })
+
+ test('handles invalid inputs gracefully', () => {
+ expect(plainChordText('NOT_A_CHORD', 0)).toBe('NOT_A_CHORD')
+ })
+})
+
+describe('chordFont settings', () => {
+ test('isChordFont recognizes valid font preferences', () => {
+ expect(isChordFont('Handwritten')).toBe(true)
+ expect(isChordFont('Plain')).toBe(true)
+ expect(isChordFont('other')).toBe(false)
+ expect(isChordFont(null)).toBe(false)
+ expect(isChordFont(undefined)).toBe(false)
+ })
+
+ test('loadChordFont falls back to Handwritten when storage is empty or invalid', () => {
+ const store = new Map
()
+ const mockStorage = {
+ getItem: (k: string) => store.get(k) ?? null,
+ setItem: (k: string, v: string) => store.set(k, String(v)),
+ removeItem: (k: string) => store.delete(k),
+ clear: () => store.clear(),
+ key: () => null,
+ length: 0,
+ }
+ const original = globalThis.localStorage
+ Object.defineProperty(globalThis, 'localStorage', {
+ value: mockStorage,
+ writable: true,
+ configurable: true,
+ })
+ try {
+ expect(loadChordFont()).toBe('Handwritten')
+
+ mockStorage.setItem(CHORD_FONT_KEY, 'invalid')
+ expect(loadChordFont()).toBe('Handwritten')
+
+ mockStorage.setItem(CHORD_FONT_KEY, 'Plain')
+ expect(loadChordFont()).toBe('Plain')
+
+ mockStorage.setItem(CHORD_FONT_KEY, 'Handwritten')
+ expect(loadChordFont()).toBe('Handwritten')
+ } finally {
+ Object.defineProperty(globalThis, 'localStorage', {
+ value: original,
+ writable: true,
+ configurable: true,
+ })
+ }
+ })
+})