import * as React from "react" import styled, { css } from "styled-components" import MenuItem from "./MenuItem.component" import SocialLink from "../../SocialLink" import { SocialMedia } from "./Social.component" import CategorySprite from "./CategorySprite.component" import withTranslate from "jamplay-common/i18n/withTranslate" import FixScroll from "../../FixScroll" const DrawerContainerRoot = styled.div` width: 300px; position: fixed; top: 0; left: 0; bottom: 0; right: 0; z-index: 99999999; opacity: 0; pointer-events: none; transition: 0.11111s ease-in opacity; will-change: opacity; ` const DrawerContainer = styled(DrawerContainerRoot)` hr { color: #e5e5e5; background-color: #e5e5e5; height: 1px; border: none; width: 100%; } .outside.visible { top: 0; left: 0; bottom: 0; right: 0; background: rgba(0, 0, 0, 0.3); position: fixed; } ${(props: any) => props.visible ? css` opacity: 1 !important; pointer-events: all !important; ` : ""}; ` as any const DrawerMenu = styled.div` box-shadow: 2px 0 2px rgba(0, 0, 0, 0.3); position: relative; -webkit-overflow-scrolling: touch; top: 0; left: 0; bottom: 0; z-index: 1000; height: 100vh; background: white; transform: translateX(-100%); transition: 0.2222s ease-in-out transform; will-change: transform; overflow-y: auto; ` const DrawerMenuWithVisible = styled(DrawerMenu)` ${(props: any) => props.visible ? css` transform: translateX(0%) !important; ` : ""}; ` as any const DrawerMenuContent = styled.div` margin-top: 30px; margin-bottom: 30px; ` @withTranslate export default class Drawer extends React.Component { public state: { isMount: boolean } public props: { visible: boolean onClose?: () => void categories: any } & withTranslatePropType constructor(props) { super(props) this.state = { isMount: false } } public componentDidMount() { this.setState({ isMount: true }) } public render() { const { t, visible, onClose, categories } = this.props if (!t) { throw new Error("have no translate") } if (!categories) { throw new Error( "Drawer.component.js, Categories data is not provided to Layout/DrawerMenu, please follow Landing/index.js:66-68" ) } let pathname = "" if (typeof window !== "undefined") { pathname = window.location.pathname } if (!this.state.isMount) { return
} return (
} active={false} href={"/all/jamsai/trendy"} title={t("fiction") + " " + t("jamsai")} className={visible ? "menuIn" : ""} delay={0.444} /> {categories.map((category, i) => ( } title={t("fiction") + " " + t(category.name)} key={category.value} /> ))}
{visible ? : null} ) } }