2017-11-07 17:07:31 +03:00
|
|
|
/*
|
|
|
|
Copyright 2017 New Vector Ltd.
|
2019-06-19 13:26:11 +03:00
|
|
|
Copyright 2019 The Matrix.org Foundation C.I.C.
|
2017-11-07 17:07:31 +03: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';
|
2021-06-29 15:11:58 +03:00
|
|
|
import { replaceableComponent } from "../../../utils/replaceableComponent";
|
2021-07-03 11:44:03 +03:00
|
|
|
import Tooltip from './Tooltip';
|
2017-11-07 17:07:31 +03:00
|
|
|
|
2021-05-24 17:01:59 +03:00
|
|
|
interface IProps {
|
2021-07-03 11:59:57 +03:00
|
|
|
helpText: React.ReactNode | string;
|
2021-05-24 17:01:59 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IState {
|
|
|
|
hover: boolean;
|
|
|
|
}
|
|
|
|
|
2021-03-09 05:59:41 +03:00
|
|
|
@replaceableComponent("views.elements.TooltipButton")
|
2021-05-24 17:01:59 +03:00
|
|
|
export default class TooltipButton extends React.Component<IProps, IState> {
|
2021-05-24 18:40:55 +03:00
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
hover: false,
|
|
|
|
};
|
|
|
|
}
|
2017-11-07 17:07:31 +03:00
|
|
|
|
2021-05-24 18:40:55 +03:00
|
|
|
private onMouseOver = () => {
|
2017-11-07 17:07:31 +03:00
|
|
|
this.setState({
|
|
|
|
hover: true,
|
2017-11-07 18:13:26 +03:00
|
|
|
});
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
2017-11-07 17:07:31 +03:00
|
|
|
|
2021-05-24 18:40:55 +03:00
|
|
|
private onMouseLeave = () => {
|
2017-11-07 17:07:31 +03:00
|
|
|
this.setState({
|
|
|
|
hover: false,
|
2017-11-07 18:13:26 +03:00
|
|
|
});
|
2020-08-29 14:14:16 +03:00
|
|
|
};
|
2017-11-07 17:07:31 +03:00
|
|
|
|
2020-08-29 14:14:16 +03:00
|
|
|
render() {
|
2019-02-01 02:36:19 +03:00
|
|
|
const tip = this.state.hover ? <Tooltip
|
2019-06-19 13:26:11 +03:00
|
|
|
className="mx_TooltipButton_container"
|
|
|
|
tooltipClassName="mx_TooltipButton_helpText"
|
2017-11-07 17:07:31 +03:00
|
|
|
label={this.props.helpText}
|
|
|
|
/> : <div />;
|
|
|
|
return (
|
2020-07-18 14:01:51 +03:00
|
|
|
<div className="mx_TooltipButton" onMouseOver={this.onMouseOver} onMouseLeave={this.onMouseLeave}>
|
2017-11-07 17:07:31 +03:00
|
|
|
?
|
|
|
|
{ tip }
|
|
|
|
</div>
|
|
|
|
);
|
2020-08-29 14:14:16 +03:00
|
|
|
}
|
|
|
|
}
|