improve messagePage
This commit is contained in:
Vendored
+59
-1
@@ -360,8 +360,8 @@ body[showing-chat] #chat-page-wrapper {
|
|||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
#message-page #composer {
|
#message-page #composer {
|
||||||
border-top: 1px solid var(--border);
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
#message-page #composer input {
|
#message-page #composer input {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
@@ -369,13 +369,71 @@ body[showing-chat] #chat-page-wrapper {
|
|||||||
max-width: unset;
|
max-width: unset;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
#message-page #composer {
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
#message-page #composer div {
|
||||||
|
width: 100%;
|
||||||
|
max-width: unset;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media (min-width: 700px) {
|
||||||
|
#message-page #composer .content-width-constraint,
|
||||||
|
#message-page #composer .input-width-constraint {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--max-content-width);
|
||||||
|
}
|
||||||
|
#message-page #composer .content-width-constraint {
|
||||||
|
max-width: var(--max-content-width);
|
||||||
|
}
|
||||||
|
#message-page #composer .input-width-constraint {
|
||||||
|
max-width: var(--max-input-width);
|
||||||
|
}
|
||||||
|
}
|
||||||
#message-page #message-container {
|
#message-page #message-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
padding: var(--content-padding);
|
padding: var(--content-padding);
|
||||||
gap: var(--gap-between-tiles);
|
gap: var(--gap-between-tiles);
|
||||||
|
height: auto;
|
||||||
|
max-height: unset;
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
}
|
}
|
||||||
|
.message-bubble {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--max-content-width);
|
||||||
|
}
|
||||||
|
.message-bubble > div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
background-color: var(--surface);
|
||||||
|
padding: var(--control-padding);
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--max-input-width);
|
||||||
|
}
|
||||||
|
.message-bubble .timestamp,
|
||||||
|
.message-bubble .sender-name {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
.message-bubble .sender-name {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
.message-bubble[sentbyuser] {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
.message-bubble[sentbyuser] {
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
.message-bubble[sentbyuser] span {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
/* src/View/Components/chatEntry.css */
|
/* src/View/Components/chatEntry.css */
|
||||||
.chat-entry {
|
.chat-entry {
|
||||||
|
|||||||
Vendored
+24
-5
@@ -664,12 +664,14 @@
|
|||||||
sender;
|
sender;
|
||||||
dateSent;
|
dateSent;
|
||||||
body = new State("");
|
body = new State("");
|
||||||
constructor(chatModel, chatMessage) {
|
sentByUser;
|
||||||
|
constructor(chatModel, chatMessage, sentByUser) {
|
||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
this.channel = chatMessage.channel;
|
this.channel = chatMessage.channel;
|
||||||
this.sender = chatMessage.sender;
|
this.sender = chatMessage.sender;
|
||||||
this.dateSent = new Date(chatMessage.dateSent).toLocaleString();
|
this.dateSent = new Date(chatMessage.dateSent).toLocaleString();
|
||||||
this.body.value = chatMessage.body;
|
this.body.value = chatMessage.body;
|
||||||
|
this.sentByUser = sentByUser;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -721,7 +723,11 @@
|
|||||||
};
|
};
|
||||||
// add
|
// add
|
||||||
addChatMessage = (chatMessage) => {
|
addChatMessage = (chatMessage) => {
|
||||||
const chatMessageModel = new ChatMessageViewModel(this.chatModel, chatMessage);
|
const chatMessageModel = new ChatMessageViewModel(
|
||||||
|
this.chatModel,
|
||||||
|
chatMessage,
|
||||||
|
chatMessage.sender == this.settingsViewModel.username.value
|
||||||
|
);
|
||||||
this.chatMessageViewModels.add(chatMessageModel);
|
this.chatMessageViewModels.add(chatMessageModel);
|
||||||
};
|
};
|
||||||
// settings
|
// settings
|
||||||
@@ -901,7 +907,20 @@
|
|||||||
|
|
||||||
// src/View/Components/chatMessage.tsx
|
// src/View/Components/chatMessage.tsx
|
||||||
function ChatMessage(chatMessageViewModel) {
|
function ChatMessage(chatMessageViewModel) {
|
||||||
return /* @__PURE__ */ createElement("div", { class: "tile flex-no" }, /* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", null, chatMessageViewModel.sender), /* @__PURE__ */ createElement("b", { "subscribe:innerText": chatMessageViewModel.body }), /* @__PURE__ */ createElement("span", null, chatMessageViewModel.dateSent)));
|
return /* @__PURE__ */ createElement(
|
||||||
|
"div",
|
||||||
|
{
|
||||||
|
class: "message-bubble",
|
||||||
|
"toggle:sentbyuser": chatMessageViewModel.sentByUser
|
||||||
|
},
|
||||||
|
/* @__PURE__ */ createElement("div", null, /* @__PURE__ */ createElement("span", { class: "sender-name" }, chatMessageViewModel.sender), /* @__PURE__ */ createElement(
|
||||||
|
"span",
|
||||||
|
{
|
||||||
|
class: "body",
|
||||||
|
"subscribe:innerText": chatMessageViewModel.body
|
||||||
|
}
|
||||||
|
), /* @__PURE__ */ createElement("span", { class: "timestamp" }, chatMessageViewModel.dateSent))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
var ChatMessageViewModelToView = (chatMessageViewModel) => {
|
var ChatMessageViewModelToView = (chatMessageViewModel) => {
|
||||||
console.log(chatMessageViewModel);
|
console.log(chatMessageViewModel);
|
||||||
@@ -1018,7 +1037,7 @@
|
|||||||
}
|
}
|
||||||
chatViewModel.chatMessageViewModels.subscribeSilent(scrollDownIfApplicable);
|
chatViewModel.chatMessageViewModels.subscribeSilent(scrollDownIfApplicable);
|
||||||
setTimeout(() => scrollDown(), 100);
|
setTimeout(() => scrollDown(), 100);
|
||||||
return /* @__PURE__ */ createElement("div", { id: "message-page" }, /* @__PURE__ */ createElement("div", { class: "toolbar" }, /* @__PURE__ */ createElement("span", { "subscribe:innerText": chatViewModel.primaryChannel })), /* @__PURE__ */ createElement("div", { class: "content" }, messageContainer, /* @__PURE__ */ createElement("div", { id: "composer" }, /* @__PURE__ */ createElement(
|
return /* @__PURE__ */ createElement("div", { id: "message-page" }, /* @__PURE__ */ createElement("div", { class: "toolbar" }, /* @__PURE__ */ createElement("span", { "subscribe:innerText": chatViewModel.primaryChannel })), /* @__PURE__ */ createElement("div", { class: "content" }, messageContainer, /* @__PURE__ */ createElement("div", { id: "composer" }, /* @__PURE__ */ createElement("div", { class: "content-width-constraint" }, /* @__PURE__ */ createElement("div", { class: "input-width-constraint" }, /* @__PURE__ */ createElement(
|
||||||
"input",
|
"input",
|
||||||
{
|
{
|
||||||
"bind:value": chatViewModel.composingMessage,
|
"bind:value": chatViewModel.composingMessage,
|
||||||
@@ -1034,7 +1053,7 @@
|
|||||||
"toggle:disabled": chatViewModel.cannotSendMessage
|
"toggle:disabled": chatViewModel.cannotSendMessage
|
||||||
},
|
},
|
||||||
/* @__PURE__ */ createElement("span", { class: "icon" }, "send")
|
/* @__PURE__ */ createElement("span", { class: "icon" }, "send")
|
||||||
))));
|
))))));
|
||||||
}
|
}
|
||||||
|
|
||||||
// src/View/Components/deletableListItem.tsx
|
// src/View/Components/deletableListItem.tsx
|
||||||
|
|||||||
@@ -12,13 +12,19 @@ export default class ChatMessageViewModel {
|
|||||||
sender: string;
|
sender: string;
|
||||||
dateSent: string;
|
dateSent: string;
|
||||||
body: React.State<string> = new React.State("");
|
body: React.State<string> = new React.State("");
|
||||||
|
sentByUser: boolean;
|
||||||
|
|
||||||
constructor(chatModel: ChatModel, chatMessage: ChatMessage) {
|
constructor(
|
||||||
|
chatModel: ChatModel,
|
||||||
|
chatMessage: ChatMessage,
|
||||||
|
sentByUser: boolean
|
||||||
|
) {
|
||||||
this.chatModel = chatModel;
|
this.chatModel = chatModel;
|
||||||
|
|
||||||
this.channel = chatMessage.channel;
|
this.channel = chatMessage.channel;
|
||||||
this.sender = chatMessage.sender;
|
this.sender = chatMessage.sender;
|
||||||
this.dateSent = new Date(chatMessage.dateSent).toLocaleString();
|
this.dateSent = new Date(chatMessage.dateSent).toLocaleString();
|
||||||
this.body.value = chatMessage.body;
|
this.body.value = chatMessage.body;
|
||||||
|
this.sentByUser = sentByUser;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,8 @@
|
|||||||
|
|
||||||
/* composer */
|
/* composer */
|
||||||
#message-page #composer {
|
#message-page #composer {
|
||||||
border-top: 1px solid var(--border);
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
#message-page #composer input {
|
#message-page #composer input {
|
||||||
@@ -28,12 +27,88 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media (max-width: 700px) {
|
||||||
|
#message-page #composer {
|
||||||
|
border-top: 1px solid var(--border);
|
||||||
|
}
|
||||||
|
|
||||||
|
#message-page #composer div {
|
||||||
|
width: 100%;
|
||||||
|
max-width: unset;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 700px) {
|
||||||
|
#message-page #composer .content-width-constraint,
|
||||||
|
#message-page #composer .input-width-constraint {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--max-content-width);
|
||||||
|
}
|
||||||
|
|
||||||
|
#message-page #composer .content-width-constraint {
|
||||||
|
max-width: var(--max-content-width);
|
||||||
|
}
|
||||||
|
|
||||||
|
#message-page #composer .input-width-constraint {
|
||||||
|
max-width: var(--max-input-width);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* message */
|
||||||
#message-page #message-container {
|
#message-page #message-container {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
padding: var(--content-padding);
|
padding: var(--content-padding);
|
||||||
gap: var(--gap-between-tiles);
|
gap: var(--gap-between-tiles);
|
||||||
|
|
||||||
|
height: auto;
|
||||||
|
max-height: unset;
|
||||||
|
|
||||||
scroll-behavior: smooth;
|
scroll-behavior: smooth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.message-bubble {
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--max-content-width);
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-bubble > div {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
|
||||||
|
background-color: var(--surface);
|
||||||
|
padding: var(--control-padding);
|
||||||
|
|
||||||
|
width: 100%;
|
||||||
|
max-width: var(--max-input-width);
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-bubble .timestamp,
|
||||||
|
.message-bubble .sender-name {
|
||||||
|
font-size: 0.8rem;
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-bubble .sender-name {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-bubble[sentbyuser] {
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-bubble[sentbyuser] {
|
||||||
|
align-items: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-bubble[sentbyuser] span {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function MessagePage(chatViewModel: ChatViewModel) {
|
|||||||
scrollDown();
|
scrollDown();
|
||||||
}
|
}
|
||||||
chatViewModel.chatMessageViewModels.subscribeSilent(scrollDownIfApplicable);
|
chatViewModel.chatMessageViewModels.subscribeSilent(scrollDownIfApplicable);
|
||||||
setTimeout(() => scrollDown(), 100)
|
setTimeout(() => scrollDown(), 100);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div id="message-page">
|
<div id="message-page">
|
||||||
@@ -40,10 +40,14 @@ export function MessagePage(chatViewModel: ChatViewModel) {
|
|||||||
<div class="content">
|
<div class="content">
|
||||||
{messageContainer}
|
{messageContainer}
|
||||||
<div id="composer">
|
<div id="composer">
|
||||||
|
<div class="content-width-constraint">
|
||||||
|
<div class="input-width-constraint">
|
||||||
<input
|
<input
|
||||||
bind:value={chatViewModel.composingMessage}
|
bind:value={chatViewModel.composingMessage}
|
||||||
on:enter={chatViewModel.sendMessage}
|
on:enter={chatViewModel.sendMessage}
|
||||||
placeholder={translations.chatPage.message.composerInputPlaceholder}
|
placeholder={
|
||||||
|
translations.chatPage.message.composerInputPlaceholder
|
||||||
|
}
|
||||||
></input>
|
></input>
|
||||||
<button
|
<button
|
||||||
class="primary"
|
class="primary"
|
||||||
@@ -58,5 +62,7 @@ export function MessagePage(chatViewModel: ChatViewModel) {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,11 +4,17 @@ import ChatMessageViewModel from "../../Model/chatMessageViewModel";
|
|||||||
|
|
||||||
export function ChatMessage(chatMessageViewModel: ChatMessageViewModel) {
|
export function ChatMessage(chatMessageViewModel: ChatMessageViewModel) {
|
||||||
return (
|
return (
|
||||||
<div class="tile flex-no">
|
<div
|
||||||
|
class="message-bubble"
|
||||||
|
toggle:sentbyuser={chatMessageViewModel.sentByUser}
|
||||||
|
>
|
||||||
<div>
|
<div>
|
||||||
<span>{chatMessageViewModel.sender}</span>
|
<span class="sender-name">{chatMessageViewModel.sender}</span>
|
||||||
<b subscribe:innerText={chatMessageViewModel.body}></b>
|
<span
|
||||||
<span>{chatMessageViewModel.dateSent}</span>
|
class="body"
|
||||||
|
subscribe:innerText={chatMessageViewModel.body}
|
||||||
|
></span>
|
||||||
|
<span class="timestamp">{chatMessageViewModel.dateSent}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import StorageModel, { storageKeys } from "../Model/storageModel";
|
|||||||
import ChatListViewModel from "./chatListViewModel";
|
import ChatListViewModel from "./chatListViewModel";
|
||||||
import ChatMessageViewModel from "../Model/chatMessageViewModel";
|
import ChatMessageViewModel from "../Model/chatMessageViewModel";
|
||||||
import { Color } from "./colors";
|
import { Color } from "./colors";
|
||||||
|
import SettingsModel from "../Model/settingsModel";
|
||||||
import SettingsViewModel from "./settingsViewModel";
|
import SettingsViewModel from "./settingsViewModel";
|
||||||
import { localeCompare } from "../Model/Utility/utility";
|
import { localeCompare } from "../Model/Utility/utility";
|
||||||
|
|
||||||
@@ -37,7 +38,8 @@ export default class ChatViewModel {
|
|||||||
ChatPageType.Messages
|
ChatPageType.Messages
|
||||||
);
|
);
|
||||||
|
|
||||||
chatMessageViewModels: React.ListState<ChatMessageViewModel> = new React.ListState();
|
chatMessageViewModels: React.ListState<ChatMessageViewModel> =
|
||||||
|
new React.ListState();
|
||||||
composingMessage: React.State<string> = new React.State("");
|
composingMessage: React.State<string> = new React.State("");
|
||||||
|
|
||||||
// guards
|
// guards
|
||||||
@@ -70,7 +72,11 @@ export default class ChatViewModel {
|
|||||||
|
|
||||||
// add
|
// add
|
||||||
addChatMessage = (chatMessage: ChatMessage): void => {
|
addChatMessage = (chatMessage: ChatMessage): void => {
|
||||||
const chatMessageModel = new ChatMessageViewModel(this.chatModel, chatMessage);
|
const chatMessageModel = new ChatMessageViewModel(
|
||||||
|
this.chatModel,
|
||||||
|
chatMessage,
|
||||||
|
chatMessage.sender == this.settingsViewModel.username.value
|
||||||
|
);
|
||||||
this.chatMessageViewModels.add(chatMessageModel);
|
this.chatMessageViewModels.add(chatMessageModel);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user