From f43561460d7e23db1d583c04d526a108d9aa38ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Sat, 18 Mar 2023 01:44:39 +0100 Subject: [PATCH] Added hover and clik effects --- front/components/VirtualPiano/Octave.tsx | 149 ++++++++++++++--------- 1 file changed, 89 insertions(+), 60 deletions(-) diff --git a/front/components/VirtualPiano/Octave.tsx b/front/components/VirtualPiano/Octave.tsx index 97587cc..3fa0d62 100644 --- a/front/components/VirtualPiano/Octave.tsx +++ b/front/components/VirtualPiano/Octave.tsx @@ -45,71 +45,100 @@ const Octave = ({ const whiteKeys = keys.filter((k) => k?.accidental === undefined); const blackKeys = keys.filter((k) => k?.accidental !== undefined); - const whiteKeyWidthExpr = '50px'; - const whiteKeyHeightExpr = '200px'; - const blackKeyWidthExpr = '25px'; - const blackKeyHeightExpr = '100px'; + const whiteKeyWidthExpr = "50px"; + const whiteKeyHeightExpr = "200px"; + const blackKeyWidthExpr = "25px"; + const blackKeyHeightExpr = "100px"; return ( - - - {whiteKeys.map((key, i) => { - return ( - onNoteDown(key)} - onPressOut={() => onNoteUp(key)} - > - + + {whiteKeys.map((key, i) => { + return ( + onNoteDown(key)} + onPressOut={() => onNoteUp(key)} > - - {key.note} - - - - ); - })} - - - {blackKeys.map((key, i) => { - return ( - onNoteDown(key)} - onPressOut={() => onNoteUp(key)} - > - 1) as unknown as number)) * 50 + (50 - (25 / 2))}px`, - top: "0px", - justifyContent: "flex-end", - alignItems: "center", - }} + {({ isHovered, isPressed }) => ( + + + {key.note} + + + )} + + ); + })} + + + {blackKeys.map((key, i) => { + return ( + onNoteDown(key)} + onPressOut={() => onNoteUp(key)} > - - {key.note + key.accidental} - - - - ); - })} - - + {({ isHovered, isPressed }) => ( + 1) as unknown as number)) * 50 + (50 - 25 / 2) + }px`, + top: "0px", + justifyContent: "flex-end", + alignItems: "center", + }} + > + + {key.note + key.accidental} + + + )} + + ); + })} + + ); };