1
- import React , { Fragment } from " react" ;
2
- import { withStyles } from " @material-ui/core/styles" ;
3
- import Typography from " @material-ui/core/Typography" ;
4
- import List from " @material-ui/core/List" ;
5
- import ListItem from " @material-ui/core/ListItem" ;
6
- import ListItemSecondaryAction from " @material-ui/core/ListItemSecondaryAction" ;
7
- import ListItemText from " @material-ui/core/ListItemText" ;
8
- import IconButton from " @material-ui/core/IconButton" ;
9
- import Grid from " @material-ui/core/Grid" ;
10
- import AddIcon from " @material-ui/icons/Add" ;
11
- import DeleteIcon from " @material-ui/icons/Delete" ;
12
- import Fab from " @material-ui/core/Fab" ;
1
+ import React , { Fragment } from ' react' ;
2
+ import { withStyles } from ' @material-ui/core/styles' ;
3
+ import Typography from ' @material-ui/core/Typography' ;
4
+ import List from ' @material-ui/core/List' ;
5
+ import ListItem from ' @material-ui/core/ListItem' ;
6
+ import ListItemSecondaryAction from ' @material-ui/core/ListItemSecondaryAction' ;
7
+ import ListItemText from ' @material-ui/core/ListItemText' ;
8
+ import IconButton from ' @material-ui/core/IconButton' ;
9
+ import Grid from ' @material-ui/core/Grid' ;
10
+ import AddIcon from ' @material-ui/icons/Add' ;
11
+ import DeleteIcon from ' @material-ui/icons/Delete' ;
12
+ import Fab from ' @material-ui/core/Fab' ;
13
13
14
- import { openExpansionPanel } from " ../utils/componentReducer.util" ;
14
+ import { openExpansionPanel } from ' ../utils/componentReducer.util' ;
15
15
16
- const LeftColExpansionPanel = props => {
17
- const { classes, focusComponent, component, addChild, changeFocusComponent, selectableChildren } = props ;
16
+ const LeftColExpansionPanel = ( props ) => {
17
+ const {
18
+ classes,
19
+ focusComponent,
20
+ component,
21
+ addChild,
22
+ changeFocusComponent,
23
+ selectableChildren,
24
+ components,
25
+ deleteComponent,
26
+ } = props ;
18
27
const { title, id, color } = component ;
19
28
29
+ // show a string of all direct parents. SO the user can gaze at it.
30
+ const directParents = components
31
+ . filter ( comp => comp . childrenArray . some ( kiddy => kiddy . childComponentId == id ) )
32
+ . map ( comp => comp . title )
33
+ . join ( ',' ) ;
34
+
20
35
function isFocused ( ) {
21
36
return focusComponent . id == id ? 'focused' : '' ;
22
37
}
23
38
24
39
return (
25
- < Grid
26
- container
27
- spacing = { 16 }
28
- direction = "row"
29
- justify = "flex-start"
30
- alignItems = "baseline"
31
- >
40
+ < Grid container spacing = { 16 } direction = "row" justify = "flex-start" alignItems = "baseline" >
32
41
< Grid item xs = { 9 } >
33
42
< div
34
43
className = { classes . root }
35
- style = {
36
- ! isFocused ( ) ? { } : { boxShadow : "0 10px 10px rgba(0,0,0,0.22)" }
37
- }
44
+ style = { ! isFocused ( ) ? { } : { boxShadow : '0 10px 10px rgba(0,0,0,0.22)' } }
38
45
>
39
- < Grid item xs = { 12 } style = { { color : " red" } } >
40
- < List style = { { color : " red" } } >
46
+ < Grid item xs = { 12 } style = { { color : ' red' } } >
47
+ < List style = { { color : ' red' } } >
41
48
< ListItem
42
49
button
43
50
component = "a"
44
- style = { { color : " red" } }
51
+ style = { { color : ' red' } }
45
52
onClick = { ( ) => {
46
53
changeFocusComponent ( { title } ) ;
47
54
} }
@@ -50,7 +57,7 @@ const LeftColExpansionPanel = props => {
50
57
disableTypography
51
58
className = { classes . light }
52
59
primary = {
53
- < Typography type = "body2" style = { { color : color } } >
60
+ < Typography type = "body2" style = { { color } } >
54
61
{ title }
55
62
</ Typography >
56
63
}
@@ -68,21 +75,21 @@ const LeftColExpansionPanel = props => {
68
75
{ directParents ? (
69
76
< p
70
77
style = { {
71
- marginLeft : " 10px" ,
72
- color : " white" ,
73
- fontSize : " 12px" ,
74
- marginTop : " 1px"
78
+ marginLeft : ' 10px' ,
79
+ color : ' white' ,
80
+ fontSize : ' 12px' ,
81
+ marginTop : ' 1px' ,
75
82
} }
76
83
>
77
84
Used in: { directParents }
78
85
</ p >
79
86
) : (
80
87
< p
81
88
style = { {
82
- marginLeft : " 10px" ,
83
- color : " white" ,
84
- fontSize : " 12px" ,
85
- marginTop : " 1px"
89
+ marginLeft : ' 10px' ,
90
+ color : ' white' ,
91
+ fontSize : ' 12px' ,
92
+ marginTop : ' 1px' ,
86
93
} }
87
94
>
88
95
Not used
@@ -96,16 +103,15 @@ const LeftColExpansionPanel = props => {
96
103
aria-label = "Delete"
97
104
className = { classes . margin }
98
105
style = { {
99
- marginLeft : " 10px" ,
100
- marginTop : " 5px" ,
101
- marginBottom : " 10px"
106
+ marginLeft : ' 10px' ,
107
+ marginTop : ' 5px' ,
108
+ marginBottom : ' 10px' ,
102
109
} }
103
110
// style={{ maxWidth: "20px" }}
104
- onClick = { ( ) =>
105
- deleteComponent ( {
106
- componentId : id ,
107
- stateComponents : components
108
- } )
111
+ onClick = { ( ) => deleteComponent ( {
112
+ componentId : id ,
113
+ stateComponents : components ,
114
+ } )
109
115
}
110
116
>
111
117
< DeleteIcon className = { classes . extendedIcon } />
@@ -133,9 +139,9 @@ const LeftColExpansionPanel = props => {
133
139
) : (
134
140
< IconButton aria-label = "Add" >
135
141
< AddIcon
136
- style = { { color, float : " right" } }
142
+ style = { { color, float : ' right' } }
137
143
onClick = { ( ) => {
138
- addChild ( { title, childType : " COMP" } ) ;
144
+ addChild ( { title, childType : ' COMP' } ) ;
139
145
} }
140
146
/>
141
147
< ListItemSecondaryAction >
0 commit comments