refactor: unify NOTE_WIDTH constant with --note-width CSS variable

Read note width from the CSS custom property at runtime (cached on first
call) instead of duplicating the value in a JS constant.
This commit is contained in:
Julien Calixte
2026-02-15 09:09:20 +01:00
parent b03626bb1a
commit bf73f08cb2
4 changed files with 19 additions and 8 deletions

View File

@@ -1 +1,12 @@
export const NOTE_WIDTH = 480
let cached: number | undefined
export const getNoteWidth = () => {
if (cached === undefined) {
cached = parseInt(
getComputedStyle(document.documentElement).getPropertyValue(
"--note-width",
),
)
}
return cached
}