@@ -20,8 +20,10 @@ class Main extends React.Component {
2020 let { config } = props
2121
2222 this . state = {
23- isSliderFocused : false ,
24- listWidth : config . listWidth
23+ isRightSliderFocused : false ,
24+ listWidth : config . listWidth ,
25+ navWidth : config . listWidth ,
26+ isLeftSliderFocused : false
2527 }
2628 }
2729
@@ -49,17 +51,24 @@ class Main extends React.Component {
4951 } )
5052 }
5153
52- handleSlideMouseDown ( e ) {
54+ handleLeftSlideMouseDown ( e ) {
5355 e . preventDefault ( )
5456 this . setState ( {
55- isSliderFocused : true
57+ isLeftSliderFocused : true
58+ } )
59+ }
60+
61+ handleRightSlideMouseDown ( e ) {
62+ e . preventDefault ( )
63+ this . setState ( {
64+ isRightSliderFocused : true
5665 } )
5766 }
5867
5968 handleMouseUp ( e ) {
60- if ( this . state . isSliderFocused ) {
69+ if ( this . state . isRightSliderFocused ) {
6170 this . setState ( {
62- isSliderFocused : false
71+ isRightSliderFocused : false
6372 } , ( ) => {
6473 let { dispatch } = this . props
6574 let newListWidth = this . state . listWidth
@@ -71,10 +80,24 @@ class Main extends React.Component {
7180 } )
7281 } )
7382 }
83+ if ( this . state . isLeftSliderFocused ) {
84+ this . setState ( {
85+ isLeftSliderFocused : false
86+ } , ( ) => {
87+ let { dispatch } = this . props
88+ let navWidth = this . state . navWidth
89+ // TODO: ConfigManager should dispatch itself.
90+ ConfigManager . set ( { listWidth : navWidth } )
91+ dispatch ( {
92+ type : 'SET_NAV_WIDTH' ,
93+ listWidth : navWidth
94+ } )
95+ } )
96+ }
7497 }
7598
7699 handleMouseMove ( e ) {
77- if ( this . state . isSliderFocused ) {
100+ if ( this . state . isRightSliderFocused ) {
78101 let offset = this . refs . body . getBoundingClientRect ( ) . left
79102 let newListWidth = e . pageX - offset
80103 if ( newListWidth < 10 ) {
@@ -86,6 +109,17 @@ class Main extends React.Component {
86109 listWidth : newListWidth
87110 } )
88111 }
112+ if ( this . state . isLeftSliderFocused ) {
113+ let navWidth = e . pageX
114+ if ( navWidth < 80 ) {
115+ navWidth = 80
116+ } else if ( navWidth > 600 ) {
117+ navWidth = 600
118+ }
119+ this . setState ( {
120+ navWidth : navWidth
121+ } )
122+ }
89123 }
90124
91125 render ( ) {
@@ -105,9 +139,20 @@ class Main extends React.Component {
105139 'config' ,
106140 'location'
107141 ] ) }
142+ width = { this . state . navWidth }
108143 />
144+ { ! config . isSideNavFolded &&
145+ < div styleName = { this . state . isLeftSliderFocused ? 'slider--active' : 'slider' }
146+ style = { { left : this . state . navWidth - 1 } }
147+ onMouseDown = { ( e ) => this . handleLeftSlideMouseDown ( e ) }
148+ draggable = 'false'
149+ >
150+ < div styleName = 'slider-hitbox' />
151+ </ div >
152+ }
109153 < div styleName = { config . isSideNavFolded ? 'body--expanded' : 'body' }
110154 ref = 'body'
155+ style = { { left : config . isSideNavFolded ? 44 : this . state . navWidth } }
111156 >
112157 < TopBar style = { { width : this . state . listWidth } }
113158 { ..._ . pick ( this . props , [
@@ -127,9 +172,9 @@ class Main extends React.Component {
127172 'location'
128173 ] ) }
129174 />
130- < div styleName = { this . state . isSliderFocused ? 'slider--active' : 'slider' }
175+ < div styleName = { this . state . isRightSliderFocused ? 'slider--active' : 'slider' }
131176 style = { { left : this . state . listWidth } }
132- onMouseDown = { ( e ) => this . handleSlideMouseDown ( e ) }
177+ onMouseDown = { ( e ) => this . handleRightSlideMouseDown ( e ) }
133178 draggable = 'false'
134179 >
135180 < div styleName = 'slider-hitbox' />
@@ -143,7 +188,7 @@ class Main extends React.Component {
143188 'params' ,
144189 'location'
145190 ] ) }
146- ignorePreviewPointerEvents = { this . state . isSliderFocused }
191+ ignorePreviewPointerEvents = { this . state . isRightSliderFocused }
147192 />
148193 </ div >
149194 < StatusBar
0 commit comments