Files
CT/src/View/Components/chatEntry.tsx
T

40 lines
1.1 KiB
TypeScript
Raw Normal View History

2024-07-20 05:10:50 +02:00
import * as React from "bloatless-react";
2024-07-22 20:02:13 +02:00
import ChatViewModel from "../../ViewModel/Chat/chatViewModel";
2024-07-20 05:10:50 +02:00
2024-07-20 14:16:26 +02:00
export function ChatEntry(chatViewModel: ChatViewModel) {
2026-04-01 08:29:39 +00:00
const view = (
<button
class="tile colored-tile chat-entry"
set:color={chatViewModel.settingsPageViewModel.color}
style="height: 8rem"
on:click={chatViewModel.open}
toggle:unread={chatViewModel.hasUnreadMessages}
>
<span
class="shadow"
subscribe:innerText={
chatViewModel.settingsPageViewModel.primaryChannel
}
></span>
<h2
subscribe:innerText={
chatViewModel.settingsPageViewModel.primaryChannel
}
></h2>
</button>
);
2024-07-20 16:49:01 +02:00
2026-04-01 08:29:39 +00:00
chatViewModel.index.subscribe((newIndex) => {
view.style.order = newIndex;
});
2024-07-20 16:49:01 +02:00
2026-04-01 08:29:39 +00:00
return view;
2024-07-20 05:10:50 +02:00
}
2024-07-20 14:16:26 +02:00
export const ChatViewModelToChatEntry: React.StateItemConverter<
2026-04-01 08:29:39 +00:00
ChatViewModel
2024-07-20 14:16:26 +02:00
> = (chatViewModel: ChatViewModel) => {
2026-04-01 08:29:39 +00:00
return ChatEntry(chatViewModel);
2024-07-20 05:10:50 +02:00
};