1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00

Preferenceからもフォルダーの色の選択ができる。

This commit is contained in:
Rokt33r
2015-11-16 01:22:22 +09:00
parent b28b18a19a
commit ff1bffbb55
4 changed files with 107 additions and 20 deletions

View File

@@ -440,15 +440,15 @@ iptFocusBorderColor = #369DCD
padding 5px 0 padding 5px 0
&:last-child &:last-child
border-color transparent border-color transparent
.folderColor
float left
margin-left 10px
text-align center
width 44px
.folderName .folderName
float left float left
width 175px width 175px
overflow ellipsis overflow ellipsis
padding-left 15px
.folderPublic
float left
text-align center
width 100px
.folderControl .folderControl
float right float right
width 145px width 145px
@@ -512,16 +512,52 @@ iptFocusBorderColor = #369DCD
width 150px width 150px
&:focus &:focus
border-color iptFocusBorderColor border-color iptFocusBorderColor
.folderPublic select .folderColor
height 33px .select
border 1px solid borderColor height 33px
background-color white width 33px
outline none border 1px solid borderColor
display block background-color white
margin 0 auto outline none
font-size 14px display block
&:focus margin 0 auto
border-color iptFocusBorderColor font-size 14px
border-radius 5px
&:focus
border-color iptFocusBorderColor
.options
position absolute
background-color white
text-align left
border 1px solid borderColor
border-radius 5px
padding 0 5px 5px
margin-left 5px
margin-top -34px
clearfix()
.label
margin-left 5px
line-height 22px
font-size 12px
button
float left
border none
width 33px
height 33px
margin-right 5px
border 1px solid transparent
line-height 29px
overflow hidden
border-radius 5px
background-color transparent
outline none
transition 0.1s
&:hover
border-color borderColor
&.active
.FolderMark
transform scale(1.4)
border-color iptFocusBorderColor
.folderControl .folderControl
button button
border none border none

View File

@@ -26,7 +26,9 @@ export default class FolderRow extends React.Component {
handleEditButtonClick (e) { handleEditButtonClick (e) {
this.setState({ this.setState({
mode: EDIT, mode: EDIT,
name: this.props.folder.name name: this.props.folder.name,
color: this.props.folder.color,
isColorEditing: false
}) })
} }
@@ -34,12 +36,28 @@ export default class FolderRow extends React.Component {
this.setState({mode: DELETE}) this.setState({mode: DELETE})
} }
handleColorSelectClick (e) {
this.setState({
isColorEditing: true
})
}
handleColorButtonClick (index) {
return e => {
this.setState({
color: index,
isColorEditing: false
})
}
}
handleSaveButtonClick (e) { handleSaveButtonClick (e) {
let { folder, setAlert } = this.props let { folder, setAlert } = this.props
setAlert(null, () => { setAlert(null, () => {
let input = { let input = {
name: this.state.name name: this.state.name,
color: this.state.color
} }
folder = Object.assign({}, folder, input) folder = Object.assign({}, folder, input)
@@ -68,8 +86,38 @@ export default class FolderRow extends React.Component {
switch (this.state.mode) { switch (this.state.mode) {
case EDIT: case EDIT:
let colorIndexes = []
for (let i = 0; i < 8; i++) {
colorIndexes.push(i)
}
let colorOptions = colorIndexes.map(index => {
let className = this.state.color === index
? 'active'
: null
return (
<button onClick={e => this.handleColorButtonClick(index)(e)} className={className} key={index}>
<FolderMark color={index}/>
</button>
)
})
return ( return (
<div className='FolderRow edit'> <div className='FolderRow edit'>
<div className='folderColor'>
<button onClick={e => this.handleColorSelectClick(e)} className='select'>
<FolderMark color={this.state.color}/>
</button>
{this.state.isColorEditing
? (
<div className='options'>
<div className='label'>Color select</div>
{colorOptions}
</div>
)
: null
}
</div>
<div className='folderName'> <div className='folderName'>
<input valueLink={this.linkState('name')} type='text'/> <input valueLink={this.linkState('name')} type='text'/>
</div> </div>
@@ -93,7 +141,8 @@ export default class FolderRow extends React.Component {
default: default:
return ( return (
<div className='FolderRow'> <div className='FolderRow'>
<div className='folderName'><FolderMark color={folder.color}/> {folder.name}</div> <div className='folderColor'><FolderMark color={folder.color}/></div>
<div className='folderName'>{folder.name}</div>
<div className='folderControl'> <div className='folderControl'>
<button onClick={e => this.handleEditButtonClick(e)}><i className='fa fa-fw fa-edit'/></button> <button onClick={e => this.handleEditButtonClick(e)}><i className='fa fa-fw fa-edit'/></button>
<button onClick={e => this.handleDeleteButtonClick(e)}><i className='fa fa-fw fa-close'/></button> <button onClick={e => this.handleDeleteButtonClick(e)}><i className='fa fa-fw fa-close'/></button>

View File

@@ -59,7 +59,8 @@ export default class FolderSettingTab extends React.Component {
<div className='sectionTitle'>Manage folder</div> <div className='sectionTitle'>Manage folder</div>
<div className='folderTable'> <div className='folderTable'>
<div className='folderHeader'> <div className='folderHeader'>
<div className='folderName'>Folder name</div> <div className='folderColor'></div>
<div className='folderName'>Folder</div>
<div className='folderControl'>Edit/Delete</div> <div className='folderControl'>Edit/Delete</div>
</div> </div>
{folderElements} {folderElements}

View File

@@ -47,7 +47,8 @@ function folders (state = initialFolders, action) {
if (!_.isString(folder.name)) throw new Error('Folder name must be a string') if (!_.isString(folder.name)) throw new Error('Folder name must be a string')
folder.name = folder.name.trim().replace(/\s/, '_') folder.name = folder.name.trim().replace(/\s/, '_')
if (folder.length === 0) throw new Error('Folder name is required') if (folder.name.length === 0) throw new Error('Folder name is required')
if (folder.name.match(/\//)) throw new Error('`/` is not available for folder name')
// Folder existence check // Folder existence check
if (targetFolder == null) throw new Error('Folder doesnt exist') if (targetFolder == null) throw new Error('Folder doesnt exist')