2020-06-19 06:57:57 +03:00
|
|
|
import * as React from "react";
|
|
|
|
import * as Constants from "~/common/constants";
|
|
|
|
import * as SVG from "~/common/svg";
|
2020-04-09 00:29:13 +03:00
|
|
|
|
2020-09-06 04:57:39 +03:00
|
|
|
import { css, keyframes } from "@emotion/react";
|
2020-08-31 21:19:46 +03:00
|
|
|
import { SearchModal } from "~/components/core/SearchModal";
|
2020-08-25 02:24:29 +03:00
|
|
|
import { dispatchCustomEvent } from "~/common/custom-events";
|
2020-04-09 00:29:13 +03:00
|
|
|
|
|
|
|
const STYLES_ICON_ELEMENT = css`
|
|
|
|
height: 40px;
|
|
|
|
width: 40px;
|
|
|
|
display: inline-flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
|
|
|
color: #565151;
|
|
|
|
user-select: none;
|
|
|
|
cursor: pointer;
|
2020-08-08 03:10:28 +03:00
|
|
|
pointer-events: auto;
|
2020-04-09 00:29:13 +03:00
|
|
|
|
|
|
|
:hover {
|
|
|
|
color: ${Constants.system.brand};
|
|
|
|
}
|
|
|
|
|
|
|
|
svg {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
transition: 200ms ease transform;
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_APPLICATION_HEADER = css`
|
|
|
|
display: flex;
|
2020-08-08 03:10:28 +03:00
|
|
|
align-items: flex-start;
|
2020-04-09 00:29:13 +03:00
|
|
|
justify-content: space-between;
|
|
|
|
width: 100%;
|
2020-08-09 11:08:46 +03:00
|
|
|
height: 104px;
|
2020-08-08 03:10:28 +03:00
|
|
|
padding: 12px 48px 0 36px;
|
|
|
|
pointer-events: none;
|
2020-08-20 08:45:43 +03:00
|
|
|
background: linear-gradient(
|
|
|
|
to bottom,
|
|
|
|
rgba(255, 255, 255, 1) 30%,
|
|
|
|
rgba(255, 255, 255, 0) 100%
|
|
|
|
);
|
2020-08-09 01:04:17 +03:00
|
|
|
|
|
|
|
@media (max-width: ${Constants.sizes.mobile}px) {
|
|
|
|
padding: 12px 24px 0 12px;
|
|
|
|
}
|
2020-04-09 00:29:13 +03:00
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_LEFT = css`
|
|
|
|
flex-shrink: 0;
|
2020-07-22 21:54:58 +03:00
|
|
|
width: 352px;
|
2020-04-09 00:29:13 +03:00
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: flex-start;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_MIDDLE = css`
|
|
|
|
min-width: 10%;
|
|
|
|
width: 100%;
|
|
|
|
padding: 0 24px 0 48px;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_RIGHT = css`
|
|
|
|
flex-shrink: 0;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: flex-end;
|
|
|
|
padding-right: 16px;
|
|
|
|
`;
|
|
|
|
|
2020-09-06 04:57:39 +03:00
|
|
|
const rotate = keyframes`
|
|
|
|
0% {
|
|
|
|
transform: rotate(0deg);
|
|
|
|
}
|
|
|
|
100% {
|
|
|
|
transform: rotate(360deg);
|
|
|
|
}
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_ROTATION = css`
|
|
|
|
animation: ${rotate} 1s linear infinite;
|
|
|
|
`;
|
|
|
|
|
|
|
|
const STYLES_STATIC = css`
|
|
|
|
transition: 200ms ease all;
|
|
|
|
`;
|
|
|
|
|
2020-04-09 00:29:13 +03:00
|
|
|
export default class ApplicationHeader extends React.Component {
|
2020-09-06 04:57:39 +03:00
|
|
|
state = {
|
|
|
|
isRefreshing: false,
|
|
|
|
};
|
|
|
|
|
2020-08-25 02:24:29 +03:00
|
|
|
_handleCreateSearch = (e) => {
|
|
|
|
dispatchCustomEvent({
|
|
|
|
name: "create-modal",
|
2020-08-31 21:19:46 +03:00
|
|
|
detail: { modal: <SearchModal onAction={this.props.onAction} /> },
|
2020-08-25 02:24:29 +03:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-09-06 04:57:39 +03:00
|
|
|
_handleRehydrate = (e) => {
|
|
|
|
this.setState({ isRefreshing: true }, async () => {
|
|
|
|
await this.props.onRehydrate();
|
|
|
|
this.setState({ isRefreshing: false });
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2020-04-09 00:29:13 +03:00
|
|
|
render() {
|
2020-08-20 08:45:43 +03:00
|
|
|
const isBackDisabled =
|
|
|
|
this.props.currentIndex === 0 || this.props.history.length < 2;
|
2020-04-09 00:29:13 +03:00
|
|
|
|
|
|
|
const isForwardDisabled =
|
2020-08-20 08:45:43 +03:00
|
|
|
this.props.currentIndex === this.props.history.length - 1 ||
|
|
|
|
this.props.history.length < 2;
|
2020-04-09 00:29:13 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<header css={STYLES_APPLICATION_HEADER}>
|
|
|
|
<div css={STYLES_LEFT}>
|
|
|
|
<span
|
|
|
|
css={STYLES_ICON_ELEMENT}
|
2020-08-20 08:45:43 +03:00
|
|
|
style={
|
|
|
|
isBackDisabled
|
|
|
|
? { cursor: "not-allowed", color: Constants.system.border }
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
onClick={isBackDisabled ? () => {} : this.props.onBack}
|
|
|
|
>
|
|
|
|
<SVG.NavigationArrow
|
2020-09-05 00:37:50 +03:00
|
|
|
height="24px"
|
2020-08-20 08:45:43 +03:00
|
|
|
style={{ transform: `rotate(180deg)` }}
|
|
|
|
/>
|
2020-04-09 00:29:13 +03:00
|
|
|
</span>
|
|
|
|
<span
|
|
|
|
css={STYLES_ICON_ELEMENT}
|
2020-08-20 08:45:43 +03:00
|
|
|
style={
|
|
|
|
isForwardDisabled
|
|
|
|
? { cursor: "not-allowed", color: Constants.system.border }
|
|
|
|
: null
|
|
|
|
}
|
|
|
|
onClick={isForwardDisabled ? () => {} : this.props.onForward}
|
|
|
|
>
|
2020-09-05 00:37:50 +03:00
|
|
|
<SVG.NavigationArrow height="24px" />
|
2020-04-09 00:29:13 +03:00
|
|
|
</span>
|
2020-08-11 07:20:14 +03:00
|
|
|
|
2020-08-31 07:08:07 +03:00
|
|
|
<span
|
2020-09-06 04:57:39 +03:00
|
|
|
css={this.state.isRefreshing ? STYLES_ROTATION : STYLES_STATIC}
|
2020-08-31 07:08:07 +03:00
|
|
|
style={{ marginLeft: 24 }}
|
|
|
|
>
|
2020-09-06 04:57:39 +03:00
|
|
|
<span css={STYLES_ICON_ELEMENT} onClick={this._handleRehydrate}>
|
|
|
|
<SVG.Refresh height="20px" />
|
|
|
|
</span>
|
2020-08-31 07:08:07 +03:00
|
|
|
</span>
|
|
|
|
|
2020-08-11 07:20:14 +03:00
|
|
|
<span
|
|
|
|
css={STYLES_ICON_ELEMENT}
|
|
|
|
style={{ marginLeft: 24 }}
|
2020-08-25 02:24:29 +03:00
|
|
|
onClick={this._handleCreateSearch}
|
2020-08-20 08:45:43 +03:00
|
|
|
>
|
2020-09-05 00:37:50 +03:00
|
|
|
<SVG.Search height="20px" />
|
2020-08-11 07:20:14 +03:00
|
|
|
</span>
|
2020-04-09 00:29:13 +03:00
|
|
|
</div>
|
2020-06-19 06:57:57 +03:00
|
|
|
<div css={STYLES_MIDDLE} />
|
2020-08-08 03:10:28 +03:00
|
|
|
<div css={STYLES_RIGHT} />
|
2020-04-09 00:29:13 +03:00
|
|
|
</header>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|