@@ -26,20 +26,38 @@ export default class FolderRow extends React.Component {
2626 handleEditButtonClick ( e ) {
2727 this . setState ( {
2828 mode : EDIT ,
29- name : this . props . folder . name
29+ name : this . props . folder . name ,
30+ color : this . props . folder . color ,
31+ isColorEditing : false
3032 } )
3133 }
3234
3335 handleDeleteButtonClick ( e ) {
3436 this . setState ( { mode : DELETE } )
3537 }
3638
39+ handleColorSelectClick ( e ) {
40+ this . setState ( {
41+ isColorEditing : true
42+ } )
43+ }
44+
45+ handleColorButtonClick ( index ) {
46+ return e => {
47+ this . setState ( {
48+ color : index ,
49+ isColorEditing : false
50+ } )
51+ }
52+ }
53+
3754 handleSaveButtonClick ( e ) {
3855 let { folder, setAlert } = this . props
3956
4057 setAlert ( null , ( ) => {
4158 let input = {
42- name : this . state . name
59+ name : this . state . name ,
60+ color : this . state . color
4361 }
4462 folder = Object . assign ( { } , folder , input )
4563
@@ -68,8 +86,38 @@ export default class FolderRow extends React.Component {
6886
6987 switch ( this . state . mode ) {
7088 case EDIT :
89+ let colorIndexes = [ ]
90+ for ( let i = 0 ; i < 8 ; i ++ ) {
91+ colorIndexes . push ( i )
92+ }
93+
94+ let colorOptions = colorIndexes . map ( index => {
95+ let className = this . state . color === index
96+ ? 'active'
97+ : null
98+ return (
99+ < button onClick = { e => this . handleColorButtonClick ( index ) ( e ) } className = { className } key = { index } >
100+ < FolderMark color = { index } />
101+ </ button >
102+ )
103+ } )
104+
71105 return (
72106 < div className = 'FolderRow edit' >
107+ < div className = 'folderColor' >
108+ < button onClick = { e => this . handleColorSelectClick ( e ) } className = 'select' >
109+ < FolderMark color = { this . state . color } />
110+ </ button >
111+ { this . state . isColorEditing
112+ ? (
113+ < div className = 'options' >
114+ < div className = 'label' > Color select</ div >
115+ { colorOptions }
116+ </ div >
117+ )
118+ : null
119+ }
120+ </ div >
73121 < div className = 'folderName' >
74122 < input valueLink = { this . linkState ( 'name' ) } type = 'text' />
75123 </ div >
@@ -93,7 +141,8 @@ export default class FolderRow extends React.Component {
93141 default :
94142 return (
95143 < div className = 'FolderRow' >
96- < div className = 'folderName' > < FolderMark color = { folder . color } /> { folder . name } </ div >
144+ < div className = 'folderColor' > < FolderMark color = { folder . color } /> </ div >
145+ < div className = 'folderName' > { folder . name } </ div >
97146 < div className = 'folderControl' >
98147 < button onClick = { e => this . handleEditButtonClick ( e ) } > < i className = 'fa fa-fw fa-edit' /> </ button >
99148 < button onClick = { e => this . handleDeleteButtonClick ( e ) } > < i className = 'fa fa-fw fa-close' /> </ button >
0 commit comments