1
1
import React from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
+ import compose from 'recompose/compose' ;
3
4
import { withStyles } from 'material-ui/styles' ;
4
5
import classNames from 'classnames' ;
5
6
import Drawer from 'material-ui/Drawer' ;
6
- import compose from 'recompose/compose' ;
7
7
import withWidth , { isWidthDown } from 'material-ui/utils/withWidth' ;
8
8
import controllable from 'react-controllables' ;
9
9
@@ -164,6 +164,14 @@ class Layout extends React.PureComponent {
164
164
[ `${ classes . drawerHeaderTwoRowAppBar } ` ] : usingTwoRowAppBar ,
165
165
} )
166
166
167
+ // FIXME find a better way to inject the closeDrawer prop
168
+ const leftDrawerContentWithProps = leftDrawerContent
169
+ ? React . cloneElement ( leftDrawerContent , { closeDrawer : this . handleLeftDrawerClose } )
170
+ : leftDrawerContent ;
171
+ const rightDrawerContentWithProps = rightDrawerContent
172
+ ? React . cloneElement ( rightDrawerContent , { closeDrawer : this . handleRightDrawerClose } )
173
+ : rightDrawerContent ;
174
+
167
175
return (
168
176
< div className = { classes . layout } >
169
177
< AppBar
@@ -183,10 +191,11 @@ class Layout extends React.PureComponent {
183
191
classes = { { paper : leftDrawerPaperClassnames } }
184
192
{ ...leftDrawerProps }
185
193
>
194
+ { /* add a header to move content down if screen is not small and under the appbar */ }
186
195
{ ! smallScreen && leftDrawerUnder ? (
187
196
< div className = { drawerHeaderClassnames } />
188
197
) : null }
189
- { leftDrawerContent }
198
+ { leftDrawerContentWithProps }
190
199
</ Drawer >
191
200
) : null }
192
201
{ rightDrawerContent ? (
@@ -198,10 +207,11 @@ class Layout extends React.PureComponent {
198
207
classes = { { paper : rightDrawerPaperClassnames } }
199
208
{ ...rightDrawerProps }
200
209
>
210
+ { /* add a header to move content down if screen is not small and under the appbar */ }
201
211
{ ! smallScreen && rightDrawerUnder ? (
202
212
< div className = { drawerHeaderClassnames } />
203
213
) : null }
204
- { rightDrawerContent }
214
+ { rightDrawerContentWithProps }
205
215
</ Drawer >
206
216
) : null }
207
217
< main className = { mainClassnames } > { children } </ main >
0 commit comments