2020-08-03 11:10:58 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
2020-08-04 03:35:27 +03:00
|
|
|
import * as OldSVG from "~/components/system/svg";
|
2020-08-03 11:10:58 +03:00
|
|
|
|
|
|
|
import { css } from "@emotion/react";
|
2020-08-04 03:35:27 +03:00
|
|
|
import { Tooltip } from "react-tippy";
|
2020-08-03 11:10:58 +03:00
|
|
|
|
|
|
|
import Dismissible from "~/components/core/Dismissible";
|
|
|
|
|
2020-08-04 03:35:27 +03:00
|
|
|
const STYLES_ANCHOR = css`
|
|
|
|
position: relative;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_BUTTON = css`
|
2020-08-08 03:10:28 +03:00
|
|
|
background-color: ${Constants.system.white};
|
|
|
|
color: ${Constants.system.pitchBlack};
|
2020-08-03 11:10:58 +03:00
|
|
|
display: inline-flex;
|
2020-08-04 03:35:27 +03:00
|
|
|
width: 36px;
|
|
|
|
height: 36px;
|
|
|
|
border-radius: 36px;
|
2020-08-03 11:10:58 +03:00
|
|
|
background-size: cover;
|
|
|
|
background-position: 50% 50%;
|
|
|
|
transition: 100ms ease all;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2020-08-08 03:10:28 +03:00
|
|
|
cursor: pointer;
|
2020-08-03 11:10:58 +03:00
|
|
|
|
|
|
|
:hover {
|
2020-08-08 03:10:28 +03:00
|
|
|
color: ${Constants.system.white};
|
2020-08-03 11:10:58 +03:00
|
|
|
background-color: ${Constants.system.brand};
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
export default class ApplicationControlMenu extends React.Component {
|
|
|
|
state = {};
|
|
|
|
|
|
|
|
_handleClick = (e) => {
|
|
|
|
if (this.props.popover) {
|
|
|
|
this.setState({ visible: !this.state.visible });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.props.onClick) {
|
|
|
|
this.props.onClick(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
_handleHide = () => {
|
|
|
|
this.setState({ visible: false });
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2020-08-04 03:35:27 +03:00
|
|
|
const title = this.state.visible ? "Close menu" : "Open settings menu";
|
|
|
|
|
2020-08-03 11:10:58 +03:00
|
|
|
return (
|
|
|
|
<Dismissible
|
2020-08-04 03:35:27 +03:00
|
|
|
css={STYLES_ANCHOR}
|
2020-08-03 11:10:58 +03:00
|
|
|
captureResize={false}
|
|
|
|
captureScroll={true}
|
|
|
|
enabled={this.state.visible}
|
|
|
|
onOutsideRectEvent={this._handleHide}
|
2020-08-08 23:44:27 +03:00
|
|
|
style={this.props.style}>
|
|
|
|
<span
|
|
|
|
onClick={this._handleClick}
|
|
|
|
css={STYLES_BUTTON}
|
|
|
|
style={{
|
|
|
|
backgroundColor: this.state.visible ? Constants.system.brand : null,
|
|
|
|
color: this.state.visible ? Constants.system.white : null,
|
|
|
|
}}>
|
|
|
|
<OldSVG.ChevronDown height="20px" />
|
|
|
|
</span>
|
2020-08-04 03:35:27 +03:00
|
|
|
|
2020-08-03 11:10:58 +03:00
|
|
|
{this.state.visible ? this.props.popover : null}
|
|
|
|
</Dismissible>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|