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:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user