slate/components/core/ApplicationControlMenu.js

108 lines
2.9 KiB
JavaScript
Raw Normal View History

import * as React from "react";
import * as Constants from "~/common/constants";
import * as OldSVG from "~/components/system/svg";
import { TooltipWrapper, dispatchCustomEvent, PopoverNavigation } from "~/components/system";
import { css } from "@emotion/react";
import Dismissible from "~/components/core/Dismissible";
import CircleButtonLight from "~/components/core/CircleButtonLight";
const STYLES_ANCHOR = css`
position: relative;
`;
2020-08-14 11:29:29 +03:00
const APPLICATION_CONTROL_MENU_ID = "application-control-menu";
export default class ApplicationControlMenu extends React.Component {
2020-08-14 11:29:29 +03:00
state = { visible: false };
_handleClick = (e) => {
2020-08-14 11:29:29 +03:00
this.setState({ visible: !this.state.visible });
2020-08-14 11:29:29 +03:00
dispatchCustomEvent({
name: "show-tooltip",
detail: {
id: APPLICATION_CONTROL_MENU_ID,
},
});
};
_handleHide = () => {
this.setState({ visible: false });
2020-08-14 11:29:29 +03:00
return dispatchCustomEvent({
name: "hide-tooltip",
detail: {
id: APPLICATION_CONTROL_MENU_ID,
},
});
};
2020-08-14 11:29:29 +03:00
_handleNavigateTo = (data) => {
this._handleHide();
return this.props.onNavigateTo(data);
};
_handleAction = (data) => {
this._handleHide();
return this.props.onAction(data);
};
2020-08-14 11:29:29 +03:00
_handleSignOut = (data) => {
this._handleHide();
return this.props.onSignOut(data);
};
render() {
return (
2020-08-14 11:29:29 +03:00
<TooltipWrapper
id={APPLICATION_CONTROL_MENU_ID}
type="navigation"
horizontal="right"
vertical="below"
content={
<Dismissible
css={STYLES_ANCHOR}
captureResize={true}
captureScroll={false}
enabled
onOutsideRectEvent={this._handleHide}
style={this.props.style}>
2020-08-14 11:29:29 +03:00
<PopoverNavigation
style={{
left: 0,
top: "24px",
cursor: "pointer",
}}
onNavigateTo={this._handleNavigateTo}
onAction={this._handleAction}
onSignOut={this._handleSignOut}
navigation={[
{
text: "Profile & account settings",
value: "V1_NAVIGATION_PROFILE",
},
/*
{
text: "Filecoin settings",
value: "V1_NAVIGATION_FILECOIN_SETTINGS",
},
*/
{ text: "Sign out", value: null, action: "SIGN_OUT" },
2020-08-14 11:29:29 +03:00
]}
/>
</Dismissible>
}>
<CircleButtonLight
onClick={this._handleClick}
style={{
2020-08-25 05:31:42 +03:00
backgroundColor: this.state.visible ? Constants.system.brand : Constants.system.white,
color: this.state.visible ? Constants.system.white : null,
}}>
<OldSVG.ChevronDown height="20px" />
</CircleButtonLight>
2020-08-25 05:31:42 +03:00
</TooltipWrapper>
);
}
}