import * as React from "react"; import * as Constants from "~/common/constants"; import * as SVG from "~/common/svg"; import * as Events from "~/common/custom-events"; import * as Styles from "~/common/styles"; import { ApplicationUserControls, ApplicationUserControlsPopup, } from "~/components/core/ApplicationUserControls"; import { css, keyframes } from "@emotion/react"; import { Boundary } from "~/components/system/components/fragments/Boundary"; import { PopoverNavigation } from "~/components/system"; import { DarkSymbol } from "~/common/logo"; import { Link } from "~/components/core/Link"; import { ButtonPrimary, ButtonTertiary } from "~/components/system/components/Buttons"; const STYLES_NAV_LINKS = css` display: flex; flex-direction: row; @media (max-width: ${Constants.sizes.mobile}px) { flex-direction: column; overflow: hidden; } `; const STYLES_NAV_LINK = css` color: ${Constants.semantic.textGray}; text-decoration: none; transition: 200ms ease color; display: block; cursor: pointer; padding: 4px 24px; font-size: ${Constants.typescale.lvl1}; :hover { color: ${Constants.system.blue}; } @media (max-width: ${Constants.sizes.mobile}px) { border-bottom: 1px solid ${Constants.system.grayLight2}; margin: 0px 24px; padding: 12px 0px; ${Styles.P2}; } `; const STYLES_APPLICATION_HEADER_CONTAINER = (theme) => css` width: 100%; background-color: ${theme.system.white}; box-shadow: 0 0 0 1px ${theme.semantic.bgGrayLight}; @supports ((-webkit-backdrop-filter: blur(25px)) or (backdrop-filter: blur(25px))) { -webkit-backdrop-filter: blur(25px); backdrop-filter: blur(25px); background-color: rgba(255, 255, 255, 0.7); } `; const STYLES_APPLICATION_HEADER = css` display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; ${"" /* justify-content: space-between; */} width: 100%; height: ${Constants.sizes.header}px; ${"" /* padding: 0 24px 0 16px; */} padding: 0px 32px; @media (max-width: ${Constants.sizes.mobile}px) { padding: 0px 24px; width: 100%; } `; const STYLES_LEFT = css` flex-shrink: 0; display: flex; align-items: center; justify-content: flex-start; `; const STYLES_MIDDLE = css` min-width: 10%; width: 100%; padding: 0 24px; display: flex; justify-content: center; `; const STYLES_RIGHT = css` flex-shrink: 0; display: flex; align-items: center; justify-content: flex-end; `; const STYLES_BACKGROUND = css` position: absolute; width: 100vw; height: 100vh; background-color: ${Constants.semantic.bgBlurDark6}; pointer-events: auto; @keyframes fade-in { from { opacity: 50%; } to { opacity: 100%; } } animation: fade-in 200ms ease-out; `; const STYLES_UPLOAD_BUTTON = css` background-color: ${Constants.semantic.bgGrayLight}; border-radius: 8px; width: 24px; height: 24px; cursor: pointer; pointer-events: auto; ${Styles.CONTAINER_CENTERED}; `; export default class ApplicationHeader extends React.Component { keysPressed = {}; searchModKey = this.props.isMac ? ( ) : ( Ctrl ); state = { showDropdown: false, popup: null, isRefreshing: false, }; componentDidMount = () => { window.addEventListener("keydown", this._handleKeyDown); window.addEventListener("keyup", this._handleKeyUp); }; _handleKeyDown = (e) => { let prevValue = this.keysPressed[e.key]; if (prevValue) { return; } this.keysPressed[e.key] = true; if ((this.keysPressed["Control"] || this.keysPressed["Meta"]) && this.keysPressed["f"]) { e.preventDefault(); e.stopPropagation(); this._handleCreateSearch(); } }; _handleKeyUp = (e) => { this.keysPressed = {}; }; _handleCreateSearch = (e) => { this.setState({ showDropdown: false }); Events.dispatchCustomEvent({ name: "show-search", detail: {}, }); }; _handleTogglePopup = (value) => { if (!value || this.state.popup === value) { this.setState({ popup: null }); } else { this.setState({ popup: value, showDropdown: false }); } }; render() { const navigation = this.props.navigation.filter((item) => item.mainNav); if (!this.props.viewer) { const searchComponent = (
Search Slate...
); //NOTE(martina): signed out view return (
{searchComponent}
{searchComponent}
Sign in Sign up
); } const mobilePopup = ( // { // e.stopPropagation(); // e.preventDefault(); // this._handleTogglePopup(e); // }} // > <>
// ); const mobileDropdown = ( <> { e.stopPropagation(); e.preventDefault(); this.setState({ showDropdown: false }); }} >
{this.props.navigation .filter((item) => item.mainNav) .map((item) => ( this.setState({ showDropdown: false })} >
{item.name}
))}
Search
); return ( <>
{ this.props.onAction({ type: "SIDEBAR", value: "SIDEBAR_ADD_FILE_TO_BUCKET", }); }} style={{ marginRight: 24, marginLeft: 24 }} >
{navigation.map((item, i) => (
{item.name}
))}
Search
this.setState({ showDropdown: !this.state.showDropdown, popup: null }) } >
{this.state.popup === "profile" ? mobilePopup : this.state.showDropdown ? mobileDropdown : null}
); } }