feat: add note width modes

This commit is contained in:
lucaronin
2026-04-27 05:34:11 +02:00
parent fb39c6679a
commit f8721f2a1b
34 changed files with 353 additions and 233 deletions

23
src/utils/noteWidth.ts Normal file
View File

@@ -0,0 +1,23 @@
import type { NoteWidthMode } from '../types'
export const DEFAULT_NOTE_WIDTH_MODE: NoteWidthMode = 'normal'
export function normalizeNoteWidthMode(value: unknown): NoteWidthMode | null {
if (typeof value !== 'string') return null
const normalized = value.trim().toLowerCase()
return normalized === 'normal' || normalized === 'wide' ? normalized : null
}
export function resolveNoteWidthMode(
noteWidth: unknown,
defaultWidth: unknown,
): NoteWidthMode {
return normalizeNoteWidthMode(noteWidth)
?? normalizeNoteWidthMode(defaultWidth)
?? DEFAULT_NOTE_WIDTH_MODE
}
export function toggleNoteWidthMode(width: unknown): NoteWidthMode {
return resolveNoteWidthMode(width, DEFAULT_NOTE_WIDTH_MODE) === 'wide' ? 'normal' : 'wide'
}