import React from "react"; import { useParams } from "react-router-dom"; import styled from "styled-components"; import SidebarComponent from "components/editorComponents/Sidebar"; import NavBarItem from "components/editorComponents/NavBarItem"; import { BuilderRouteParams, BUILDER_PAGE_URL, WIDGETS_URL, } from "constants/routes"; import { Colors } from "constants/Colors"; import { MenuIcons } from "icons/MenuIcons"; const Wrapper = styled.div` display: grid; grid-template-columns: 1fr 5fr; width: ${props => props.theme.sidebarWidth}; box-shadow: 0px 1px 3px ${Colors.MINE_SHAFT}; background-color: ${Colors.MINE_SHAFT}; z-index: 3; `; const NavBar = styled.div` background-color: ${Colors.MINE_SHAFT}; color: ${props => props.theme.colors.textOnDarkBG}; display: flex; flex-direction: column; box-shadow: 0px 0px 4px ${Colors.CODE_GRAY}; `; const Navbar = () => { const params = useParams(); return ( { // Currently, the explorer shows on all paths except for the // WIDGETS_URL path // get the applicationId and pageId from the current location pathname const found = current.match( /^\/applications\/(?\w+)\/pages\/(?\w+)\//, ); // In this case: expected = BUILDER_PAGE_URL(applicationId, pageId) // If current url begins with expected url AND // If the current url isn't the WIDGETS_URL THEN // this is an explorer sidebar path return ( current.indexOf(expected) === 0 && current !== WIDGETS_URL(found?.groups?.applicationId, found?.groups?.pageId) ); }} /> expected === current} /> ); }; Navbar.displayName = "Navbar"; Navbar.whyDidYouRender = { logOnDifferentValues: false, customName: "MainSidebar", }; export default Navbar;