Add user picture to desktop sidebar; change text input to textarea to allow resizing.
This commit is contained in:
parent
5943621dbf
commit
c5218f3c1a
5 changed files with 67 additions and 12 deletions
|
|
@ -20,6 +20,7 @@
|
||||||
<button id="profile-sidebar-btn" class="icon-btn mif-person mif-2x" data-page="profile-page"></button>
|
<button id="profile-sidebar-btn" class="icon-btn mif-person mif-2x" data-page="profile-page"></button>
|
||||||
<button id="chats-sidebar-btn" class="icon-btn mif-qa mif-2x" data-page="chat-page"></button>
|
<button id="chats-sidebar-btn" class="icon-btn mif-qa mif-2x" data-page="chat-page"></button>
|
||||||
<button id="settings-sidebar-btn" class="icon-btn mif-cog mif-2x" data-page="settings-page"></button>
|
<button id="settings-sidebar-btn" class="icon-btn mif-cog mif-2x" data-page="settings-page"></button>
|
||||||
|
<img data-resource="app-user-image">
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<!-- Sidebar -->
|
<!-- Sidebar -->
|
||||||
|
|
@ -94,11 +95,11 @@
|
||||||
<!-- Input Panel -->
|
<!-- Input Panel -->
|
||||||
<footer id="chat-input-panel" class="chat-input-panel">
|
<footer id="chat-input-panel" class="chat-input-panel">
|
||||||
<div class="input-actions-left">
|
<div class="input-actions-left">
|
||||||
<button id="chat-bottom-bar-btn" class="icon-btn mif-expand-less mif-3x" title="Expand"></button>
|
<button id="chat-bottom-bar-btn" class="chat-footer-btn icon-btn mif-expand-less mif-3x" title="Expand"></button>
|
||||||
</div>
|
</div>
|
||||||
<form class="input-form" id="message-form">
|
<form class="input-form" id="message-form">
|
||||||
<input type="text" id="message-input" placeholder="Type a message..." autocomplete="off">
|
<textarea type="text" id="message-input" rows="1" placeholder="Type a message..." autocomplete="off"></textarea>
|
||||||
<button type="submit" class="send-btn mif-paper-plane mif-3x" id="send-button">
|
<button type="submit" class="chat-footer-btn send-btn mif-paper-plane mif-3x" id="send-button">
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,8 @@ function setupEventListeners() {
|
||||||
ui.renderChatList(filtered, activeChatState, selectChat);
|
ui.renderChatList(filtered, activeChatState, selectChat);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ui.autoResizeTextArea(elements.messageInput);
|
||||||
|
|
||||||
elements.messageForm.addEventListener('submit', (e) => {
|
elements.messageForm.addEventListener('submit', (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
sendMessage();
|
sendMessage();
|
||||||
|
|
@ -313,9 +315,9 @@ async function handleIncomingMessage(msg: Message) {
|
||||||
|
|
||||||
if (!msg.fromMe) {
|
if (!msg.fromMe) {
|
||||||
messageTone.play();
|
messageTone.play();
|
||||||
}
|
if (notificationAuthorization === "granted") {
|
||||||
if (notificationAuthorization === "granted") {
|
new Notification("New message", { body: msg.body || msg.text });
|
||||||
new Notification("New message", { body: msg.body || msg.text });
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (activeChatState && activeChatState.id === msgChatId) {
|
if (activeChatState && activeChatState.id === msgChatId) {
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ export class Parser {
|
||||||
|
|
||||||
const regex = new RegExp(`(^|\\s)${esc}(.+?)${esc}(?=\\s|$)`, "gs");
|
const regex = new RegExp(`(^|\\s)${esc}(.+?)${esc}(?=\\s|$)`, "gs");
|
||||||
|
|
||||||
this.input = this.input.replace(regex, (match, pre, inner) => {
|
this.input = this.input.replace(regex, (_match, pre, inner) => {
|
||||||
return `${pre}${to.replace("$1", inner)}`;
|
return `${pre}${to.replace("$1", inner)}`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export const elements = {
|
||||||
activeChatAvatar: document.getElementById('active-chat-avatar') as HTMLDivElement,
|
activeChatAvatar: document.getElementById('active-chat-avatar') as HTMLDivElement,
|
||||||
messagesContainer: document.getElementById('messages-container') as HTMLDivElement,
|
messagesContainer: document.getElementById('messages-container') as HTMLDivElement,
|
||||||
messageForm: document.getElementById('message-form') as HTMLFormElement,
|
messageForm: document.getElementById('message-form') as HTMLFormElement,
|
||||||
messageInput: document.getElementById('message-input') as HTMLInputElement,
|
messageInput: document.getElementById('message-input') as HTMLTextAreaElement,
|
||||||
backToSidebarBtn: document.querySelector('.chat-header') as HTMLElement,
|
backToSidebarBtn: document.querySelector('.chat-header') as HTMLElement,
|
||||||
sidebar: document.querySelector('.sidebar') as HTMLElement,
|
sidebar: document.querySelector('.sidebar') as HTMLElement,
|
||||||
appContainer: document.querySelector('.app-container') as HTMLElement,
|
appContainer: document.querySelector('.app-container') as HTMLElement,
|
||||||
|
|
@ -465,6 +465,27 @@ export const ui = {
|
||||||
const message = document.getElementById(msgId);
|
const message = document.getElementById(msgId);
|
||||||
if (message) message.remove();
|
if (message) message.remove();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
autoResizeTextArea(element: HTMLTextAreaElement) {
|
||||||
|
const resize = () => {
|
||||||
|
element.style.height = 'auto';
|
||||||
|
const offset = element.offsetHeight - element.clientHeight;
|
||||||
|
const newHeight = element.scrollHeight + offset;
|
||||||
|
|
||||||
|
if (element.scrollHeight > 0) {
|
||||||
|
element.style.height = `${newHeight}px`;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
element.addEventListener('input', resize);
|
||||||
|
|
||||||
|
const observer = new IntersectionObserver((entries) => {
|
||||||
|
if (entries[0].isIntersecting) {
|
||||||
|
resize();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
observer.observe(element);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export class ScrollableView {
|
export class ScrollableView {
|
||||||
|
|
|
||||||
|
|
@ -470,7 +470,19 @@ li {
|
||||||
border-right: 1px solid var(--border-color);
|
border-right: 1px solid var(--border-color);
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
padding: .2em;
|
padding: .6em .2em;
|
||||||
|
width: 60px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#desktop-aside * {
|
||||||
|
width: 38px;
|
||||||
|
height: 38px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#desktop-aside img {
|
||||||
|
margin: .2rem;
|
||||||
|
margin-top: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sidebar Footer */
|
/* Sidebar Footer */
|
||||||
|
|
@ -764,7 +776,7 @@ li {
|
||||||
.chat-input-panel {
|
.chat-input-panel {
|
||||||
padding: .8rem;
|
padding: .8rem;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: flex-end;
|
||||||
gap: 16px;
|
gap: 16px;
|
||||||
background-color: var(--bg-main);
|
background-color: var(--bg-main);
|
||||||
}
|
}
|
||||||
|
|
@ -814,19 +826,24 @@ li {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
align-items: center;
|
align-items: flex-end;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#message-input {
|
#message-input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
overflow-y: scroll;
|
||||||
padding: 12px 18px;
|
padding: 12px 18px;
|
||||||
background-color: var(--text-primary);
|
background-color: var(--text-primary);
|
||||||
border: medium solid var(--border-color);
|
border: medium solid var(--border-color);
|
||||||
color: var(--bg-main);
|
color: var(--bg-main);
|
||||||
font-size: 0.95rem;
|
font-size: 0.95rem;
|
||||||
transition: all 0.2s ease;
|
transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
resize: none;
|
||||||
|
line-height: 1.3;
|
||||||
|
max-height: 6rem;
|
||||||
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
#message-input:focus {
|
#message-input:focus {
|
||||||
|
|
@ -836,6 +853,15 @@ li {
|
||||||
background: rgba(255, 255, 255, 0.06);
|
background: rgba(255, 255, 255, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#chat-bottom-bar-btn {
|
||||||
|
margin-bottom: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#send-button {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
margin-right: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
.send-btn {
|
.send-btn {
|
||||||
width: 44px;
|
width: 44px;
|
||||||
height: 44px;
|
height: 44px;
|
||||||
|
|
@ -1010,6 +1036,11 @@ li {
|
||||||
scroll-snap-stop: always;
|
scroll-snap-stop: always;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#message-input {
|
||||||
|
padding: 8px 12px;
|
||||||
|
max-height: 10rem;
|
||||||
|
}
|
||||||
|
|
||||||
.extra-page {
|
.extra-page {
|
||||||
display: flex;
|
display: flex;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue