Skip to content

Commit

Permalink
Refactor navigation sidebar directory structure
Browse files Browse the repository at this point in the history
Because navigation panel and navigation toggle live outside the header and body, we place both components in their own navigation sidebar directory
  • Loading branch information
jeyip committed Oct 8, 2020
1 parent 93f9cde commit 390e69f
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 22 deletions.
31 changes: 14 additions & 17 deletions packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ import KeyboardShortcuts from '../keyboard-shortcuts';
import GlobalStylesProvider from './global-styles-provider';
import LeftSidebar from '../left-sidebar';
// TODO: Refactor directory and file structure
import NavigationPanel from '../left-sidebar/navigation-panel';
import NavigationToggle from '../header/navigation-toggle';
import NavigationSidebar from '../navigation-sidebar';

const interfaceLabels = {
leftSidebar: __( 'Block Library' ),
Expand Down Expand Up @@ -204,21 +203,19 @@ function Editor() {
<InterfaceSkeleton
labels={ interfaceLabels }
navigationSidebar={
<>
<NavigationToggle
isOpen={
isNavigationOpen
}
onClick={ () =>
toggleLeftSidebarContent(
'navigation'
)
}
/>
{ isNavigationOpen && (
<NavigationPanel />
) }
</>
<NavigationSidebar
content={
leftSidebarContent
}
isOpen={
isNavigationOpen
}
onNavigationToggle={ () =>
toggleLeftSidebarContent(
'navigation'
)
}
/>
}
leftSidebar={
<LeftSidebar
Expand Down
5 changes: 0 additions & 5 deletions packages/edit-site/src/components/left-sidebar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
*/
import InserterPanel from './inserter-panel';

// TODO: Remove remnants of conditional rendering for nav sidebar
const LeftSidebar = ( { content, setContent } ) => {
// if ( content === 'navigation' ) {
// return <NavigationPanel />;
// }

if ( content === 'inserter' ) {
return <InserterPanel closeInserter={ () => setContent( null ) } />;
}
Expand Down
19 changes: 19 additions & 0 deletions packages/edit-site/src/components/navigation-sidebar/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Internal dependencies
*/
import NavigationPanel from './navigation-panel';
import NavigationToggle from './navigation-toggle';

const NavigationSidebar = ( { content, isOpen, onNavigationToggle } ) => {
return (
<>
<NavigationToggle
isOpen={ isOpen }
onClick={ onNavigationToggle }
/>
{ content === 'navigation' && isOpen && <NavigationPanel /> }
</>
);
};

export default NavigationSidebar;

0 comments on commit 390e69f

Please sign in to comment.