@@ -7,32 +7,108 @@ import IconButton from '@material-ui/core/IconButton';
77import TreeItem from '@material-ui/lab/TreeItem' ;
88import Visibility from '@material-ui/icons/Visibility' ;
99import VisibilityOff from '@material-ui/icons/VisibilityOff' ;
10- import ColorLens from '@material-ui/icons/ColorLens' ;
11- import Shuffle from '@material-ui/icons/Shuffle' ;
1210import { ChromePicker } from 'react-color' ;
1311import { useDispatch , useSelector } from 'react-redux' ;
14- import { experimentLabelColor } from '../../theme' ;
15- import { changeInstanceColor , selectInstances } from '../../redux/actions/general' ;
12+ import {
13+ experimentLabelColor ,
14+ bgDarker ,
15+ bgLight ,
16+ radius ,
17+ } from '../../theme' ;
18+ import {
19+ RandomColorLensIcon ,
20+ ColorLensIcon ,
21+ TriangleIcon ,
22+ } from './NetPyNEIcons' ;
23+ import { changeInstanceColor } from '../../redux/actions/general' ;
1624
1725const useStyles = makeStyles ( ( theme ) => ( {
18- networkItem : {
19- paddingTop : '2px' ,
20- paddingBottom : '2px' ,
26+ treeItem : {
27+ '& .MuiTreeItem-iconContainer' : {
28+ marginRight : '5px' ,
29+ } ,
30+ '& .MuiTreeItem-label' : {
31+ paddingTop : '2px' ,
32+ paddingBottom : '2px' ,
33+ paddingRight : '8px' ,
34+ borderRadius : radius ,
35+ '&:hover' : {
36+ backgroundColor : '#333333' ,
37+ } ,
38+ } ,
39+ } ,
40+ leafTreeItem : {
41+ '& .MuiTreeItem-iconContainer' : {
42+ width : 0 ,
43+ } ,
2144 } ,
2245 controls : {
2346 '& .MuiIconButton-root' : {
24- padding : 0 ,
47+ padding : '0 !important' ,
2548 marginLeft : '0.5rem' ,
2649 color : experimentLabelColor ,
2750 '&:hover' : {
2851 color : 'white' ,
2952 } ,
3053 } ,
3154 } ,
55+ colorPickerBox : {
56+ position : 'absolute' ,
57+ top : '1.6rem' ,
58+ right : '2.7rem' ,
59+ height : '3rem' ,
60+ } ,
61+ triangleIcon : {
62+ marginBottom : '-7px' ,
63+ color : bgDarker ,
64+ } ,
3265 colorPicker : {
3366 position : 'absolute' ,
3467 zIndex : 1000 ,
3568 right : 0 ,
69+ backgroundColor : `${ bgDarker } !important` ,
70+ padding : '0.2rem' ,
71+ '& label' : {
72+ color : '#ffffff !important' ,
73+ fontFamily : 'Roboto, arial' ,
74+ fontSize : '11px' ,
75+ fontWeight : 400 ,
76+ } ,
77+ '& input' : {
78+ backgroundColor : `${ bgLight } !important` ,
79+ color : '#ffffff !important' ,
80+ boxShadow : 'none !important' ,
81+ fontFamily : 'Roboto, arial' ,
82+ fontSize : '11px' ,
83+ fontWeight : 400 ,
84+ } ,
85+ '& svg' : {
86+ fill : '#ffffff !important' ,
87+ } ,
88+ '& svg:hover' : {
89+ background : 'transparent !important' ,
90+ } ,
91+ '& .hue-horizontal' : {
92+ borderRadius : '10px' ,
93+ } ,
94+ '& :nth-child(2)' : {
95+ '& :nth-child(1)' : {
96+ '& :nth-child(2)' : {
97+ '& :nth-child(2)' : {
98+ '& :nth-child(1)' : {
99+ '& :nth-child(2)' : {
100+ borderRadius : '10px' ,
101+ } ,
102+ } ,
103+ } ,
104+ } ,
105+ } ,
106+ } ,
107+ } ,
108+ activeColorPicker : {
109+ '& path' : {
110+ fill : '#ffffff' ,
111+ } ,
36112 } ,
37113} ) ) ;
38114
@@ -60,6 +136,8 @@ const ControlPanelTreeItem = (props) => {
60136 } ) ;
61137 dispatch ( changeInstanceColor ( newInstances ) ) ;
62138 setColor ( _color . rgb ) ;
139+ event . stopPropagation ( ) ;
140+ event . preventDefault ( ) ;
63141 } ;
64142
65143 const getRandomColor = ( ) => ( {
@@ -70,6 +148,8 @@ const ControlPanelTreeItem = (props) => {
70148 } ) ;
71149
72150 const generateRandomColor = ( event , nodeId ) => {
151+ event . stopPropagation ( ) ;
152+ event . preventDefault ( ) ;
73153 const children = window . Instances . getInstance ( nodeId ) . getChildren ( ) . map ( ( instance ) => instance . getInstancePath ( ) ) ;
74154 // const newInstances = instances.filter((instance) => !(instance.instancePath.startsWith(nodeId)));
75155 const newInstances = instances . filter ( ( instance ) => {
@@ -98,6 +178,8 @@ const ControlPanelTreeItem = (props) => {
98178 } ;
99179
100180 const changeVisibility = ( event , nodeId ) => {
181+ event . stopPropagation ( ) ;
182+ event . preventDefault ( ) ;
101183 const copiedInstances = instances . slice ( ) ;
102184 let oldIndex = null ;
103185 let oldInstance = copiedInstances . find ( ( pInstance , index ) => {
@@ -145,51 +227,71 @@ const ControlPanelTreeItem = (props) => {
145227
146228 return (
147229 < TreeItem
230+ className = { `${ classes . treeItem } ${ children ?. length === 0 ? classes . leafTreeItem : '' } ` }
148231 nodeId = { nodeId }
149- onLabelClick = { ( e ) => { e . stopPropagation ( ) ; e . preventDefault ( ) ; } }
150232 label = { (
151233 < Grid
152234 container
153- className = { classes . networkItem }
154- onMouseEnter = { ( ) => setIsHoveredOver ( true ) }
155- onMouseLeave = { ( ) => setIsHoveredOver ( false ) }
235+ onMouseEnter = { ( ) => setTimeout ( setIsHoveredOver ( true ) , 10000 ) }
236+ onMouseLeave = { ( ) => setTimeout ( setIsHoveredOver ( false ) , 10000 ) }
156237 display = "flex"
157238 flexDirection = "row"
158239 justifyContent = "space-between"
159240 >
160- < Grid item xs = { 4 } > < Typography onClick = { ( ) => onNodeSelect ( nodeId ) } > { label } </ Typography > </ Grid >
241+
242+ < Grid item xs = { 4 } >
243+ < Typography onClick = { ( event ) => {
244+ onNodeSelect ( nodeId ) ;
245+ event . stopPropagation ( ) ;
246+ event . preventDefault ( ) ;
247+ } }
248+ >
249+ { label }
250+ </ Typography >
251+ </ Grid >
161252 < Grid item xs = { 4 } justifyContent = "center" > < Typography > { type } </ Typography > </ Grid >
162253 < Grid item xs = { 4 } justifyContent = "flex-end" className = { classes . controls } >
163254 { isHoveredOver
164255 ? (
165256 < >
166-
167257 < IconButton onClick = { ( event ) => changeVisibility ( event , nodeId ) } >
168- { visibility ? < Visibility /> : < VisibilityOff /> }
258+ { visibility ? < Visibility style = { { marginRight : '0.5rem' } } /> : < VisibilityOff style = { { marginRight : '0.5rem' } } /> }
259+ </ IconButton >
260+ < IconButton onClick = { ( event ) => {
261+ event . stopPropagation ( ) ;
262+ event . preventDefault ( ) ;
263+ setShowColorPicker ( true ) ;
264+ } }
265+ >
266+ < ColorLensIcon className = { showColorPicker ? classes . activeColorPicker : '' } />
267+ </ IconButton >
268+ < IconButton disabled = { disableRandom } onClick = { ( event ) => generateRandomColor ( event , nodeId ) } >
269+ < RandomColorLensIcon />
169270 </ IconButton >
170- < IconButton disabled = { disableRandom } onClick = { ( event ) => generateRandomColor ( event , nodeId ) } > < Shuffle /> </ IconButton >
171- < IconButton onClick = { ( ) => setShowColorPicker ( true ) } > < ColorLens /> </ IconButton >
172271 {
173272 showColorPicker
174273 ? (
175274 < Box
176- onMouseLeave = { ( ) => setShowColorPicker ( false ) }
275+ className = { classes . colorPickerBox }
276+ onMouseLeave = { ( ) => setTimeout ( setShowColorPicker ( false ) , 30000 ) }
177277 >
278+ { /* <TriangleIcon className={classes.triangleIcon} /> */ }
178279 < ChromePicker
179280 className = { classes . colorPicker }
180281 color = { color }
181- onChangeComplete = { ( color , event ) => handleColorSelection ( color , event , nodeId ) }
282+ onChangeComplete = { ( color , event ) => {
283+ handleColorSelection ( color , event , nodeId ) ;
284+ } }
182285 />
183286 </ Box >
184287 ) : null
185288 }
186-
187289 </ >
188290 )
189291 : null }
190292 </ Grid >
191293 </ Grid >
192- ) }
294+ ) }
193295 >
194296 { children }
195297 </ TreeItem >
0 commit comments