@@ -29,6 +29,9 @@ const styles = theme => ({
29
29
}
30
30
} ) ;
31
31
32
+ const defaultElevation = 2 ;
33
+ const focusedElevation = 8 ;
34
+
32
35
class Index extends React . Component {
33
36
34
37
constructor ( props ) {
@@ -69,6 +72,14 @@ class Index extends React.Component {
69
72
} ;
70
73
}
71
74
75
+ componentDidMount ( ) {
76
+ document . onblur = ( ) => {
77
+ this . setState ( {
78
+ focusedPane : null ,
79
+ } ) ;
80
+ }
81
+ }
82
+
72
83
setPersistentState = ( updater ) => {
73
84
this . setState ( updater , function ( updater ) {
74
85
if ( typeof updater === 'function' ) {
@@ -130,12 +141,18 @@ class Index extends React.Component {
130
141
}
131
142
132
143
handleInsertButtonClick = ( ) => {
144
+ this . setState ( {
145
+ focusedPane : this . state . insertPanelsAreOpen ? null : 'InsertPanels' ,
146
+ } ) ;
133
147
this . setPersistentState ( {
134
148
insertPanelsAreOpen : ! this . state . insertPanelsAreOpen ,
135
149
} ) ;
136
150
}
137
151
138
152
handleNodeFormatButtonClick = ( ) => {
153
+ this . setState ( {
154
+ focusedPane : this . state . nodeFormatDrawerIsOpen ? null : 'NodeFormatDrawer' ,
155
+ } ) ;
139
156
this . setPersistentState ( {
140
157
nodeFormatDrawerIsOpen : ! this . state . nodeFormatDrawerIsOpen ,
141
158
edgeFormatDrawerIsOpen : false ,
@@ -146,9 +163,15 @@ class Index extends React.Component {
146
163
this . setPersistentState ( {
147
164
nodeFormatDrawerIsOpen : false ,
148
165
} ) ;
166
+ this . setState ( {
167
+ focusedPane : null ,
168
+ } ) ;
149
169
}
150
170
151
171
handleEdgeFormatButtonClick = ( ) => {
172
+ this . setState ( {
173
+ focusedPane : this . state . edgeFormatDrawerIsOpen ? null : 'EdgeFormatDrawer' ,
174
+ } ) ;
152
175
this . setPersistentState ( {
153
176
edgeFormatDrawerIsOpen : ! this . state . edgeFormatDrawerIsOpen ,
154
177
nodeFormatDrawerIsOpen : false ,
@@ -159,6 +182,9 @@ class Index extends React.Component {
159
182
this . setPersistentState ( {
160
183
edgeFormatDrawerIsOpen : false ,
161
184
} ) ;
185
+ this . setState ( {
186
+ focusedPane : null ,
187
+ } ) ;
162
188
}
163
189
164
190
handleSettingsClick = ( ) => {
@@ -381,9 +407,59 @@ class Index extends React.Component {
381
407
this . redo = redo ;
382
408
}
383
409
410
+ handleTextEditorFocus = ( ) => {
411
+ this . setState ( {
412
+ focusedPane : 'TextEditor' ,
413
+ } ) ;
414
+ }
415
+
416
+ handleTextEditorBlur = ( ) => {
417
+ if ( this . state . focusedPane === 'TextEditor' ) {
418
+ this . setState ( {
419
+ focusedPane : null ,
420
+ } ) ;
421
+ }
422
+ }
423
+
424
+ handleGraphFocus = ( ) => {
425
+ this . setState ( {
426
+ focusedPane : 'Graph' ,
427
+ } ) ;
428
+ }
429
+
430
+ handleInsertPanelsClick = ( ) => {
431
+ this . setState ( {
432
+ focusedPane : 'InsertPanels' ,
433
+ } ) ;
434
+ }
435
+
436
+ handleNodeFormatDrawerClick = ( ) => {
437
+ this . setState ( ( state ) => {
438
+ return {
439
+ focusedPane : state . nodeFormatDrawerIsOpen ? 'NodeFormatDrawer' : null ,
440
+ }
441
+ } ) ;
442
+ }
443
+
444
+ handleEdgeFormatDrawerClick = ( ) => {
445
+ this . setState ( ( state ) => {
446
+ return {
447
+ focusedPane : state . edgeFormatDrawerIsOpen ? 'EdgeFormatDrawer' : null ,
448
+ }
449
+ } ) ;
450
+ }
451
+
384
452
render ( ) {
385
453
const { classes } = this . props ;
386
454
const editorIsOpen = ! this . state . nodeFormatDrawerIsOpen && ! this . state . edgeFormatDrawerIsOpen ;
455
+ const textEditorHasFocus = this . state . focusedPane === 'TextEditor' ;
456
+ const nodeFormatDrawerHasFocus = this . state . focusedPane === 'NodeFormatDrawer' ;
457
+ const edgeFormatDrawerHasFocus = this . state . focusedPane === 'EdgeFormatDrawer' ;
458
+ const insertPanelsHaveFocus = this . state . focusedPane === 'InsertPanels' ;
459
+ const graphHasFocus = this . state . focusedPane === 'Graph' ;
460
+ const leftPaneElevation = textEditorHasFocus || nodeFormatDrawerHasFocus || edgeFormatDrawerHasFocus ? focusedElevation : defaultElevation ;
461
+ const rightPaneElevation = graphHasFocus ? focusedElevation : defaultElevation ;
462
+ const midPaneElevation = insertPanelsHaveFocus ? focusedElevation : defaultElevation ;
387
463
388
464
var columns ;
389
465
if ( this . state . insertPanelsAreOpen && this . state . graphInitialized ) {
@@ -454,11 +530,12 @@ class Index extends React.Component {
454
530
} }
455
531
>
456
532
< Grid item xs = { columns . textEditor } >
457
- < Paper className = { classes . paper } >
533
+ < Paper elevation = { leftPaneElevation } className = { classes . paper } >
458
534
< FormatDrawer
459
535
type = 'node'
460
536
open = { this . state . nodeFormatDrawerIsOpen }
461
537
defaultAttributes = { this . state . defaultNodeAttributes }
538
+ onClick = { this . handleNodeFormatDrawerClick }
462
539
onFormatDrawerClose = { this . handleNodeFormatDrawerClose }
463
540
onStyleChange = { this . handleNodeStyleChange }
464
541
onColorChange = { this . handleNodeColorChange }
@@ -468,6 +545,7 @@ class Index extends React.Component {
468
545
type = 'edge'
469
546
open = { this . state . edgeFormatDrawerIsOpen }
470
547
defaultAttributes = { this . state . defaultEdgeAttributes }
548
+ onClick = { this . handleEdgeFormatDrawerClick }
471
549
onFormatDrawerClose = { this . handleEdgeFormatDrawerClose }
472
550
onStyleChange = { this . handleEdgeStyleChange }
473
551
onColorChange = { this . handleEdgeColorChange }
@@ -494,8 +572,9 @@ class Index extends React.Component {
494
572
</ Grid >
495
573
{ this . state . insertPanelsAreOpen && this . state . graphInitialized && (
496
574
< Grid item xs = { columns . insertPanels } >
497
- < Paper className = { classes . paper } >
575
+ < Paper elevation = { midPaneElevation } className = { classes . paper } >
498
576
< InsertPanels
577
+ onClick = { this . handleInsertPanelsClick }
499
578
onNodeShapeClick = { this . handleNodeShapeClick }
500
579
onNodeShapeDragStart = { this . handleNodeShapeDragStart }
501
580
onNodeShapeDragEnd = { this . handleNodeShapeDragEnd }
@@ -504,8 +583,9 @@ class Index extends React.Component {
504
583
</ Grid >
505
584
) }
506
585
< Grid item xs = { columns . graph } >
507
- < Paper className = { classes . paper } >
586
+ < Paper elevation = { rightPaneElevation } className = { classes . paper } >
508
587
< Graph
588
+ hasFocus = { graphHasFocus }
509
589
dotSrc = { this . state . dotSrc }
510
590
engine = { this . state . engine }
511
591
fit = { this . state . fitGraph }
@@ -515,6 +595,7 @@ class Index extends React.Component {
515
595
tweenPrecision = { this . state . tweenPrecision }
516
596
defaultNodeAttributes = { this . state . defaultNodeAttributes }
517
597
defaultEdgeAttributes = { this . state . defaultEdgeAttributes }
598
+ onFocus = { this . handleGraphFocus }
518
599
onTextChange = { this . handleTextChange }
519
600
onHelp = { this . handleKeyboardShortcutsClick }
520
601
onSelect = { this . handleGraphComponentSelect }
0 commit comments