@@ -8,13 +8,15 @@ import classnames from 'classnames';
8
8
* Internal dependencies
9
9
*/
10
10
import Gridicon from 'components/gridicon' ;
11
- import layoutFocus from 'lib/layout-focus' ;
12
11
import EditorPublishButton from 'post-editor/editor-publish-button' ;
13
12
import Button from 'components/button' ;
13
+ import observe from 'lib/mixins/data-observe' ;
14
14
15
15
export default React . createClass ( {
16
16
displayName : 'EditorMobileNavigation' ,
17
17
18
+ mixins : [ observe ( 'layoutFocus' ) ] ,
19
+
18
20
propTypes : {
19
21
site : PropTypes . object ,
20
22
post : PropTypes . object ,
@@ -25,27 +27,16 @@ export default React.createClass( {
25
27
isPublishing : PropTypes . bool ,
26
28
isSaveBlocked : PropTypes . bool ,
27
29
hasContent : PropTypes . bool ,
28
- onClose : PropTypes . func
29
- } ,
30
-
31
- getInitialState : function ( ) {
32
- return {
33
- sidebarOpen : false
34
- } ;
30
+ onClose : PropTypes . func ,
31
+ layoutFocus : PropTypes . object
35
32
} ,
36
33
37
34
openSidebar : function ( ) {
38
- if ( ! this . state . sidebarOpen ) {
39
- layoutFocus . set ( 'sidebar' ) ;
40
- this . setState ( { sidebarOpen : true } ) ;
41
- }
35
+ this . props . layoutFocus . set ( 'sidebar' ) ;
42
36
} ,
43
37
44
38
closeSidebar : function ( ) {
45
- if ( this . state . sidebarOpen ) {
46
- layoutFocus . set ( 'content' ) ;
47
- this . setState ( { sidebarOpen : false } ) ;
48
- }
39
+ this . props . layoutFocus . set ( 'content' ) ;
49
40
} ,
50
41
51
42
render : function ( ) {
@@ -66,14 +57,14 @@ export default React.createClass( {
66
57
< Gridicon
67
58
icon = "pencil"
68
59
className = { classnames ( 'editor-mobile-navigation__icon' , {
69
- 'is-selected' : ! this . state . sidebarOpen
60
+ 'is-selected' : this . props . layoutFocus . getCurrent ( ) === 'content'
70
61
} ) } />
71
62
</ Button >
72
63
< Button borderless onClick = { this . openSidebar } >
73
64
< Gridicon
74
65
icon = "cog"
75
66
className = { classnames ( 'editor-mobile-navigation__icon' , {
76
- 'is-selected' : this . state . sidebarOpen
67
+ 'is-selected' : this . props . layoutFocus . getCurrent ( ) === 'sidebar'
77
68
} ) } />
78
69
</ Button >
79
70
</ div >
0 commit comments