diff --git a/browser/styles/main/HomeContainer/lib/Preferences.styl b/browser/styles/main/HomeContainer/lib/Preferences.styl index 79fe0e56..104948d8 100644 --- a/browser/styles/main/HomeContainer/lib/Preferences.styl +++ b/browser/styles/main/HomeContainer/lib/Preferences.styl @@ -440,15 +440,15 @@ iptFocusBorderColor = #369DCD padding 5px 0 &:last-child border-color transparent + .folderColor + float left + margin-left 10px + text-align center + width 44px .folderName float left width 175px overflow ellipsis - padding-left 15px - .folderPublic - float left - text-align center - width 100px .folderControl float right width 145px @@ -512,16 +512,52 @@ iptFocusBorderColor = #369DCD width 150px &:focus border-color iptFocusBorderColor - .folderPublic select - height 33px - border 1px solid borderColor - background-color white - outline none - display block - margin 0 auto - font-size 14px - &:focus - border-color iptFocusBorderColor + .folderColor + .select + height 33px + width 33px + border 1px solid borderColor + background-color white + outline none + display block + margin 0 auto + 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 button border none diff --git a/lib/components/modal/Preference/FolderRow.js b/lib/components/modal/Preference/FolderRow.js index 336a0d6c..d19388d5 100644 --- a/lib/components/modal/Preference/FolderRow.js +++ b/lib/components/modal/Preference/FolderRow.js @@ -26,7 +26,9 @@ export default class FolderRow extends React.Component { handleEditButtonClick (e) { this.setState({ 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}) } + handleColorSelectClick (e) { + this.setState({ + isColorEditing: true + }) + } + + handleColorButtonClick (index) { + return e => { + this.setState({ + color: index, + isColorEditing: false + }) + } + } + handleSaveButtonClick (e) { let { folder, setAlert } = this.props setAlert(null, () => { let input = { - name: this.state.name + name: this.state.name, + color: this.state.color } folder = Object.assign({}, folder, input) @@ -68,8 +86,38 @@ export default class FolderRow extends React.Component { switch (this.state.mode) { 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 ( + + ) + }) + return (
+
+ + {this.state.isColorEditing + ? ( +
+
Color select
+ {colorOptions} +
+ ) + : null + } +
@@ -93,7 +141,8 @@ export default class FolderRow extends React.Component { default: return (
-
{folder.name}
+
+
{folder.name}
diff --git a/lib/components/modal/Preference/FolderSettingTab.js b/lib/components/modal/Preference/FolderSettingTab.js index ff1e8229..b75e368a 100644 --- a/lib/components/modal/Preference/FolderSettingTab.js +++ b/lib/components/modal/Preference/FolderSettingTab.js @@ -59,7 +59,8 @@ export default class FolderSettingTab extends React.Component {
Manage folder
-
Folder name
+
+
Folder
Edit/Delete
{folderElements} diff --git a/lib/reducer.js b/lib/reducer.js index 5b234722..cba759ce 100644 --- a/lib/reducer.js +++ b/lib/reducer.js @@ -47,7 +47,8 @@ function folders (state = initialFolders, action) { if (!_.isString(folder.name)) throw new Error('Folder name must be a string') 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 if (targetFolder == null) throw new Error('Folder doesnt exist')