-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Avoid reporting about unsupported Speech synthesis API on old Android * Allow to replay speaking card
- Loading branch information
Showing
7 changed files
with
67 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { CardUnderReviewStore } from "../../store/card-under-review-store.ts"; | ||
import { isSpeechSynthesisSupported } from "../../lib/voice-playback/speak.ts"; | ||
import { throttle } from "../../lib/throttle/throttle.ts"; | ||
import { css, cx } from "@emotion/css"; | ||
import { theme } from "../../ui/theme.tsx"; | ||
import React from "react"; | ||
import { observer } from "mobx-react-lite"; | ||
|
||
type Props = { | ||
card: CardUnderReviewStore; | ||
type: "front" | "back"; | ||
}; | ||
|
||
export const CardSpeaker = observer((props: Props) => { | ||
const { card, type } = props; | ||
if ( | ||
!isSpeechSynthesisSupported || | ||
!card.isOpened || | ||
type !== card.deckSpeakField || | ||
!card.isSpeakingCardsEnabledSettings | ||
) { | ||
return null; | ||
} | ||
|
||
// throttle is needed to avoid user clicking on the speaker button many times in a row hence creating many sounds | ||
return ( | ||
<i | ||
onClick={throttle(card.speak, 500)} | ||
className={cx( | ||
"mdi mdi-play-circle mdi-24px", | ||
css({ | ||
cursor: "pointer", | ||
position: "relative", | ||
top: 3, | ||
color: theme.buttonColor, | ||
}), | ||
)} | ||
/> | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters