Files
CT/src/Tabs/messageTab.tsx
T

70 lines
2.0 KiB
TypeScript
Raw Normal View History

2024-07-07 22:11:18 +02:00
import * as React from "bloatless-react";
2024-07-10 19:07:58 +02:00
import { closeChatView, isShowingChatTools, selectedChat, toggleChatTools } from "../Model/model";
2024-07-09 14:28:13 +02:00
2024-07-11 01:24:06 +02:00
import { ChatOptionModal } from "../Views/Chat/chatOptionModal";
import { ChatToolView } from "../Views/Chat/chatToolView";
import { MessageComposer } from "../Views/Chat/messageComposer";
import { ThreadView } from "../Views/Chat/threadView";
2024-07-07 22:11:18 +02:00
import { translation } from "../translations";
export function MessageTab() {
2024-07-09 14:28:13 +02:00
const messageTabContent = React.createProxyState([selectedChat], () => {
if (selectedChat.value == undefined)
return (
<div class="width-100 height-100 flex-column align-center justify-center">
<span class="secondary">{translation.noChatSelected}</span>
</div>
);
const chat = selectedChat.value;
2024-07-09 17:23:29 +02:00
const isShowingOptions = new React.State(false);
2024-07-09 14:28:13 +02:00
2024-07-09 17:23:29 +02:00
function showOptions() {
isShowingOptions.value = true;
}
2024-07-09 14:28:13 +02:00
2024-07-09 18:21:28 +02:00
return [
<header class="padding-0">
<span class="flex-row align-center">
<button aria-label={translation.back} on:click={closeChatView}>
<span class="icon">arrow_back</span>
</button>
<span subscribe:innerText={chat.primaryChannel}></span>
</span>
<span>
2024-07-10 19:07:58 +02:00
<button
aria-label={translation.toggleChatTools}
on:click={toggleChatTools}
toggle:selected={isShowingChatTools}
>
2024-07-11 02:30:38 +02:00
<span class="icon">deployed_code</span>
2024-07-10 19:07:58 +02:00
</button>
2024-07-09 18:21:28 +02:00
<button
aria-label={translation.showChatOptions}
on:click={showOptions}
>
<span class="icon">tune</span>
</button>
</span>
</header>,
2024-07-10 19:07:58 +02:00
ChatToolView(chat),
2024-07-09 18:21:28 +02:00
ThreadView(chat),
<footer>{MessageComposer(chat)}</footer>,
ChatOptionModal(chat, isShowingOptions),
];
2024-07-09 14:28:13 +02:00
});
2024-07-10 19:07:58 +02:00
return (
<article
toggle:showingchattools={isShowingChatTools}
id="message-tab"
children:set={messageTabContent}
></article>
);
2024-07-07 22:11:18 +02:00
}