@@ -38,8 +38,22 @@ const Header = ({
3838 const [ showPopup , setShowPopup ] = useState ( false ) ;
3939 const [ selectedColor , setSelectedColor ] = useState ( null ) ;
4040
41- // const controls = { technique: [RiEyeLine]}
42- const controls = { technique : [ RiEyeLine , RiPaletteLine ] } ;
41+ const controls = {
42+ technique : [
43+ { icon : RiEyeLine , name : 'RiEyeLine' } ,
44+ { icon : RiPaletteLine , name : 'RiPaletteLine' } ,
45+ ] ,
46+ } ;
47+
48+ const toggleHide = ( iconName ) => {
49+ if ( iconName === 'RiEyeLine' ) {
50+ const newValue = ! hide ;
51+ setHide ( newValue ) ;
52+ onHideClick ( newValue ) ;
53+ } else if ( iconName === 'RiPaletteLine' ) {
54+ setShowPopup ( ! showPopup ) ;
55+ }
56+ } ;
4357
4458 useEffect ( ( ) => setIsToggled ( editStatus ) , [ editStatus ] ) ;
4559 useEffect ( ( ) => setHide ( hideStatus ) , [ hideStatus ] ) ;
@@ -55,19 +69,6 @@ const Header = ({
5569 onHideToggle ( value ) ;
5670 } , [ onHideToggle ] ) ;
5771
58- const toggleHide = ( iconName ) => {
59- console . log ( 'inside toggleHide' , iconName )
60- if ( iconName === 'RiEyeLine' ) {
61- console . log ( 'inside if' )
62- const newValue = ! hide ;
63- setHide ( newValue ) ;
64- onHideClick ( newValue ) ;
65- } else if ( iconName === 'RiPaletteLine' ) {
66- console . log ( 'inside else' )
67- setShowPopup ( ! showPopup ) ;
68- }
69- } ;
70-
7172 const toggleViewContent = ( ) => {
7273 const newValue = ! viewCustomContent ;
7374 setViewCustomContent ( newValue ) ;
@@ -80,6 +81,7 @@ const Header = ({
8081
8182 const handleColorClick = ( color ) => {
8283 onColorClick ( color ) ;
84+ setSelectedColor ( color )
8385 }
8486
8587 const handleBackClick = ( ) => {
@@ -142,20 +144,19 @@ const Header = ({
142144 // Aqua / Cyan / Teal
143145 '#00CED1' , '#20B2AA' , '#40E0D0' , '#5F9EA0'
144146 ] ;
145-
147+
146148 return (
147149 showPopup && (
148150 < div className = "popup" >
149151 < div className = "color-grid" >
150152 { colors . map ( ( color , index ) => (
151- < div key = { index } className = "color-square" style = { { backgroundColor : color } } onClick = { ( ) => handleColorClick ( color ) } />
153+ < div key = { index } className = "color-square" style = { { backgroundColor : color , border : color === selectedColor ? '2px solid white' : 'none' , } } onClick = { ( ) => handleColorClick ( color ) } />
152154 ) ) }
153155 </ div >
154156 </ div >
155157 )
156158 ) ;
157159 } ;
158-
159160
160161 return (
161162 < header >
@@ -169,7 +170,7 @@ const Header = ({
169170 < div className = "header-controls" >
170171 < button className = "header-button" onClick = { handleAddClick } >
171172 < RiAddCircleLine style = { { fontSize : '30px' } } />
172- Add Technique
173+ Add Technique
173174 </ button >
174175
175176 < button className = "header-button" onClick = { handleImportClick } >
@@ -179,8 +180,8 @@ const Header = ({
179180
180181 < div style = { { position : 'relative' } } >
181182 < button className = "header-button" onClick = { ( ) => setActiveControl ( ! activeControl ) } >
182- < RiSettings5Fill style = { { fontSize : '30px' } } /> Technique Controls
183-
183+ < RiSettings5Fill style = { { fontSize : '30px' } } /> Technique Controls
184+
184185 </ button >
185186 { activeControl && (
186187 < div style = { {
@@ -191,8 +192,12 @@ const Header = ({
191192 gap : "10px" ,
192193 zIndex : 10 ,
193194 } } >
194- { controls . technique . map ( ( Icon , idx ) => (
195- < Icon key = { idx } style = { { fontSize : '24px' , color : 'white' } } onClick = { ( ) => { toggleHide ( Icon . name ) } } />
195+ { controls . technique . map ( ( control , idx ) => (
196+ < control . icon
197+ key = { idx }
198+ style = { { fontSize : '24px' , color : 'white' } }
199+ onClick = { ( ) => toggleHide ( control . name ) }
200+ />
196201 ) ) }
197202 </ div >
198203 ) }
@@ -239,7 +244,7 @@ const Header = ({
239244 ) }
240245
241246 < button className = "header-button" onClick = { ( ) => toggleControl ( 'selection' ) } >
242- < RiFilterFill style = { { fontSize : '30px' } } />
247+ < RiFilterFill style = { { fontSize : '30px' } } />
243248 Filter By
244249 </ button >
245250 </ div >
@@ -260,7 +265,7 @@ const Header = ({
260265 </ div >
261266 ) }
262267
263- < ColorPopup showPopup = { showPopup } togglePopup = { ( ) => setShowPopup ( ! showPopup ) } />
268+ < ColorPopup showPopup = { showPopup } togglePopup = { ( ) => setShowPopup ( ! showPopup ) } />
264269 </ header >
265270 ) ;
266271} ;
0 commit comments