@@ -36,6 +36,10 @@ const LeftColExpansionPanel = (props: any) => {
36
36
return focusComponent . id === id ? 'focused' : '' ;
37
37
}
38
38
39
+ // boolean flag to determine if the component card is focused or not
40
+ // state/class toggles will be displayed when a component is focused
41
+ const focusedToggle = isFocused ( ) === 'focused' ? true : false ;
42
+
39
43
return (
40
44
< Grid
41
45
container
@@ -48,7 +52,8 @@ const LeftColExpansionPanel = (props: any) => {
48
52
< div
49
53
className = { classes . root }
50
54
style = {
51
- ! isFocused ( ) ? { } : { boxShadow : '0 10px 10px rgba(0,0,0,0.25)' }
55
+ // shadow to highlight the focused component card
56
+ focusedToggle ? { boxShadow : '4px 4px 4px rgba(0, 0, 0, .4)' } : { }
52
57
}
53
58
>
54
59
< Grid item xs = { 12 } style = { { color : 'red' , backgroundColor : color } } >
@@ -75,40 +80,16 @@ const LeftColExpansionPanel = (props: any) => {
75
80
>
76
81
{ title }
77
82
</ Typography >
78
- { /* TOGGLE FOR STATEFULNESS */ }
79
- < InputLabel
80
- htmlFor = 'stateful'
81
- style = { {
82
- color : '#fff' ,
83
- marginBottom : '10px' ,
84
- marginTop : '0px' ,
85
- marginLeft : '11px' ,
86
- padding : '0px' ,
87
- fontSize : '18px'
88
- } }
89
- >
90
- State?
91
- </ InputLabel >
92
- { /*
93
- Have to change focus component after toggling state
94
- in order to properly change the code that appears in the code
95
- peview
83
+
84
+ { /* ALL OF THE STATE/CLASS TOGGLES AND LABELS ARE ONLY RENDERED IF THEIR COMPONENT IS THE FOCUSED COMPONENT
85
+
86
+ TO DO : IMPROVE DRYNESS OF CODE BY RENDERING ALL FOUR MATERIAL ELEMENTS (LABELS/SWITCH) IN ONE CONDITIONAL
96
87
*/ }
97
- < Switch
98
- checked = { stateful }
99
- onChange = { e => {
100
- toggleComponentState ( id ) ;
101
- changeFocusComponent ( title ) ;
102
- } }
103
- value = 'stateful'
104
- color = 'primary'
105
- id = { props . id . toString ( ) }
106
- // id={props.index.toString()}
107
- />
108
- < div >
109
- { /* TOGGLE FOR CLASS BASED */ }
88
+
89
+ { /* LABEL AND TOGGLE(SWITCH) FOR STATEFULNESS */ }
90
+ { focusedToggle ? (
110
91
< InputLabel
111
- htmlFor = 'classBased '
92
+ htmlFor = 'stateful '
112
93
style = { {
113
94
color : '#fff' ,
114
95
marginBottom : '10px' ,
@@ -118,17 +99,58 @@ const LeftColExpansionPanel = (props: any) => {
118
99
fontSize : '18px'
119
100
} }
120
101
>
121
- Class ?
102
+ State ?
122
103
</ InputLabel >
104
+ ) : (
105
+ ''
106
+ ) }
107
+
108
+ { focusedToggle ? (
123
109
< Switch
124
- checked = { classBased }
110
+ checked = { stateful }
125
111
onChange = { e => {
126
- toggleComponentClass ( id ) ;
112
+ toggleComponentState ( id ) ;
127
113
changeFocusComponent ( title ) ;
128
114
} }
129
- value = 'classBased '
115
+ value = 'stateful '
130
116
color = 'primary'
117
+ id = { props . id . toString ( ) }
131
118
/>
119
+ ) : (
120
+ ''
121
+ ) }
122
+ < div >
123
+ { /* LABEL/TOGGLE(SWITCH) FOR CLASS BASED */ }
124
+ { focusedToggle ? (
125
+ < InputLabel
126
+ htmlFor = 'classBased'
127
+ style = { {
128
+ color : '#fff' ,
129
+ marginBottom : '10px' ,
130
+ marginTop : '0px' ,
131
+ marginLeft : '11px' ,
132
+ padding : '0px' ,
133
+ fontSize : '18px'
134
+ } }
135
+ >
136
+ Class?
137
+ </ InputLabel >
138
+ ) : (
139
+ ''
140
+ ) }
141
+ { focusedToggle ? (
142
+ < Switch
143
+ checked = { classBased }
144
+ onChange = { e => {
145
+ toggleComponentClass ( id ) ;
146
+ changeFocusComponent ( title ) ;
147
+ } }
148
+ value = 'classBased'
149
+ color = 'primary'
150
+ />
151
+ ) : (
152
+ ''
153
+ ) }
132
154
</ div >
133
155
</ div >
134
156
}
0 commit comments