Skip to content

Commit

Permalink
refactor(mon-pix): use PixIcon component for text-to-speech
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeyffrey authored Nov 25, 2024
1 parent 03a80f8 commit 7877298
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion mon-pix/app/components/assessment-banner.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PixTooltip class="assessment-banner__text-to-speech-toggle" @position="left" @isInline={{true}}>
<:triggerElement>
<button type="button" aria-label={{this.textToSpeechTooltipText}} {{on "click" @toggleTextToSpeech}}>
<FaIcon @icon={{this.textToSpeechIcon}} />
<PixIcon @name={{if @isTextToSpeechActivated "volumeOn" "volumeOff"}} />
</button>
</:triggerElement>
<:tooltip>
Expand Down
4 changes: 0 additions & 4 deletions mon-pix/app/components/assessment-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@ export default class AssessmentBanner extends Component {

@tracked showClosingModal = false;

get textToSpeechIcon() {
return this.args.isTextToSpeechActivated ? 'volume-high' : 'volume-xmark';
}

get textToSpeechTooltipText() {
return this.args.isTextToSpeechActivated
? this.intl.t('pages.challenge.statement.text-to-speech.deactivate')
Expand Down
4 changes: 2 additions & 2 deletions mon-pix/app/components/challenge-statement.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
<:triggerElement>
<button
type="button"
class="challenge-statement__text-to-speech-trigger"
aria-label={{this.textToSpeechButtonTooltipText}}
{{on "click" this.toggleInstructionTextToSpeech}}
class="challenge-statement__text-to-speech-trigger"
>
<FaIcon @icon={{this.textToSpeechButtonIcon}} />
<PixIcon @name={{if this.isSpeaking "stopCircle" "volumeOn"}} />
</button>
</:triggerElement>
<:tooltip>
Expand Down
3 changes: 0 additions & 3 deletions mon-pix/app/components/challenge-statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default class ChallengeStatement extends Component {
@tracked displayAlternativeInstruction = false;
@tracked isSpeaking = false;
@tracked textToSpeechButtonTooltipText = this.intl.t('pages.challenge.statement.text-to-speech.play');
@tracked textToSpeechButtonIcon = 'volume-high';

constructor() {
super(...arguments);
Expand Down Expand Up @@ -78,7 +77,6 @@ export default class ChallengeStatement extends Component {
speechSynthesis.cancel();
this.isSpeaking = false;
this.textToSpeechButtonTooltipText = this.intl.t('pages.challenge.statement.text-to-speech.play');
this.textToSpeechButtonIcon = 'volume-high';
} else {
const element = document.getElementsByClassName('challenge-statement-instruction__text')[0];
const textToSpeech = new SpeechSynthesisUtterance(element.innerText);
Expand All @@ -88,7 +86,6 @@ export default class ChallengeStatement extends Component {
textToSpeech.onend = () => {
this.isSpeaking = false;
this.textToSpeechButtonTooltipText = this.intl.t('pages.challenge.statement.text-to-speech.play');
this.textToSpeechButtonIcon = 'volume-high';
};
this.isSpeaking = true;
this.textToSpeechButtonTooltipText = this.intl.t('pages.challenge.statement.text-to-speech.stop');
Expand Down
5 changes: 5 additions & 0 deletions mon-pix/app/styles/components/_assessment-banner.scss
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,9 @@

.assessment-banner__text-to-speech-toggle {
z-index: 1;
line-height: 0;

button {
color: var(--pix-neutral-0);
}
}

0 comments on commit 7877298

Please sign in to comment.