Files
ThreadNet-Web/src/components/views/rooms/RoomHeader.tsx
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
2.3 KiB
TypeScript
Raw Normal View History

2015-11-27 10:42:03 +00:00
/*
Copyright 2023 The Matrix.org Foundation C.I.C.
2015-11-27 10:42:03 +00:00
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
2023-08-02 14:03:04 +01:00
import { Body as BodyText } from "@vector-im/compound-web";
2021-12-09 09:10:23 +00:00
import type { Room } from "matrix-js-sdk/src/matrix";
2023-08-01 14:47:09 +01:00
import { useRoomName } from "../../../hooks/useRoomName";
2023-08-02 11:54:06 +01:00
import DecoratedRoomAvatar from "../avatars/DecoratedRoomAvatar";
import { RightPanelPhases } from "../../../stores/right-panel/RightPanelStorePhases";
import RightPanelStore from "../../../stores/right-panel/RightPanelStore";
import { useTopic } from "../../../hooks/room/useTopic";
export default function RoomHeader({ room }: { room: Room }): JSX.Element {
const roomName = useRoomName(room);
2023-08-02 11:54:06 +01:00
const roomTopic = useTopic(room);
return (
2023-08-02 11:54:06 +01:00
<header
className="mx_RoomHeader light-panel"
onClick={() => {
const rightPanel = RightPanelStore.instance;
rightPanel.isOpen
? rightPanel.togglePanel(null)
: rightPanel.setCard({ phase: RightPanelPhases.RoomSummary });
}}
>
<DecoratedRoomAvatar room={room} avatarSize={40} displayBadge={false} />
2023-08-02 11:54:06 +01:00
<div className="mx_RoomHeader_info">
2023-08-02 14:03:04 +01:00
<BodyText
as="div"
size="lg"
weight="semibold"
dir="auto"
title={roomName}
role="heading"
aria-level={1}
>
2023-08-01 14:47:09 +01:00
{roomName}
2023-08-02 14:03:04 +01:00
</BodyText>
{roomTopic && (
<BodyText as="div" size="sm" className="mx_RoomHeader_topic">
{roomTopic.text}
</BodyText>
)}
</div>
</header>
);
2020-08-29 12:14:16 +01:00
}