v3: added a chatbox
Some checks failed
Build and Publish Docker Image / build-and-push (push) Has been cancelled
Some checks failed
Build and Publish Docker Image / build-and-push (push) Has been cancelled
This commit is contained in:
27
src/components/ChatButton.tsx
Normal file
27
src/components/ChatButton.tsx
Normal file
@@ -0,0 +1,27 @@
|
||||
import { t } from "@lingui/core/macro";
|
||||
import { useWS } from "../hooks/useWS.ts";
|
||||
import { useChat } from "../hooks/useChat.ts";
|
||||
|
||||
/** Header chat button with an unread-message badge. Opens the app-wide chat. */
|
||||
export function ChatButton() {
|
||||
const { unreadChatCount } = useWS();
|
||||
const { openChat } = useChat();
|
||||
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
className="chat-button"
|
||||
onClick={openChat}
|
||||
aria-label={unreadChatCount > 0
|
||||
? t`Chat (${unreadChatCount} unread)`
|
||||
: t`Chat`}
|
||||
>
|
||||
<span className="chat-button-icon">💬</span>
|
||||
{unreadChatCount > 0 && (
|
||||
<span className="notification-badge">
|
||||
{unreadChatCount > 99 ? "99+" : unreadChatCount}
|
||||
</span>
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user