frontend: add "send" button for small viewports

This commit is contained in:
hippoz 2022-04-27 20:12:04 +03:00
parent f67909c8e7
commit e0ba97deb3
Signed by: hippoz
GPG key ID: 7C52899193467641

View file

@ -1,17 +1,15 @@
<script> <script>
import request from "../request"; import { SendIcon } from "svelte-feather-icons";
import request from "../request";
import { apiRoute } from "../storage"; import { apiRoute } from "../storage";
import { messagesStoreProvider, overlayStore, userInfoStore } from "../stores"; import { messagesStoreProvider, overlayStore, smallViewport, userInfoStore } from "../stores";
export let channel; export let channel;
let messageInput = ""; let messageInput = "";
$: messages = messagesStoreProvider.getStore(channel.id); $: messages = messagesStoreProvider.getStore(channel.id);
const onKeydown = async (e) => { const sendMessage = async () => {
if (e.code !== "Enter")
return;
if (messageInput.trim() === "" || !$userInfoStore) if (messageInput.trim() === "" || !$userInfoStore)
return; return;
@ -44,10 +42,20 @@
}); });
} }
}; };
const onKeydown = async (e) => {
if (e.code !== "Enter")
return;
await sendMessage();
};
</script> </script>
<style> <style>
.message-input-container { .message-input-container {
display: flex;
justify-content: center;
align-items: center;
width: 100%; width: 100%;
padding: var(--space-norm); padding: var(--space-norm);
} }
@ -67,6 +75,10 @@
.message-input::placeholder { .message-input::placeholder {
color: var(--foreground-color-3); color: var(--foreground-color-3);
} }
.send-button {
margin-left: var(--space-sm);
}
</style> </style>
<div class="message-input-container"> <div class="message-input-container">
@ -77,4 +89,9 @@
on:keydown={ onKeydown } on:keydown={ onKeydown }
bind:value={ messageInput } bind:value={ messageInput }
> >
{#if $smallViewport}
<button class="icon-button send-button" on:click="{ sendMessage }">
<SendIcon />
</button>
{/if}
</div> </div>