2018-10-30 17:15:19 +01:00
|
|
|
/*
|
|
|
|
|
Copyright 2015, 2016 OpenMarket Ltd
|
|
|
|
|
Copyright 2017 Vector Creations Ltd
|
|
|
|
|
Copyright 2017 New Vector Ltd
|
|
|
|
|
Copyright 2018 New Vector Ltd
|
2019-10-03 09:35:39 +01:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2018-10-30 17:15:19 +01: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-03-08 13:28:07 +00:00
|
|
|
import React, { ReactNode } from "react";
|
2018-10-30 17:15:19 +01:00
|
|
|
import classNames from "classnames";
|
2021-10-22 17:23:32 -05:00
|
|
|
|
2020-07-17 18:16:21 +01:00
|
|
|
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
|
2022-02-28 14:11:14 +00:00
|
|
|
import { ButtonEvent } from "../elements/AccessibleButton";
|
2022-10-06 22:27:28 -04:00
|
|
|
import { Alignment } from "../elements/Tooltip";
|
2018-10-30 17:15:19 +01:00
|
|
|
|
2020-07-18 16:34:48 +05:30
|
|
|
interface IProps {
|
|
|
|
|
// Whether this button is highlighted
|
|
|
|
|
isHighlighted: boolean;
|
2022-04-04 12:36:54 +01:00
|
|
|
isUnread?: boolean;
|
2020-07-18 16:34:48 +05:30
|
|
|
// click handler
|
2022-02-28 14:11:14 +00:00
|
|
|
onClick: (ev: ButtonEvent) => void;
|
2020-07-18 16:34:48 +05:30
|
|
|
|
|
|
|
|
// Button name
|
|
|
|
|
name: string;
|
|
|
|
|
// Button title
|
|
|
|
|
title: string;
|
2023-03-08 13:28:07 +00:00
|
|
|
children?: ReactNode;
|
2020-07-18 16:41:57 +05:30
|
|
|
}
|
2020-07-18 16:34:48 +05:30
|
|
|
|
2021-05-25 13:53:46 +01:00
|
|
|
// TODO: replace this, the composer buttons and the right panel buttons with a unified representation
|
2020-07-18 16:34:48 +05:30
|
|
|
export default class HeaderButton extends React.Component<IProps> {
|
2023-02-13 17:01:43 +00:00
|
|
|
public render(): React.ReactNode {
|
2022-06-14 17:51:51 +01:00
|
|
|
const { isHighlighted, isUnread = false, onClick, name, title, ...props } = this.props;
|
2021-05-25 13:53:46 +01:00
|
|
|
|
2018-10-30 17:15:19 +01:00
|
|
|
const classes = classNames({
|
|
|
|
|
mx_RightPanel_headerButton: true,
|
2021-05-25 13:53:46 +01:00
|
|
|
mx_RightPanel_headerButton_highlight: isHighlighted,
|
2022-04-04 12:36:54 +01:00
|
|
|
mx_RightPanel_headerButton_unread: isUnread,
|
2021-05-25 13:53:46 +01:00
|
|
|
[`mx_RightPanel_${name}`]: true,
|
2018-10-30 17:15:19 +01:00
|
|
|
});
|
|
|
|
|
|
2020-07-17 18:16:21 +01:00
|
|
|
return (
|
|
|
|
|
<AccessibleTooltipButton
|
2021-05-25 13:53:46 +01:00
|
|
|
{...props}
|
|
|
|
|
aria-selected={isHighlighted}
|
2019-10-03 09:35:39 +01:00
|
|
|
role="tab"
|
2021-05-25 13:53:46 +01:00
|
|
|
title={title}
|
2022-10-06 22:27:28 -04:00
|
|
|
alignment={Alignment.Bottom}
|
2018-10-30 17:15:19 +01:00
|
|
|
className={classes}
|
2022-06-14 17:51:51 +01:00
|
|
|
onClick={onClick}
|
2020-07-17 18:16:21 +01:00
|
|
|
/>
|
|
|
|
|
);
|
2018-10-30 17:15:19 +01:00
|
|
|
}
|
|
|
|
|
}
|