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

33 lines
858 B
TypeScript
Raw Normal View History

2024-07-20 16:28:00 +02:00
import * as React from "bloatless-react";
2024-07-23 15:41:03 +02:00
import ChatViewModel, {
2026-04-01 08:29:39 +00:00
ChatPageType,
2024-07-23 15:41:03 +02:00
} from "../../ViewModel/Chat/chatViewModel";
import { RibbonButton } from "./ribbonButton";
2024-07-20 16:28:00 +02:00
export function ChatViewToggleButton(
2026-04-01 08:29:39 +00:00
label: string,
icon: string,
page: ChatPageType,
chatViewModel: ChatViewModel,
2024-07-20 16:28:00 +02:00
) {
2026-04-01 08:29:39 +00:00
function select() {
chatViewModel.selectedPage.value = page;
}
2024-07-20 16:28:00 +02:00
2026-04-01 08:29:39 +00:00
const isSelected = React.createProxyState(
[chatViewModel.selectedPage],
() => chatViewModel.selectedPage.value == page,
);
2024-07-20 16:28:00 +02:00
const isHighlighted = new React.State(false);
if (page == ChatPageType.Messages) {
chatViewModel.hasUnreadMessages.subscribe(
(hasUnreadMessages) => (isHighlighted.value = hasUnreadMessages),
);
}
return RibbonButton(label, icon, isSelected, select, isHighlighted);
2024-07-20 16:28:00 +02:00
}