2021-07-07 18:07:58 +02:00
|
|
|
<script lang="ts">
|
|
|
|
import {chatMessagesStore, chatInputFocusStore} from "../../Stores/ChatStore";
|
|
|
|
|
|
|
|
let newMessageText = '';
|
|
|
|
|
|
|
|
function onFocus() {
|
|
|
|
chatInputFocusStore.set(true);
|
|
|
|
}
|
|
|
|
function onBlur() {
|
|
|
|
chatInputFocusStore.set(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
function saveMessage() {
|
|
|
|
if (!newMessageText) return;
|
|
|
|
chatMessagesStore.addPersonnalMessage(newMessageText);
|
|
|
|
newMessageText = '';
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<form on:submit|preventDefault={saveMessage}>
|
2021-07-13 11:00:32 +02:00
|
|
|
<input type="text" bind:value={newMessageText} placeholder="Enter your message..." on:focus={onFocus} on:blur={onBlur} >
|
2021-07-07 18:07:58 +02:00
|
|
|
<button type="submit">
|
|
|
|
<img src="/static/images/send.png" alt="Send" width="20">
|
|
|
|
</button>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
form {
|
|
|
|
display: flex;
|
|
|
|
padding-left: 4px;
|
|
|
|
padding-right: 4px;
|
|
|
|
|
|
|
|
input {
|
|
|
|
flex: auto;
|
2021-07-15 19:12:19 +02:00
|
|
|
background-color: #254560;
|
2021-07-07 18:07:58 +02:00
|
|
|
color: white;
|
|
|
|
border-bottom-left-radius: 4px;
|
|
|
|
border-top-left-radius: 4px;
|
|
|
|
border: none;
|
|
|
|
font-size: 22px;
|
2021-07-15 11:26:04 +02:00
|
|
|
font-family: Lato;
|
|
|
|
padding-left: 6px;
|
2021-07-12 11:59:05 +02:00
|
|
|
min-width: 0; //Needed so that the input doesn't overflow the container in firefox
|
|
|
|
outline: none;
|
2021-07-07 18:07:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
button {
|
2021-07-15 19:12:19 +02:00
|
|
|
background-color: #254560;
|
2021-07-07 18:07:58 +02:00
|
|
|
border-bottom-right-radius: 4px;
|
|
|
|
border-top-right-radius: 4px;
|
|
|
|
border: none;
|
2021-07-15 19:12:19 +02:00
|
|
|
border-left: solid white 1px;
|
2021-07-07 18:07:58 +02:00
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|