Explorar o código

open drawer with NavbarToggler

Yuki Takei %!s(int64=6) %!d(string=hai) anos
pai
achega
ebe2fb5240

+ 5 - 2
src/client/js/components/Navbar/NavbarToggler.jsx

@@ -8,11 +8,14 @@ import AppContainer from '../../services/AppContainer';
 
 
 const NavbarToggler = (props) => {
 const NavbarToggler = (props) => {
 
 
-  // eslint-disable-next-line no-unused-vars
   const { appContainer } = props;
   const { appContainer } = props;
 
 
+  const clickHandler = () => {
+    appContainer.setState({ isDrawerOpened: true });
+  };
+
   return (
   return (
-    <button className="navbar-toggler grw-navbar-toggler border-0" type="button" aria-expanded="false" aria-label="Toggle navigation">
+    <button className="navbar-toggler grw-navbar-toggler border-0" type="button" aria-expanded="false" aria-label="Toggle navigation" onClick={clickHandler}>
       <i className="icon-menu"></i>
       <i className="icon-menu"></i>
     </button>
     </button>
   );
   );

+ 4 - 8
src/client/js/components/Sidebar.jsx

@@ -22,17 +22,17 @@ import CustomSidebar from './Sidebar/CustomSidebar';
 class Sidebar extends React.Component {
 class Sidebar extends React.Component {
 
 
   static propTypes = {
   static propTypes = {
+    appContainer: PropTypes.instanceOf(AppContainer).isRequired,
     navigationUIController: PropTypes.any.isRequired,
     navigationUIController: PropTypes.any.isRequired,
   };
   };
 
 
   state = {
   state = {
     currentContentsId: 'custom',
     currentContentsId: 'custom',
-    isDrawerOpen: false,
   };
   };
 
 
-  openDrawer = () => this.setState({ isDrawerOpen: true });
+  openDrawer = () => this.props.appContainer.setState({ isDrawerOpened: true });
 
 
-  closeDrawer = () => this.setState({ isDrawerOpen: false });
+  closeDrawer = () => this.props.appContainer.setState({ isDrawerOpened: false });
 
 
   itemSelectedHandler = (contentsId) => {
   itemSelectedHandler = (contentsId) => {
     const { navigationUIController } = this.props;
     const { navigationUIController } = this.props;
@@ -47,16 +47,12 @@ class Sidebar extends React.Component {
       this.setState({ currentContentsId: contentsId });
       this.setState({ currentContentsId: contentsId });
       navigationUIController.expand();
       navigationUIController.expand();
     }
     }
-
-    // if (contentsId === 'drawer') {
-    //   this.openDrawer();
-    // }
   }
   }
 
 
   renderGlobalNavigation = () => (
   renderGlobalNavigation = () => (
     <>
     <>
       <SidebarNav currentContentsId={this.state.currentContentsId} onItemSelected={this.itemSelectedHandler} />
       <SidebarNav currentContentsId={this.state.currentContentsId} onItemSelected={this.itemSelectedHandler} />
-      <Drawer onClose={this.closeDrawer} isOpen={this.state.isDrawerOpen} width="wide">
+      <Drawer onClose={this.closeDrawer} isOpen={this.props.appContainer.state.isDrawerOpened}>
         <code>Drawer contents</code>
         <code>Drawer contents</code>
       </Drawer>
       </Drawer>
     </>
     </>

+ 1 - 0
src/client/js/services/AppContainer.js

@@ -33,6 +33,7 @@ export default class AppContainer extends Container {
       editorMode: null,
       editorMode: null,
       preferDarkModeByMediaQuery: false,
       preferDarkModeByMediaQuery: false,
       preferDarkModeByUser: null,
       preferDarkModeByUser: null,
+      isDrawerOpen: false,
     };
     };
 
 
     const body = document.querySelector('body');
     const body = document.querySelector('body');

+ 10 - 0
src/client/styles/scss/_layout.scss

@@ -94,6 +94,16 @@
   }
   }
 }
 }
 
 
+// Atlaskit Drawer
+.atlaskit-portal-container {
+  // override @atlaskit/navigation-next styles
+  div[class$='-Wrapper'],
+  .jyecer {
+    // Adjust to be on top of the growi subnavigation
+    z-index: $zindex-fixed + 5;
+  }
+}
+
 #page-wrapper {
 #page-wrapper {
   margin-top: $grw-navbar-height;
   margin-top: $grw-navbar-height;
 }
 }