mirror of
https://github.com/9x/sheetmusictrainer.git
synced 2026-09-02 09:34:33 +02:00
"Good" animation
This commit is contained in:
@@ -205,7 +205,8 @@ function App() {
|
|||||||
// Common success handler
|
// Common success handler
|
||||||
const handleMatchSuccess = useCallback(() => {
|
const handleMatchSuccess = useCallback(() => {
|
||||||
// Success!
|
// Success!
|
||||||
setFeedbackMessage("Good!");
|
const noteDetails = getNoteDetails(targetMidi);
|
||||||
|
setFeedbackMessage(`Good! ${noteDetails.name}`);
|
||||||
setRevealed(true);
|
setRevealed(true);
|
||||||
setMatchStartTime(null);
|
setMatchStartTime(null);
|
||||||
|
|
||||||
@@ -255,7 +256,7 @@ function App() {
|
|||||||
|
|
||||||
if (playedMidi === targetMidi) {
|
if (playedMidi === targetMidi) {
|
||||||
// Instant match
|
// Instant match
|
||||||
if (feedbackMessage !== "Good!") {
|
if (!feedbackMessage.startsWith("Good!")) {
|
||||||
handleMatchSuccess();
|
handleMatchSuccess();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,7 +271,7 @@ function App() {
|
|||||||
|
|
||||||
if (pitchData.midi === targetMidi) {
|
if (pitchData.midi === targetMidi) {
|
||||||
// Prevent re-triggering success if we're already in a success state
|
// Prevent re-triggering success if we're already in a success state
|
||||||
if (feedbackMessage === "Good!") return;
|
if (feedbackMessage.startsWith("Good!")) return;
|
||||||
|
|
||||||
if (matchStartTime === null) {
|
if (matchStartTime === null) {
|
||||||
setMatchStartTime(Date.now());
|
setMatchStartTime(Date.now());
|
||||||
|
|||||||
@@ -157,11 +157,8 @@ export const SheetMusic: React.FC<SheetMusicProps> = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (type === 'played') {
|
if (type === 'played') {
|
||||||
if (midi === targetMidi) {
|
// Always use default style (text color), no green/red distinction
|
||||||
staveNote.setStyle({ fillStyle: "var(--color-success)", strokeStyle: "var(--color-success)" });
|
staveNote.setStyle({ fillStyle: "var(--color-text-main)", strokeStyle: "var(--color-text-main)" });
|
||||||
} else {
|
|
||||||
staveNote.setStyle({ fillStyle: "var(--color-error)", strokeStyle: "var(--color-error)" });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return { note: staveNote, clef: noteClef };
|
return { note: staveNote, clef: noteClef };
|
||||||
|
|||||||
Reference in New Issue
Block a user