@@ -41,47 +41,56 @@ const MenuProvider = props => {
4141 _setMenuProps ( newMenuProps ) ;
4242 } ;
4343
44- return (
45- < MenuContext . Provider
46- value = { { openMenu, closeMenu, toggleMenu, setMenuProps } }
47- >
48- { animation === 'push' ? (
49- < >
50- { isMenuOpen && (
51- < MenuContainerForPush
44+ const renderContents = ( ) => {
45+ switch ( animation ) {
46+ case 'push' :
47+ return (
48+ < >
49+ { isMenuOpen && (
50+ < MenuContainerForPush
51+ direction = { direction }
52+ width = { width }
53+ menuIsClosing = { menuIsClosing }
54+ setIsMenuOpen = { setIsMenuOpen }
55+ >
56+ < MenuComponent { ...menuProps } />
57+ </ MenuContainerForPush >
58+ ) }
59+ < AppContainerForPush
5260 direction = { direction }
5361 width = { width }
54- menuIsClosing = { menuIsClosing }
5562 setIsMenuOpen = { setIsMenuOpen }
56- >
57- < MenuComponent { ...menuProps } />
58- </ MenuContainerForPush >
59- ) }
60- < AppContainerForPush
61- direction = { direction }
62- width = { width }
63- setIsMenuOpen = { setIsMenuOpen }
64- isMenuOpen = { isMenuOpen }
65- menuIsClosing = { menuIsClosing }
66- >
67- { children }
68- </ AppContainerForPush >
69- </ >
70- ) : (
71- < >
72- { isMenuOpen && (
73- < MenuContainerForSlide
74- direction = { direction }
75- width = { width }
63+ isMenuOpen = { isMenuOpen }
7664 menuIsClosing = { menuIsClosing }
77- setIsMenuOpen = { setIsMenuOpen }
7865 >
79- < MenuComponent { ...menuProps } />
80- </ MenuContainerForSlide >
81- ) }
82- { children }
83- </ >
84- ) }
66+ { children }
67+ </ AppContainerForPush >
68+ </ >
69+ ) ;
70+ default :
71+ return (
72+ < >
73+ { isMenuOpen && (
74+ < MenuContainerForSlide
75+ direction = { direction }
76+ width = { width }
77+ menuIsClosing = { menuIsClosing }
78+ setIsMenuOpen = { setIsMenuOpen }
79+ >
80+ < MenuComponent { ...menuProps } />
81+ </ MenuContainerForSlide >
82+ ) }
83+ { children }
84+ </ >
85+ ) ;
86+ }
87+ } ;
88+
89+ return (
90+ < MenuContext . Provider
91+ value = { { openMenu, closeMenu, toggleMenu, setMenuProps } }
92+ >
93+ { renderContents ( ) }
8594 </ MenuContext . Provider >
8695 ) ;
8796} ;
@@ -91,7 +100,6 @@ MenuProvider.propTypes = {
91100 * Set's the initial state of the Menu i.e. Open or Close
92101 */
93102 openByDefault : PropTypes . bool ,
94- takeChildrenHeight : PropTypes . bool ,
95103 direction : PropTypes . oneOf ( [ 'left' , 'right' ] ) ,
96104 animation : PropTypes . oneOf ( [ 'slide' , 'push' ] ) ,
97105 MenuComponent : PropTypes . elementType . isRequired ,
@@ -101,7 +109,6 @@ MenuProvider.propTypes = {
101109
102110MenuProvider . defaultProps = {
103111 openByDefault : false ,
104- takeChildrenHeight : false ,
105112 width : '250px' ,
106113 direction : 'left' ,
107114 animation : 'slide'
0 commit comments