From 1d9dad5a026a251588323e048fc591adcbaf7c8b Mon Sep 17 00:00:00 2001 From: Julian Jelfs Date: Fri, 24 Nov 2023 18:49:07 +0000 Subject: [PATCH] rejig message entry layout a bit (#4849) --- .../app/src/components/home/Footer.svelte | 51 +++++++- .../src/components/home/MessageActions.svelte | 10 +- .../src/components/home/MessageEntry.svelte | 110 ++++++++++-------- .../app/src/components/home/RepliesTo.svelte | 2 + .../app/src/components/home/ReplyingTo.svelte | 2 + 5 files changed, 117 insertions(+), 58 deletions(-) diff --git a/frontend/app/src/components/home/Footer.svelte b/frontend/app/src/components/home/Footer.svelte index 1cbc40be6d..5d8570bfc3 100644 --- a/frontend/app/src/components/home/Footer.svelte +++ b/frontend/app/src/components/home/Footer.svelte @@ -2,6 +2,7 @@ import { _ } from "svelte-i18n"; import ReplyingTo from "./ReplyingTo.svelte"; import MessageEntry from "./MessageEntry.svelte"; + import Close from "svelte-material-icons/Close.svelte"; import DraftMediaMessage from "./DraftMediaMessage.svelte"; import { toastStore } from "../../stores/toast"; import EmojiPicker from "./EmojiPicker.svelte"; @@ -17,6 +18,9 @@ AttachmentContent, } from "openchat-client"; import { createEventDispatcher, getContext } from "svelte"; + import HoverIcon from "../HoverIcon.svelte"; + import ModalContent from "../ModalContent.svelte"; + import { iconSize } from "../../stores/iconSize"; const client = getContext("client"); @@ -95,6 +99,25 @@ } +{#if messageAction === "emoji"} +
+ + +
+

{$_("pickEmoji")}

+ + (messageAction = undefined)}> + + + +
+ +
+ +
+
+{/if} + , - messageAction: MessageAction + messageAction: MessageAction, ): Map { const actions = new Map(); if (permissions.get("text") || messageAction === "file") { @@ -119,13 +119,13 @@ function cssVars(key: string): string { return `--top: ${top(supportedActions.get(key))}px; --transition-delay: ${delay( - supportedActions.get(key) + supportedActions.get(key), )}ms`; } function top(i: number | undefined): number { if (i === undefined) return 0; - return -75 - i * 45; + return -55 - i * 45; } function delay(i: number | undefined): number { @@ -284,7 +284,9 @@ left: toRem(-44); opacity: 0; position: absolute; - transition: top 200ms ease-in, opacity 200ms ease-in; + transition: + top 200ms ease-in, + opacity 200ms ease-in; @include z-index("action-list"); } diff --git a/frontend/app/src/components/home/MessageEntry.svelte b/frontend/app/src/components/home/MessageEntry.svelte index c2adc375cb..fdd5874054 100644 --- a/frontend/app/src/components/home/MessageEntry.svelte +++ b/frontend/app/src/components/home/MessageEntry.svelte @@ -94,7 +94,7 @@ if (editingEvent && editingEvent.index !== previousEditingEvent?.index) { if (editingEvent.event.content.kind === "text_content") { inp.textContent = formatUserGroupMentions( - formatUserMentions(editingEvent.event.content.text) + formatUserMentions(editingEvent.event.content.text), ); selectedRange = undefined; restoreSelection(); @@ -144,10 +144,10 @@ $: placeholder = !canEnterText ? $_("sendTextDisabled") : attachment !== undefined - ? $_("enterCaption") - : dragging - ? $_("dropFile") - : $_("enterMessage"); + ? $_("enterCaption") + : dragging + ? $_("dropFile") + : $_("enterMessage"); export function replaceSelection(text: string) { restoreSelection(); @@ -171,7 +171,7 @@ function uptoCaret( inputContent: string | null, - fn: (slice: string, pos: number) => void + fn: (slice: string, pos: number) => void, ): void { if (inputContent === null) return; @@ -228,7 +228,7 @@ typingTimer = window.setTimeout( () => dispatch("stopTyping"), - MARK_TYPING_STOPPED_INTERVAL_MS + MARK_TYPING_STOPPED_INTERVAL_MS, ); }); } @@ -363,7 +363,7 @@ if (tokenMatch && tokenMatch[2] !== undefined) { const token = tokenMatch[1]; const tokenDetails = Object.values($cryptoLookup).find( - (t) => t.symbol.toLowerCase() === token + (t) => t.symbol.toLowerCase() === token, ); if (tokenDetails !== undefined) { dispatch("tokenTransfer", { @@ -453,7 +453,7 @@ const replaced = `${inp.textContent?.slice( 0, - rangeToReplace[0] + rangeToReplace[0], )}${replacement} ${inp.textContent?.slice(rangeToReplace[1])}`; inp.textContent = replaced; @@ -552,51 +552,54 @@ {placeholder} {/if} - {#if editingEvent === undefined} - {#if permittedMessages.get("audio") && messageIsEmpty && audioMimeType !== undefined && audioSupported} -
- -
- {:else if canEnterText} + +
+ {#if editingEvent === undefined} + {#if permittedMessages.get("audio") && messageIsEmpty && audioMimeType !== undefined && audioSupported} +
+ +
+ {:else if canEnterText} +
+ + + +
+ {/if} + + + {:else}
- - + + + +
+
+ +
{/if} - - - {:else} -
- - - -
-
- - - -
- {/if} +
{/if} @@ -614,6 +617,11 @@ &.editing { background-color: var(--button-bg); } + + .icons { + display: flex; + align-self: flex-end; + } } .send { flex: 0 0 15px; @@ -626,7 +634,7 @@ border-radius: var(--entry-input-rd); outline: none; border: 0; - max-height: 100px; + max-height: calc(var(--vh, 1vh) * 50); min-height: toRem(30); overflow-x: hidden; overflow-y: auto; diff --git a/frontend/app/src/components/home/RepliesTo.svelte b/frontend/app/src/components/home/RepliesTo.svelte index 0a6b6c0bfd..0434e91c08 100644 --- a/frontend/app/src/components/home/RepliesTo.svelte +++ b/frontend/app/src/components/home/RepliesTo.svelte @@ -105,6 +105,8 @@ cursor: pointer; margin-bottom: $sp3; overflow: hidden; + @include nice-scrollbar(); + max-height: 300px; &.me { background-color: var(--currentChat-msg-me-bg); diff --git a/frontend/app/src/components/home/ReplyingTo.svelte b/frontend/app/src/components/home/ReplyingTo.svelte index 4d851ef506..58d0a86eb6 100644 --- a/frontend/app/src/components/home/ReplyingTo.svelte +++ b/frontend/app/src/components/home/ReplyingTo.svelte @@ -75,6 +75,8 @@ background-color: var(--currentChat-msg-bg); color: var(--currentChat-msg-txt); position: relative; + @include nice-scrollbar(); + max-height: 150px; .close-icon { position: absolute;