2015-11-27 10:42:03 +00:00
|
|
|
/*
|
2023-08-01 08:32:53 +01: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.
|
|
|
|
|
*/
|
|
|
|
|
|
2023-08-01 08:32:53 +01:00
|
|
|
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
|
|
|
|
2023-08-04 08:36:16 +01: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";
|
2022-09-25 10:57:25 -04:00
|
|
|
|
2023-08-02 16:29:19 +01:00
|
|
|
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);
|
2022-09-25 10:57:25 -04:00
|
|
|
|
|
|
|
|
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 });
|
|
|
|
|
}}
|
|
|
|
|
>
|
2023-08-02 16:29:19 +01:00
|
|
|
<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>
|
|
|
|
|
)}
|
2023-08-01 08:32:53 +01:00
|
|
|
</div>
|
|
|
|
|
</header>
|
2022-09-25 10:57:25 -04:00
|
|
|
);
|
2020-08-29 12:14:16 +01:00
|
|
|
}
|