Skip to content

Commit ff1bffb

Browse files
committed
Preferenceからもフォルダーの色の選択ができる。
1 parent b28b18a commit ff1bffb

4 files changed

Lines changed: 107 additions & 20 deletions

File tree

browser/styles/main/HomeContainer/lib/Preferences.styl

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -440,15 +440,15 @@ iptFocusBorderColor = #369DCD
440440
padding 5px 0
441441
&:last-child
442442
border-color transparent
443+
.folderColor
444+
float left
445+
margin-left 10px
446+
text-align center
447+
width 44px
443448
.folderName
444449
float left
445450
width 175px
446451
overflow ellipsis
447-
padding-left 15px
448-
.folderPublic
449-
float left
450-
text-align center
451-
width 100px
452452
.folderControl
453453
float right
454454
width 145px
@@ -512,16 +512,52 @@ iptFocusBorderColor = #369DCD
512512
width 150px
513513
&:focus
514514
border-color iptFocusBorderColor
515-
.folderPublic select
516-
height 33px
517-
border 1px solid borderColor
518-
background-color white
519-
outline none
520-
display block
521-
margin 0 auto
522-
font-size 14px
523-
&:focus
524-
border-color iptFocusBorderColor
515+
.folderColor
516+
.select
517+
height 33px
518+
width 33px
519+
border 1px solid borderColor
520+
background-color white
521+
outline none
522+
display block
523+
margin 0 auto
524+
font-size 14px
525+
border-radius 5px
526+
&:focus
527+
border-color iptFocusBorderColor
528+
.options
529+
position absolute
530+
background-color white
531+
text-align left
532+
border 1px solid borderColor
533+
border-radius 5px
534+
padding 0 5px 5px
535+
margin-left 5px
536+
margin-top -34px
537+
clearfix()
538+
.label
539+
margin-left 5px
540+
line-height 22px
541+
font-size 12px
542+
button
543+
float left
544+
border none
545+
width 33px
546+
height 33px
547+
margin-right 5px
548+
border 1px solid transparent
549+
line-height 29px
550+
overflow hidden
551+
border-radius 5px
552+
background-color transparent
553+
outline none
554+
transition 0.1s
555+
&:hover
556+
border-color borderColor
557+
&.active
558+
.FolderMark
559+
transform scale(1.4)
560+
border-color iptFocusBorderColor
525561
.folderControl
526562
button
527563
border none

lib/components/modal/Preference/FolderRow.js

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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>

lib/components/modal/Preference/FolderSettingTab.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export default class FolderSettingTab extends React.Component {
5959
<div className='sectionTitle'>Manage folder</div>
6060
<div className='folderTable'>
6161
<div className='folderHeader'>
62-
<div className='folderName'>Folder name</div>
62+
<div className='folderColor'></div>
63+
<div className='folderName'>Folder</div>
6364
<div className='folderControl'>Edit/Delete</div>
6465
</div>
6566
{folderElements}

lib/reducer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ function folders (state = initialFolders, action) {
4747

4848
if (!_.isString(folder.name)) throw new Error('Folder name must be a string')
4949
folder.name = folder.name.trim().replace(/\s/, '_')
50-
if (folder.length === 0) throw new Error('Folder name is required')
50+
if (folder.name.length === 0) throw new Error('Folder name is required')
51+
if (folder.name.match(/\//)) throw new Error('`/` is not available for folder name')
5152

5253
// Folder existence check
5354
if (targetFolder == null) throw new Error('Folder doesnt exist')

0 commit comments

Comments
 (0)