@@ -19,27 +19,36 @@ import { changeFocusChild } from '../actions/components';
19
19
20
20
const LeftColExpansionPanel = ( props ) => {
21
21
const {
22
- index, classes, focusComponent, component, deleteComponent, addChild,
23
- changeFocusComponent } = props ;
22
+ index,
23
+ classes,
24
+ focusComponent,
25
+ component,
26
+ deleteComponent,
27
+ addChild,
28
+ changeFocusComponent,
29
+ } = props ;
24
30
const { title, id, color } = component ;
25
31
32
+ function isFocused ( ) {
33
+ return focusComponent . title === title ? 'focused' : '' ;
34
+ }
35
+
26
36
return (
27
37
< div className = { classes . root } >
28
- < Grid item xs = { 12 } md = { 6 } style = { { color : 'red' } } >
29
- < List
30
- style = { { color : 'red' } }
31
- >
32
- < ListItem button component = "a"
33
- // style={
34
- // if (components.find(comp => comp.title === focusComponent.title))
35
- // }
36
- style = { { color : 'red' } }
37
- onClick = { ( ) => {
38
- console . log ( { title } )
39
- changeFocusComponent ( { title } )
40
-
41
- } }
42
- >
38
+ < Grid item xs = { 12 } md = { 6 } style = { { color : 'red' } } >
39
+ < List style = { { color : 'red' } } >
40
+ < ListItem
41
+ button
42
+ component = "a"
43
+ // style={
44
+ // if (components.find(comp => comp.title === focusComponent.title))
45
+ // }
46
+ style = { { color : 'red' } }
47
+ onClick = { ( ) => {
48
+ console . log ( { title } ) ;
49
+ changeFocusComponent ( { title } ) ;
50
+ } }
51
+ >
43
52
< ListItemText
44
53
disableTypography
45
54
className = { classes . light }
@@ -48,20 +57,24 @@ const LeftColExpansionPanel = (props) => {
48
57
{ title }
49
58
</ Typography >
50
59
}
51
- secondary = { 'focused' }
60
+ secondary = { isFocused ( ) }
52
61
style = { { color } }
53
62
/>
54
63
< ListItemSecondaryAction >
55
- < IconButton aria-label = "Add" >
56
- < AddIcon
57
- style = { { color, float : 'right' } }
58
- onClick = { ( ) => {
59
- console . log ( title ) ;
60
- addChild ( { title } ) ;
61
- changeFocusChild ( { title } ) ;
62
- } }
63
- />
64
- </ IconButton >
64
+ { isFocused ( ) ? (
65
+ < div />
66
+ ) : (
67
+ < IconButton aria-label = "Add" >
68
+ < AddIcon
69
+ style = { { color, float : 'right' } }
70
+ onClick = { ( ) => {
71
+ console . log ( title ) ;
72
+ addChild ( { title } ) ;
73
+ changeFocusChild ( { title } ) ;
74
+ } }
75
+ />
76
+ </ IconButton >
77
+ ) }
65
78
</ ListItemSecondaryAction >
66
79
</ ListItem >
67
80
</ List >
0 commit comments