import React from 'react'; import { Route, Switch } from 'react-router-dom'; import { Swipeable } from 'react-swipeable'; import { faBars as burgerIcon } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import classnames from 'classnames'; import * as PropTypes from 'prop-types'; import { serverType } from '../servers/prop-types'; import NotFound from './NotFound'; import './MenuLayout.scss'; const MenuLayout = (TagsList, ShortUrls, AsideMenu, CreateShortUrl, ShortUrlVisits) => class MenuLayout extends React.Component { static propTypes = { match: PropTypes.object, selectServer: PropTypes.func, location: PropTypes.object, selectedServer: serverType, }; state = { showSideBar: false }; componentDidMount() { const { match, selectServer } = this.props; const { params: { serverId } } = match; selectServer(serverId); } componentDidUpdate(prevProps) { const { location } = this.props; // Hide sidebar when location changes if (location !== prevProps.location) { this.setState({ showSideBar: false }); } } render() { const { selectedServer, match } = this.props; const { params: { serverId } } = match; const burgerClasses = classnames('menu-layout__burger-icon', { 'menu-layout__burger-icon--active': this.state.showSideBar, }); const swipeMenuIfNoModalExists = (showSideBar) => () => { if (document.querySelector('.modal')) { return; } this.setState({ showSideBar }); }; return ( this.setState(({ showSideBar }) => ({ showSideBar: !showSideBar }))} />
this.setState({ showSideBar: false })} > } />
); } }; export default MenuLayout;