message align left on oversize

pull/1/head
adb 4 years ago
parent 62ad4f40e8
commit 54d712555b

@ -1,7 +1,7 @@
<template> <template>
<div class="iconContainer" > <button class="iconContainer" >
<img class="icon" v-bind:src=ic alt="" /> <img class="icon" v-bind:src=ic alt="" />
</div> </button>
</template> </template>
<script> <script>
@ -22,6 +22,7 @@ name: "icon",
box-shadow: 3px 3px 10px #111; box-shadow: 3px 3px 10px #111;
cursor: pointer; cursor: pointer;
user-select: none; user-select: none;
border: none;
} }
.icon{ .icon{
position: absolute; position: absolute;

@ -1,34 +1,46 @@
<template> <template>
<div class="newMessageBanner"> <div class="newMessageBanner">
<label for="newMessageInput"></label><textarea id="newMessageInput" class="newMessageInput" placeholder="type a message ..." v-model="content" /> <label for="newMessageInput"></label>
<icon id="sendMessageBtn" style="position: absolute; right: 1rem; bottom: 0.5rem;" ic="./sym/ic_send_white_24px.svg" /> <textarea id="newMessageInput" class="newMessageInput" placeholder="type a message ..." v-model="msg.content.text" />
<icon v-on:click="sendMessage()" id="sendMessageBtn" style="position: absolute; right: 1rem; bottom: 0.5rem;" ic="./sym/ic_send_white_24px.svg" />
</div> </div>
</template> </template>
<script> <script>
import icon from './icon.vue'; import icon from './icon.vue';
import sendMessage from '../main.js'; import main from '../main.js';
export default { export default {
name: "newMessage", name: "newMessage",
components: { components: {
icon icon
}, },
props: {
content: String
},
mounted() { mounted() {
ResizeListener(document.getElementById("newMessageInput")); ResizeListener(document.getElementById("newMessageInput"));
document.getElementById("sendMessageBtn").addEventListener("click", () => { /*document.getElementById("sendMessageBtn").addEventListener("click", () => {
if (document.getElementById("newMessageInput").value !== '') { if (document.getElementById("newMessageInput").value !== '') {
sendMessage.methods.callSendMessage(document.getElementById("newMessageInput").value) main.methods.sendMessage(document.getElementById("newMessageInput").value)
document.getElementById("newMessageInput").value = '' document.getElementById("newMessageInput").value = ''
//sendMessage.methods.callSendMessage(this.data.message) //sendMessage.methods.callSendMessage(this.data.message)
} }
}) })*/
},
methods: {
sendMessage(){
this.msg.time = Date.now()
main.methods.sendWebSocket(this.msg)
}
}, },
data: function () { data(){
return { message: this.content} return {
msg: {
type: "message",
time: Date.now(),
content: {
text: ""
}
}
}
} }
} }

@ -12,8 +12,18 @@ export default {
sendMessage() sendMessage()
}, },
methods: { methods: {
callSendMessage(data) { sendMessage(message){
sendMessage(data) let msg = {
type: "message",
time: Date.now(),
content: {
message: message
}
}
socket.send(JSON.stringify(msg))
},
sendWebSocket(msg){
socket.send(JSON.stringify(msg))
} }
} }
} }

Loading…
Cancel
Save