2020-09-02 04:09:39 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
2020-09-05 02:15:29 +03:00
|
|
|
import * as SVG from "~/common/svg";
|
2020-11-22 00:25:40 +03:00
|
|
|
import * as UserBehaviors from "~/common/user-behaviors";
|
2020-09-02 04:09:39 +03:00
|
|
|
|
2020-11-08 05:32:17 +03:00
|
|
|
import { PopoverNavigation } from "~/components/system";
|
2020-11-04 20:55:48 +03:00
|
|
|
import { css } from "@emotion/core";
|
2020-09-02 04:09:39 +03:00
|
|
|
|
2020-09-05 00:37:50 +03:00
|
|
|
import { Boundary } from "~/components/system/components/fragments/Boundary";
|
2020-09-02 04:09:39 +03:00
|
|
|
|
|
|
|
const STYLES_HEADER = css`
|
|
|
|
position: relative;
|
2020-11-14 02:43:59 +03:00
|
|
|
margin-left: 16px;
|
2020-09-02 04:09:39 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
2020-09-29 07:39:05 +03:00
|
|
|
padding: 0px;
|
2020-09-29 08:47:27 +03:00
|
|
|
width: auto;
|
2020-09-02 04:09:39 +03:00
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_PROFILE = css`
|
2020-09-29 07:39:05 +03:00
|
|
|
position: relative;
|
2020-09-02 04:09:39 +03:00
|
|
|
display: flex;
|
2020-09-05 04:40:23 +03:00
|
|
|
align-items: center;
|
2020-09-02 04:09:39 +03:00
|
|
|
justify-content: flex-start;
|
|
|
|
min-width: 10%;
|
2020-09-05 22:27:41 +03:00
|
|
|
width: 204px;
|
2020-09-02 04:09:39 +03:00
|
|
|
|
|
|
|
color: ${Constants.system.pitchBlack};
|
|
|
|
background-color: ${Constants.system.white};
|
|
|
|
font-size: 12px;
|
|
|
|
text-decoration: none;
|
2020-09-05 04:40:23 +03:00
|
|
|
border-radius: 4px;
|
|
|
|
min-height: 48px;
|
2020-09-02 04:09:39 +03:00
|
|
|
cursor: pointer;
|
2020-09-27 00:15:37 +03:00
|
|
|
border: 1px solid rgba(229, 229, 229, 0.5);
|
2020-09-05 04:40:23 +03:00
|
|
|
box-shadow: 0 0 7px 0 rgba(0, 0, 0, 0.03);
|
2020-09-02 04:09:39 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-09-05 22:27:41 +03:00
|
|
|
const STYLES_PROFILE_MOBILE = css`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
`;
|
|
|
|
|
2020-09-02 04:09:39 +03:00
|
|
|
const STYLES_PROFILE_IMAGE = css`
|
2020-09-14 08:22:19 +03:00
|
|
|
background-color: ${Constants.system.foreground};
|
2020-09-02 04:09:39 +03:00
|
|
|
background-size: cover;
|
|
|
|
background-position: 50% 50%;
|
|
|
|
flex-shrink: 0;
|
|
|
|
height: 32px;
|
|
|
|
width: 32px;
|
2020-11-14 02:43:59 +03:00
|
|
|
border-radius: 2px;
|
2020-09-05 22:27:41 +03:00
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
height: 24px;
|
|
|
|
width: 24px;
|
|
|
|
}
|
2020-09-02 04:09:39 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_PROFILE_USERNAME = css`
|
|
|
|
min-width: 10%;
|
|
|
|
width: 100%;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
2020-09-06 05:27:30 +03:00
|
|
|
text-overflow: ellipsis;
|
|
|
|
padding: 12px;
|
2020-09-02 04:09:39 +03:00
|
|
|
user-select: none;
|
2020-09-05 04:40:23 +03:00
|
|
|
font-family: ${Constants.font.medium};
|
2020-09-10 06:28:48 +03:00
|
|
|
font-size: ${Constants.typescale.lvl1};
|
2020-09-05 04:40:23 +03:00
|
|
|
`;
|
|
|
|
|
2020-09-05 22:27:41 +03:00
|
|
|
const STYLES_ITEM_BOX_MOBILE = css`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
padding: 4px;
|
|
|
|
background-color: ${Constants.system.white};
|
|
|
|
cursor: pointer;
|
|
|
|
border-radius: 4px;
|
2020-10-17 04:58:11 +03:00
|
|
|
border-left: 2px solid ${Constants.system.foreground};
|
2020-09-05 22:27:41 +03:00
|
|
|
`;
|
|
|
|
|
2020-09-05 04:40:23 +03:00
|
|
|
const STYLES_ITEM_BOX = css`
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
height: 100%;
|
|
|
|
padding: 8px;
|
2020-10-17 23:21:35 +03:00
|
|
|
padding-right: 9px;
|
2020-09-05 04:40:23 +03:00
|
|
|
transition: 200ms ease all;
|
2020-10-17 04:58:11 +03:00
|
|
|
border-left: 2px solid ${Constants.system.foreground};
|
|
|
|
|
2020-09-05 04:40:23 +03:00
|
|
|
:hover {
|
|
|
|
color: ${Constants.system.brand};
|
|
|
|
}
|
2020-09-02 04:09:39 +03:00
|
|
|
`;
|
|
|
|
|
2020-09-29 07:39:05 +03:00
|
|
|
const STYLES_MENU = css`
|
|
|
|
position: absolute;
|
|
|
|
top: 48px;
|
2020-11-14 02:43:59 +03:00
|
|
|
right: 0px;
|
|
|
|
|
|
|
|
${"" /* @media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
top: 48px;
|
|
|
|
left: 0px;
|
|
|
|
} */}
|
2020-09-29 07:39:05 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_MOBILE_HIDDEN = css`
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_MOBILE_ONLY = css`
|
|
|
|
@media (min-width: ${Constants.sizes.mobile}px) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
2020-09-02 04:09:39 +03:00
|
|
|
export default class ApplicationUserControls extends React.Component {
|
2020-10-02 02:44:22 +03:00
|
|
|
_handleAction = (e, data) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2020-11-19 06:00:59 +03:00
|
|
|
this.props.onTogglePopup();
|
2020-09-02 04:09:39 +03:00
|
|
|
return this.props.onAction(data);
|
|
|
|
};
|
|
|
|
|
2020-11-22 00:25:40 +03:00
|
|
|
_handleSignOut = (e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2020-11-19 06:00:59 +03:00
|
|
|
this.props.onTogglePopup();
|
2020-11-22 00:25:40 +03:00
|
|
|
UserBehaviors.signOut();
|
2020-09-02 04:09:39 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2020-09-29 07:39:05 +03:00
|
|
|
let tooltip = (
|
2020-11-14 02:43:59 +03:00
|
|
|
<Boundary
|
|
|
|
captureResize={true}
|
|
|
|
captureScroll={false}
|
|
|
|
enabled
|
2020-11-19 06:00:59 +03:00
|
|
|
onOutsideRectEvent={() => this.props.onTogglePopup()}
|
2020-11-14 02:43:59 +03:00
|
|
|
style={this.props.style}
|
|
|
|
>
|
|
|
|
<div>
|
|
|
|
<PopoverNavigation
|
|
|
|
style={{ top: 36, right: 0, padding: "0px 24px", width: 220 }}
|
|
|
|
itemStyle={{ margin: "24px 0", fontSize: 18, justifyContent: "flex-end" }}
|
|
|
|
navigation={[
|
|
|
|
{
|
|
|
|
text: "View profile",
|
|
|
|
onClick: (e) =>
|
|
|
|
this._handleAction(e, {
|
|
|
|
type: "NAVIGATE",
|
|
|
|
value: "V1_NAVIGATION_PROFILE",
|
|
|
|
data: this.props.viewer,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Account settings",
|
|
|
|
onClick: (e) =>
|
|
|
|
this._handleAction(e, {
|
|
|
|
type: "NAVIGATE",
|
|
|
|
value: "V1_NAVIGATION_PROFILE_EDIT",
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Contact us",
|
|
|
|
onClick: (e) =>
|
|
|
|
this._handleAction(e, {
|
|
|
|
type: "SIDEBAR",
|
|
|
|
value: "SIDEBAR_HELP",
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
text: "Sign out",
|
|
|
|
onClick: (e) => {
|
|
|
|
this._handleSignOut(e);
|
2020-09-29 07:39:05 +03:00
|
|
|
},
|
2020-11-14 02:43:59 +03:00
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</Boundary>
|
2020-09-29 07:39:05 +03:00
|
|
|
);
|
2020-09-02 04:09:39 +03:00
|
|
|
return (
|
|
|
|
<div css={STYLES_HEADER}>
|
2020-11-14 02:43:59 +03:00
|
|
|
<div css={STYLES_PROFILE_MOBILE} style={{ position: "relative" }}>
|
2020-09-29 07:39:05 +03:00
|
|
|
<span
|
|
|
|
css={STYLES_PROFILE_IMAGE}
|
2020-11-19 06:00:59 +03:00
|
|
|
onClick={() => this.props.onTogglePopup("profile")}
|
2020-09-29 07:39:05 +03:00
|
|
|
style={{
|
|
|
|
backgroundImage: `url('${this.props.viewer.data.photo}')`,
|
|
|
|
}}
|
|
|
|
/>
|
2020-11-19 06:00:59 +03:00
|
|
|
{this.props.popup === "profile" ? tooltip : null}
|
2020-09-29 07:39:05 +03:00
|
|
|
</div>
|
2020-09-02 04:09:39 +03:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|