Skip to content

Commit 6367be2

Browse files
committed
rename config.tag to config.coloredTags
1 parent 3e645db commit 6367be2

File tree

9 files changed

+37
-33
lines changed

9 files changed

+37
-33
lines changed

browser/components/ColorPicker.styl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
height 1.6em
1818
border 1px solid #888888
1919
background-color #fff
20-
font-size 16px
21-
border-radius 4px
20+
font-size 15px
21+
border-radius 2px
2222
.btn-confirm
23-
background-color $ui-button-default--active-backgroundColor
23+
background-color #1EC38B
2424

2525

browser/components/NoteItem.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import i18n from 'browser/lib/i18n'
1313
/**
1414
* @description Tag element component.
1515
* @param {string} tagName
16+
* @param {string} color
1617
* @return {React.Component}
1718
*/
1819
const TagElement = ({ tagName, color }) => (
@@ -25,17 +26,18 @@ const TagElement = ({ tagName, color }) => (
2526
* @description Tag element list component.
2627
* @param {Array|null} tags
2728
* @param {boolean} showTagsAlphabetically
29+
* @param {Object} coloredTags
2830
* @return {React.Component}
2931
*/
30-
const TagElementList = (tags, showTagsAlphabetically, tagConfig) => {
32+
const TagElementList = (tags, showTagsAlphabetically, coloredTags) => {
3133
if (!isArray(tags)) {
3234
return []
3335
}
3436

3537
if (showTagsAlphabetically) {
3638
return _.sortBy(tags).map(tag => TagElement({ tagName: tag }))
3739
} else {
38-
return tags.map(tag => TagElement({ tagName: tag, color: tagConfig[tag] }))
40+
return tags.map(tag => TagElement({ tagName: tag, color: coloredTags[tag] }))
3941
}
4042
}
4143

@@ -46,6 +48,7 @@ const TagElementList = (tags, showTagsAlphabetically, tagConfig) => {
4648
* @param {Function} handleNoteClick
4749
* @param {Function} handleNoteContextMenu
4850
* @param {Function} handleDragStart
51+
* @param {Object} coloredTags
4952
* @param {string} dateDisplay
5053
*/
5154
const NoteItem = ({
@@ -60,7 +63,7 @@ const NoteItem = ({
6063
folderName,
6164
viewType,
6265
showTagsAlphabetically,
63-
tagConfig
66+
coloredTags
6467
}) => (
6568
<div
6669
styleName={isActive ? 'item--active' : 'item'}
@@ -98,7 +101,7 @@ const NoteItem = ({
98101
<div styleName='item-bottom'>
99102
<div styleName='item-bottom-tagList'>
100103
{note.tags.length > 0
101-
? TagElementList(note.tags, showTagsAlphabetically, tagConfig)
104+
? TagElementList(note.tags, showTagsAlphabetically, coloredTags)
102105
: <span
103106
style={{ fontStyle: 'italic', opacity: 0.5 }}
104107
styleName='item-bottom-tagList-empty'
@@ -128,7 +131,7 @@ const NoteItem = ({
128131
NoteItem.propTypes = {
129132
isActive: PropTypes.bool.isRequired,
130133
dateDisplay: PropTypes.string.isRequired,
131-
tagConfig: PropTypes.object,
134+
coloredTags: PropTypes.object,
132135
note: PropTypes.shape({
133136
storage: PropTypes.string.isRequired,
134137
key: PropTypes.string.isRequired,

browser/main/Detail/MarkdownNoteDetail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ class MarkdownNoteDetail extends React.Component {
437437
showTagsAlphabetically={config.ui.showTagsAlphabetically}
438438
data={data}
439439
onChange={this.handleUpdateTag.bind(this)}
440-
tagConfig={config.tag}
440+
coloredTags={config.coloredTags}
441441
/>
442442
<TodoListPercentage onClearCheckboxClick={(e) => this.handleClearTodo(e)} percentageOfTodo={getTodoPercentageOfCompleted(note.content)} />
443443
</div>

browser/main/Detail/SnippetNoteDetail.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,7 @@ class SnippetNoteDetail extends React.Component {
788788
showTagsAlphabetically={config.ui.showTagsAlphabetically}
789789
data={data}
790790
onChange={(e) => this.handleChange(e)}
791-
tagConfig={config.tag}
791+
coloredTags={config.coloredTags}
792792
/>
793793
</div>
794794
<div styleName='info-right'>

browser/main/Detail/TagSelect.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ class TagSelect extends React.Component {
179179
}
180180

181181
render () {
182-
const { value, className, showTagsAlphabetically, tagConfig } = this.props
182+
const { value, className, showTagsAlphabetically, coloredTags } = this.props
183183

184184
const tagList = _.isArray(value)
185185
? (showTagsAlphabetically ? _.sortBy(value) : value).map((tag) => {
186186
return (
187187
<span styleName='tag'
188188
key={tag}
189-
style={{backgroundColor: tagConfig[tag]}}
189+
style={{backgroundColor: coloredTags[tag]}}
190190
>
191191
<span styleName='tag-label' onClick={(e) => this.handleTagLabelClick(tag)}>#{tag}</span>
192192
<button styleName='tag-removeButton'
@@ -242,7 +242,7 @@ TagSelect.propTypes = {
242242
className: PropTypes.string,
243243
value: PropTypes.arrayOf(PropTypes.string),
244244
onChange: PropTypes.func,
245-
tagConfig: PropTypes.object
245+
coloredTags: PropTypes.object
246246
}
247247

248248
export default CSSModules(TagSelect, styles)

browser/main/NoteList/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,7 +1047,7 @@ class NoteList extends React.Component {
10471047
storageName={this.getNoteStorage(note).name}
10481048
viewType={viewType}
10491049
showTagsAlphabetically={config.ui.showTagsAlphabetically}
1050-
tagConfig={config.tag}
1050+
coloredTags={config.coloredTags}
10511051
/>
10521052
)
10531053
}

browser/main/SideNav/index.js

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SideNav extends React.Component {
3232
super(props)
3333

3434
this.state = {
35-
colorPickerState: {
35+
colorPicker: {
3636
show: false,
3737
color: null,
3838
tagName: null,
@@ -131,7 +131,7 @@ class SideNav extends React.Component {
131131

132132
dismissColorPicker () {
133133
this.setState({
134-
colorPickerState: {
134+
colorPicker: {
135135
show: false
136136
}
137137
})
@@ -140,21 +140,21 @@ class SideNav extends React.Component {
140140
displayColorPicker (tagName, rect) {
141141
const { config } = this.props
142142
this.setState({
143-
colorPickerState: {
143+
colorPicker: {
144144
show: true,
145-
color: config.tag && config.tag[tagName],
145+
color: config.coloredTags[tagName],
146146
tagName,
147147
targetRect: rect
148148
}
149149
})
150150
}
151151

152152
handleColorPickerConfirm (color) {
153-
const { dispatch, config: {tag} } = this.props
154-
const { colorPickerState: { tagName } } = this.state
155-
const tagConfig = Object.assign({}, tag, {[tagName]: color.hex})
153+
const { dispatch, config: {coloredTags} } = this.props
154+
const { colorPicker: { tagName } } = this.state
155+
const newColoredTags = Object.assign({}, coloredTags, {[tagName]: color.hex})
156156

157-
const config = {tag: tagConfig}
157+
const config = { coloredTags: newColoredTags }
158158
ConfigManager.set(config)
159159
dispatch({
160160
type: 'SET_CONFIG',
@@ -164,12 +164,13 @@ class SideNav extends React.Component {
164164
}
165165

166166
handleColorPickerReset () {
167-
const { dispatch, config: {tag} } = this.props
168-
const { colorPickerState: { tagName } } = this.state
169-
const tagConfig = Object.assign({}, tag)
170-
delete tagConfig[tagName]
167+
const { dispatch, config: {coloredTags} } = this.props
168+
const { colorPicker: { tagName } } = this.state
169+
const newColoredTags = Object.assign({}, coloredTags)
171170

172-
const config = {tag: tagConfig}
171+
delete newColoredTags[tagName]
172+
173+
const config = { coloredTags: newColoredTags }
173174
ConfigManager.set(config)
174175
dispatch({
175176
type: 'SET_CONFIG',
@@ -278,6 +279,7 @@ class SideNav extends React.Component {
278279

279280
tagListComponent () {
280281
const { data, location, config } = this.props
282+
const { colorPicker } = this.state
281283
const activeTags = this.getActiveTags(location.pathname)
282284
const relatedTags = this.getRelatedTags(activeTags, data.noteMap)
283285
let tagList = _.sortBy(data.tagNoteMap.map(
@@ -308,11 +310,11 @@ class SideNav extends React.Component {
308310
handleClickTagListItem={this.handleClickTagListItem.bind(this)}
309311
handleClickNarrowToTag={this.handleClickNarrowToTag.bind(this)}
310312
handleContextMenu={this.handleTagContextMenu.bind(this)}
311-
isActive={this.getTagActive(location.pathname, tag.name)}
313+
isActive={this.getTagActive(location.pathname, tag.name) || (colorPicker.tagName === tag.name)}
312314
isRelated={tag.related}
313315
key={tag.name}
314316
count={tag.size}
315-
color={config.tag[tag.name]}
317+
color={config.coloredTags[tag.name]}
316318
/>
317319
)
318320
})
@@ -405,7 +407,7 @@ class SideNav extends React.Component {
405407

406408
render () {
407409
const { data, location, config, dispatch } = this.props
408-
const { colorPickerState } = this.state
410+
const { colorPicker: colorPickerState } = this.state
409411

410412
const isFolded = config.isSideNavFolded
411413

browser/main/lib/ConfigManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const DEFAULT_CONFIG = {
8787
username: '',
8888
password: ''
8989
},
90-
tag: {}
90+
coloredTags: {}
9191
}
9292

9393
function validate (config) {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"react": "^15.5.4",
9898
"react-autosuggest": "^9.4.0",
9999
"react-codemirror": "^0.3.0",
100-
"react-color": "^2.17.0",
100+
"react-color": "^2.2.2",
101101
"react-debounce-render": "^4.0.1",
102102
"react-dom": "^15.0.2",
103103
"react-image-carousel": "^2.0.18",
@@ -154,7 +154,6 @@
154154
"merge-stream": "^1.0.0",
155155
"mock-require": "^3.0.1",
156156
"nib": "^1.1.0",
157-
"react-color": "^2.2.2",
158157
"react-css-modules": "^3.7.6",
159158
"react-input-autosize": "^1.1.0",
160159
"react-router": "^2.4.0",

0 commit comments

Comments
 (0)