Skip to content

Commit 26a08fa

Browse files
committed
new folder modalにcolor select追加
1 parent da9d7a4 commit 26a08fa

5 files changed

Lines changed: 71 additions & 18 deletions

File tree

browser/styles/main/HomeContainer/components/ArticleNavigator.styl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ articleCount = #999
150150
&:hover
151151
background-color transparentify(white, 5%)
152152
&.active, &:active
153-
background-color brandColor
153+
background-color transparentify(lighten(brandColor, 25%), 70%)
154154
.articleCount
155155
color articleCount
156156
font-size 12px

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,37 @@ iptFocusBorderColor = #369DCD
3434
border-radius 5px
3535
border solid 1px borderColor
3636
outline none
37-
margin 100px auto 25px
37+
margin 100px auto 15px
3838
&:focus
3939
border-color iptFocusBorderColor
40+
.colorSelect
41+
text-align center
42+
.option
43+
cursor pointer
44+
.FolderMark
45+
padding 5px
46+
font-size 22px
47+
height 33px
48+
width 33px
49+
overflow hidden
50+
line-height 33px
51+
transition 0.1s
52+
border 1px solid transparent
53+
border-radius 5px
54+
margin 0 2px
55+
&:hover
56+
border-color borderColor
57+
&.active
58+
font-size 28px
59+
border-color iptFocusBorderColor
4060
.alert
4161
color infoTextColor
4262
background-color infoBackgroundColor
4363
font-size 14px
4464
padding 15px 15px
4565
width 330px
4666
border-radius 5px
47-
margin 0 auto
67+
margin 15px auto 0
4868
&.error
4969
color errorTextColor
5070
background-color errorBackgroundColor

lib/components/FolderMark.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,45 +3,50 @@ import React, { PropTypes } from 'react'
33
const BLUE = '#3460C7'
44
const LIGHTBLUE = '#2BA5F7'
55
const ORANGE = '#FF8E00'
6-
const YELLOW = '#EAEF31'
7-
const GREEN = '#02FF26'
8-
const DARKGREEN = '#008A59'
6+
const YELLOW = '#E8D252'
7+
const GREEN = '#3FD941'
8+
const DARKGREEN = '#1FAD85'
99
const RED = '#E10051'
1010
const PURPLE = '#B013A4'
11-
const BRAND_COLOR = '#2BAC8F'
1211

1312
function getColorByIndex (index) {
1413
switch (index % 8) {
1514
case 0:
16-
return LIGHTBLUE
15+
return RED
1716
case 1:
1817
return ORANGE
1918
case 2:
20-
return RED
19+
return YELLOW
2120
case 3:
2221
return GREEN
2322
case 4:
2423
return DARKGREEN
2524
case 5:
26-
return YELLOW
25+
return LIGHTBLUE
2726
case 6:
2827
return BLUE
2928
case 7:
3029
return PURPLE
3130
default:
32-
return BRAND_COLOR
31+
return DARKGREEN
3332
}
3433
}
3534

3635
export default class FolderMark extends React.Component {
3736
render () {
3837
let color = getColorByIndex(this.props.color)
38+
let className = 'FolderMark fa fa-square fa-fw'
39+
if (this.props.className != null) {
40+
className += ' active'
41+
}
42+
3943
return (
40-
<i className='fa fa-square fa-fw' style={{color: color}}/>
44+
<i className={className} style={{color: color}}/>
4145
)
4246
}
4347
}
4448

4549
FolderMark.propTypes = {
46-
color: PropTypes.number
50+
color: PropTypes.number,
51+
className: PropTypes.string
4752
}

lib/components/modal/CreateNewFolder.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,15 @@ import React, { PropTypes } from 'react'
22
import linkState from 'boost/linkState'
33
import { createFolder } from 'boost/actions'
44
import store from 'boost/store'
5+
import FolderMark from 'boost/components/FolderMark'
56

67
export default class CreateNewFolder extends React.Component {
78
constructor (props) {
89
super(props)
910

1011
this.state = {
1112
name: '',
13+
color: Math.round(Math.random() * 7),
1214
alert: null
1315
}
1416
}
@@ -20,9 +22,11 @@ export default class CreateNewFolder extends React.Component {
2022
handleConfirmButton (e) {
2123
this.setState({alert: null}, () => {
2224
let { close } = this.props
23-
let name = this.state.name
25+
let { name, color } = this.state
26+
2427
let input = {
25-
name
28+
name,
29+
color
2630
}
2731

2832
try {
@@ -38,13 +42,36 @@ export default class CreateNewFolder extends React.Component {
3842
})
3943
}
4044

45+
handleColorClick (colorIndex) {
46+
return e => {
47+
this.setState({
48+
color: colorIndex
49+
})
50+
}
51+
}
52+
4153
render () {
4254
let alert = this.state.alert
4355
let alertElement = alert != null ? (
4456
<p className={`alert ${alert.type}`}>
4557
{alert.message}
4658
</p>
4759
) : null
60+
let colorIndexes = []
61+
for (let i = 0; i < 8; i++) {
62+
colorIndexes.push(i)
63+
}
64+
let colorElements = colorIndexes.map(index => {
65+
let className = index === this.state.color
66+
? 'active'
67+
: null
68+
69+
return (
70+
<span className='option' key={index} onClick={e => this.handleColorClick(index)(e)}>
71+
<FolderMark className={className} color={index}/>
72+
</span>
73+
)
74+
})
4875

4976
return (
5077
<div className='CreateNewFolder modal'>
@@ -53,6 +80,9 @@ export default class CreateNewFolder extends React.Component {
5380
<div className='title'>Create new folder</div>
5481

5582
<input className='ipt' type='text' valueLink={this.linkState('name')} placeholder='Enter folder name'/>
83+
<div className='colorSelect'>
84+
{colorElements}
85+
</div>
5686
{alertElement}
5787

5888
<button onClick={e => this.handleConfirmButton(e)} className='confirmBtn'>Create</button>

lib/reducer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ function folders (state = initialFolders, action) {
2626
Object.assign(newFolder, {
2727
key: keygen(),
2828
createdAt: new Date(),
29-
updatedAt: new Date(),
30-
// random number (0-7)
31-
color: Math.round(Math.random() * 7)
29+
updatedAt: new Date()
3230
})
3331

3432
if (newFolder.length === 0) throw new Error('Folder name is required')

0 commit comments

Comments
 (0)