Skip to content

Commit 8fa7596

Browse files
committed
(props) move textareaAction icon to the right
1 parent a5a5a98 commit 8fa7596

File tree

3 files changed

+17
-21
lines changed

3 files changed

+17
-21
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ messages="[
561561
| messageActionHandler (3) | `{ roomId, action, message }` | A user clicks on the dropdown icon inside a message |
562562
| sendMessageReaction | `{ roomId, messageId, reaction, remove }` | A user clicks on the emoji icon inside a message |
563563
| roomInfo | `room` | A user clicks the room header bar |
564-
| textareaActionHandler (4) | `{ roomId, message }` | A user clicks on the left icon inside the footer |
564+
| textareaActionHandler (4) | `{ roomId, message }` | A user clicks on custom icon inside the footer |
565565
| typingMessage | `{ message, roomId }` | A user is typing a message |
566566

567567
(1) `fetchMessages` is triggered every time a room is opened. If the room is opened for the first time, the `options` param will hold `reset: true`
@@ -599,8 +599,7 @@ messageActionHandler({ roomId, action, message }) {
599599
}
600600
```
601601

602-
(4) `textareaActionHandler` can be used to add an extra icon on the left of the textarea.<br>
603-
By default, adding this event will automatically display a microphone icon. In that case, you can implement a speech recognition system and update the textarea value by using `roomMessage` prop.
602+
(4) `textareaActionHandler` can be used to add an extra icon on the right of the textarea, and recieve an event when clicking it.
604603

605604
(5) All file params contain: `{ blob, localURL, name, size, type }`
606605

demo/src/ChatContainer.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ export default {
477477
},
478478
479479
textareaActionHandler({ message, roomId }) {
480-
this.roomMessage = 'Implement your own speech recognition system!'
480+
this.roomMessage = 'Implement your own action!'
481481
},
482482
483483
async sendMessageReaction({ reaction, remove, messageId, roomId }) {

src/ChatWindow/Room.vue

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
</transition>
170170

171171
<div class="box-footer">
172-
<div class="icon-textarea-left" v-if="showAudio">
172+
<div class="icon-textarea-left" v-if="showAudio && !imageFile">
173173
<div class="svg-button" @click="recordAudio">
174174
<slot
175175
v-if="recorder.state === 'recording'"
@@ -183,11 +183,7 @@
183183
</div>
184184
</div>
185185

186-
<div
187-
class="image-container"
188-
:class="{ 'image-container-right': textareaAction }"
189-
v-if="imageFile"
190-
>
186+
<div class="image-container" v-if="imageFile">
191187
<div class="svg-button icon-image" @click="resetImageFile">
192188
<slot name="image-close-icon">
193189
<svg-icon name="close" param="image" />
@@ -208,7 +204,8 @@
208204
<svg-icon name="file" />
209205
</slot>
210206
</div>
211-
<div class="file-message">{{ message }}</div>
207+
<div class="file-message" v-if="file && file.audio">audio</div>
208+
<div class="file-message" v-else>{{ message }}</div>
212209
<div class="svg-button icon-remove" @click="resetMessage(null, true)">
213210
<slot name="file-close-icon">
214211
<svg-icon name="close" />
@@ -264,6 +261,16 @@
264261
</slot>
265262
</div>
266263

264+
<div
265+
v-if="textareaAction"
266+
@click="textareaActionHandler"
267+
class="svg-button"
268+
>
269+
<slot name="custom-action-icon">
270+
<svg-icon name="deleted" />
271+
</slot>
272+
</div>
273+
267274
<input
268275
v-if="showFiles"
269276
type="file"
@@ -549,8 +556,6 @@ export default {
549556
audio: true,
550557
localUrl: URL.createObjectURL(recordedBlob)
551558
}
552-
553-
this.message = 'audio'
554559
})
555560
},
556561
addNewMessage(message) {
@@ -947,10 +952,6 @@ textarea {
947952
top: 18px;
948953
}
949954
950-
.image-container-right {
951-
left: calc(16px + 43px);
952-
}
953-
954955
.image-file {
955956
display: flex;
956957
justify-content: center;
@@ -1107,10 +1108,6 @@ textarea {
11071108
left: 10px;
11081109
}
11091110
1110-
.image-container-right {
1111-
left: calc(10px + 39px);
1112-
}
1113-
11141111
.image-file img {
11151112
transform: scale(0.97);
11161113
}

0 commit comments

Comments
 (0)