Skip to content

Commit 07dfa18

Browse files
adjustment status component
1 parent b79f5f0 commit 07dfa18

File tree

2 files changed

+20
-26
lines changed

2 files changed

+20
-26
lines changed

Diff for: src/App.vue

+15-22
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ function openVoiceCapture(mode) {
1414
isVoiceCaptureExample.value = true;
1515
}
1616
17+
function statusVoiceCapture(value) {
18+
isVoiceCaptureExample.value = value;
19+
}
20+
1721
function returnVoiceTranscript(transcript) {
1822
voiceTextTranscript.value = transcript;
1923
}
@@ -25,19 +29,11 @@ function returnVoiceTranscript(transcript) {
2529
<h2>Voice Capture Example</h2>
2630
<div class="content-actions">
2731
<div class="example-actions">
28-
<button
29-
class="button-voicecapture-example"
30-
type="button"
31-
@click="openVoiceCapture('fullscreen')"
32-
>
32+
<button class="button-voicecapture-example" type="button" @click="openVoiceCapture('fullscreen')">
3333
<span class="material-symbols-outlined"> &#xe029; </span>
3434
<span class="material-symbols-outlined"> &#xe5d0; </span> FullScreen
3535
</button>
36-
<button
37-
class="button-voicecapture-example"
38-
type="button"
39-
@click="openVoiceCapture('float')"
40-
>
36+
<button class="button-voicecapture-example" type="button" @click="openVoiceCapture('float')">
4137
<span class="material-symbols-outlined"> &#xe029; </span>
4238
<span class="material-symbols-outlined"> &#xe62e; </span> Float
4339
</button>
@@ -62,24 +58,16 @@ function returnVoiceTranscript(transcript) {
6258
</div>
6359
</div>
6460

65-
<VoiceCaptureVue
66-
:start="isVoiceCaptureExample"
67-
@voiceTranscript="returnVoiceTranscript"
68-
:lang="langSelect"
69-
:mode="modeSelect"
70-
/>
61+
<VoiceCaptureVue :status="isVoiceCaptureExample" @voiceTranscript="returnVoiceTranscript"
62+
@onStatus="statusVoiceCapture" :lang="langSelect" :mode="modeSelect" />
7163

7264
<div v-if="voiceTextTranscript" class="content">
7365
<div class="input-group">
7466
<label for="voiceTextArea" class="input-label">
7567
<h2>Transcript Results</h2>
7668
</label>
77-
<textarea
78-
id="voiceTextArea"
79-
class="input-field textarea"
80-
v-model="voiceTextTranscript"
81-
placeholder="Texto do Voice Transcript"
82-
></textarea>
69+
<textarea id="voiceTextArea" class="input-field textarea" v-model="voiceTextTranscript"
70+
placeholder="Texto do Voice Transcript"></textarea>
8371
</div>
8472
</div>
8573
</div>
@@ -91,6 +79,7 @@ function returnVoiceTranscript(transcript) {
9179
width: 50%;
9280
display: flex;
9381
gap: 20px;
82+
9483
@media (max-width: 800px) {
9584
width: 100%;
9685
}
@@ -116,6 +105,7 @@ function returnVoiceTranscript(transcript) {
116105
.material-symbols-outlined {
117106
margin-right: 0.5rem;
118107
}
108+
119109
.material-symbols-outlined.plus {
120110
margin: 0 0.5rem;
121111
}
@@ -166,12 +156,15 @@ function returnVoiceTranscript(transcript) {
166156
.content-actions {
167157
display: flex;
168158
gap: 20px;
159+
169160
button,
170161
.language {
171162
width: 50%;
172163
}
164+
173165
@media (max-width: 800px) {
174166
flex-direction: column;
167+
175168
.language {
176169
width: 100%;
177170
}

Diff for: src/components/VoiceCapture.vue

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<section
33
class="voicecapture"
4-
:class="{ active: start, [mode]: mode }"
4+
:class="{ active: status, [mode]: mode }"
55
@click="deactivateVoice"
66
>
77
<button class="exit" type="button" @click="deactivateVoice">
@@ -29,7 +29,7 @@ import { translates } from './VoiceCapture.translate';
2929
export default {
3030
name: 'VoiceCapture',
3131
props: {
32-
start: {
32+
status: {
3333
type: Boolean,
3434
default: false,
3535
},
@@ -42,7 +42,7 @@ export default {
4242
default: 'fullscreen',
4343
},
4444
},
45-
emits: ['voiceTranscript'],
45+
emits: ['voiceTranscript', 'onStatus'],
4646
setup(props, { emit }) {
4747
const recognizing = ref(false);
4848
const errorOccurred = ref(false);
@@ -66,6 +66,7 @@ export default {
6666
recognizing.value = false;
6767
animationButton.value = false;
6868
recognition.value.stop();
69+
emit('onStatus', false);
6970
}
7071
};
7172
@@ -140,7 +141,7 @@ export default {
140141
return translationsForLang[key] || key;
141142
};
142143
143-
watch(() => props.start, (newVal) => {
144+
watch(() => props.status, (newVal) => {
144145
if (newVal) activateVoice();
145146
else deactivateVoice();
146147
});

0 commit comments

Comments
 (0)