added support for showOctaveNumber property

This commit is contained in:
Clément Le Bihan
2023-03-19 18:06:52 +01:00
parent 6a10ad2398
commit a9cd0f16ae
2 changed files with 21 additions and 1 deletions
+20 -1
View File
@@ -43,12 +43,13 @@ type OctaveProps = Parameters<typeof Box>[0] & {
startNote: Note;
endNote: Note;
showNoteNames: NoteNameBehavior;
showOctaveNumber: boolean;
onNoteDown: (note: PianoKey) => void;
onNoteUp: (note: PianoKey) => void;
};
const Octave = (props: OctaveProps) => {
const { number, startNote, endNote, showNoteNames, onNoteDown, onNoteUp } =
const { number, startNote, endNote, showNoteNames, showOctaveNumber, onNoteDown, onNoteUp } =
props;
const oK: PianoKey[] = octaveKeys.map((k) => {
return new PianoKey(k.note, k.accidental, number);
@@ -169,6 +170,24 @@ const Octave = (props: OctaveProps) => {
);
})}
</Row>
{showOctaveNumber && (
<Text
style={{
userSelect: "none",
WebkitUserSelect: "none",
MozUserSelect: "none",
msUserSelect: "none",
}}
fontSize="2xs"
color="black"
position="absolute"
bottom="0px"
left="2px"
m="2px"
>
{number}
</Text>
)}
</Box>
);
};
@@ -53,6 +53,7 @@ const VirtualPiano = ({
key={octaveNum}
number={octaveNum}
showNoteNames={showNoteNames}
showOctaveNumber={showOctaveNumbers}
startNote={octaveNum == startOctave ? startNote : notesList[0]}
endNote={octaveNum == endOctave ? endNote : notesList[notesList.length - 1]}
onNoteDown={onNoteDown}