mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 17:56:25 +00:00
rename config.tag to config.coloredTags
This commit is contained in:
@@ -17,9 +17,9 @@
|
|||||||
height 1.6em
|
height 1.6em
|
||||||
border 1px solid #888888
|
border 1px solid #888888
|
||||||
background-color #fff
|
background-color #fff
|
||||||
font-size 16px
|
font-size 15px
|
||||||
border-radius 4px
|
border-radius 2px
|
||||||
.btn-confirm
|
.btn-confirm
|
||||||
background-color $ui-button-default--active-backgroundColor
|
background-color #1EC38B
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import i18n from 'browser/lib/i18n'
|
|||||||
/**
|
/**
|
||||||
* @description Tag element component.
|
* @description Tag element component.
|
||||||
* @param {string} tagName
|
* @param {string} tagName
|
||||||
|
* @param {string} color
|
||||||
* @return {React.Component}
|
* @return {React.Component}
|
||||||
*/
|
*/
|
||||||
const TagElement = ({ tagName, color }) => (
|
const TagElement = ({ tagName, color }) => (
|
||||||
@@ -25,9 +26,10 @@ const TagElement = ({ tagName, color }) => (
|
|||||||
* @description Tag element list component.
|
* @description Tag element list component.
|
||||||
* @param {Array|null} tags
|
* @param {Array|null} tags
|
||||||
* @param {boolean} showTagsAlphabetically
|
* @param {boolean} showTagsAlphabetically
|
||||||
|
* @param {Object} coloredTags
|
||||||
* @return {React.Component}
|
* @return {React.Component}
|
||||||
*/
|
*/
|
||||||
const TagElementList = (tags, showTagsAlphabetically, tagConfig) => {
|
const TagElementList = (tags, showTagsAlphabetically, coloredTags) => {
|
||||||
if (!isArray(tags)) {
|
if (!isArray(tags)) {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
@@ -35,7 +37,7 @@ const TagElementList = (tags, showTagsAlphabetically, tagConfig) => {
|
|||||||
if (showTagsAlphabetically) {
|
if (showTagsAlphabetically) {
|
||||||
return _.sortBy(tags).map(tag => TagElement({ tagName: tag }))
|
return _.sortBy(tags).map(tag => TagElement({ tagName: tag }))
|
||||||
} else {
|
} else {
|
||||||
return tags.map(tag => TagElement({ tagName: tag, color: tagConfig[tag] }))
|
return tags.map(tag => TagElement({ tagName: tag, color: coloredTags[tag] }))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,6 +48,7 @@ const TagElementList = (tags, showTagsAlphabetically, tagConfig) => {
|
|||||||
* @param {Function} handleNoteClick
|
* @param {Function} handleNoteClick
|
||||||
* @param {Function} handleNoteContextMenu
|
* @param {Function} handleNoteContextMenu
|
||||||
* @param {Function} handleDragStart
|
* @param {Function} handleDragStart
|
||||||
|
* @param {Object} coloredTags
|
||||||
* @param {string} dateDisplay
|
* @param {string} dateDisplay
|
||||||
*/
|
*/
|
||||||
const NoteItem = ({
|
const NoteItem = ({
|
||||||
@@ -60,7 +63,7 @@ const NoteItem = ({
|
|||||||
folderName,
|
folderName,
|
||||||
viewType,
|
viewType,
|
||||||
showTagsAlphabetically,
|
showTagsAlphabetically,
|
||||||
tagConfig
|
coloredTags
|
||||||
}) => (
|
}) => (
|
||||||
<div
|
<div
|
||||||
styleName={isActive ? 'item--active' : 'item'}
|
styleName={isActive ? 'item--active' : 'item'}
|
||||||
@@ -98,7 +101,7 @@ const NoteItem = ({
|
|||||||
<div styleName='item-bottom'>
|
<div styleName='item-bottom'>
|
||||||
<div styleName='item-bottom-tagList'>
|
<div styleName='item-bottom-tagList'>
|
||||||
{note.tags.length > 0
|
{note.tags.length > 0
|
||||||
? TagElementList(note.tags, showTagsAlphabetically, tagConfig)
|
? TagElementList(note.tags, showTagsAlphabetically, coloredTags)
|
||||||
: <span
|
: <span
|
||||||
style={{ fontStyle: 'italic', opacity: 0.5 }}
|
style={{ fontStyle: 'italic', opacity: 0.5 }}
|
||||||
styleName='item-bottom-tagList-empty'
|
styleName='item-bottom-tagList-empty'
|
||||||
@@ -128,7 +131,7 @@ const NoteItem = ({
|
|||||||
NoteItem.propTypes = {
|
NoteItem.propTypes = {
|
||||||
isActive: PropTypes.bool.isRequired,
|
isActive: PropTypes.bool.isRequired,
|
||||||
dateDisplay: PropTypes.string.isRequired,
|
dateDisplay: PropTypes.string.isRequired,
|
||||||
tagConfig: PropTypes.object,
|
coloredTags: PropTypes.object,
|
||||||
note: PropTypes.shape({
|
note: PropTypes.shape({
|
||||||
storage: PropTypes.string.isRequired,
|
storage: PropTypes.string.isRequired,
|
||||||
key: PropTypes.string.isRequired,
|
key: PropTypes.string.isRequired,
|
||||||
|
|||||||
@@ -437,7 +437,7 @@ class MarkdownNoteDetail extends React.Component {
|
|||||||
showTagsAlphabetically={config.ui.showTagsAlphabetically}
|
showTagsAlphabetically={config.ui.showTagsAlphabetically}
|
||||||
data={data}
|
data={data}
|
||||||
onChange={this.handleUpdateTag.bind(this)}
|
onChange={this.handleUpdateTag.bind(this)}
|
||||||
tagConfig={config.tag}
|
coloredTags={config.coloredTags}
|
||||||
/>
|
/>
|
||||||
<TodoListPercentage onClearCheckboxClick={(e) => this.handleClearTodo(e)} percentageOfTodo={getTodoPercentageOfCompleted(note.content)} />
|
<TodoListPercentage onClearCheckboxClick={(e) => this.handleClearTodo(e)} percentageOfTodo={getTodoPercentageOfCompleted(note.content)} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -788,7 +788,7 @@ class SnippetNoteDetail extends React.Component {
|
|||||||
showTagsAlphabetically={config.ui.showTagsAlphabetically}
|
showTagsAlphabetically={config.ui.showTagsAlphabetically}
|
||||||
data={data}
|
data={data}
|
||||||
onChange={(e) => this.handleChange(e)}
|
onChange={(e) => this.handleChange(e)}
|
||||||
tagConfig={config.tag}
|
coloredTags={config.coloredTags}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div styleName='info-right'>
|
<div styleName='info-right'>
|
||||||
|
|||||||
@@ -179,14 +179,14 @@ class TagSelect extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { value, className, showTagsAlphabetically, tagConfig } = this.props
|
const { value, className, showTagsAlphabetically, coloredTags } = this.props
|
||||||
|
|
||||||
const tagList = _.isArray(value)
|
const tagList = _.isArray(value)
|
||||||
? (showTagsAlphabetically ? _.sortBy(value) : value).map((tag) => {
|
? (showTagsAlphabetically ? _.sortBy(value) : value).map((tag) => {
|
||||||
return (
|
return (
|
||||||
<span styleName='tag'
|
<span styleName='tag'
|
||||||
key={tag}
|
key={tag}
|
||||||
style={{backgroundColor: tagConfig[tag]}}
|
style={{backgroundColor: coloredTags[tag]}}
|
||||||
>
|
>
|
||||||
<span styleName='tag-label' onClick={(e) => this.handleTagLabelClick(tag)}>#{tag}</span>
|
<span styleName='tag-label' onClick={(e) => this.handleTagLabelClick(tag)}>#{tag}</span>
|
||||||
<button styleName='tag-removeButton'
|
<button styleName='tag-removeButton'
|
||||||
@@ -242,7 +242,7 @@ TagSelect.propTypes = {
|
|||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
value: PropTypes.arrayOf(PropTypes.string),
|
value: PropTypes.arrayOf(PropTypes.string),
|
||||||
onChange: PropTypes.func,
|
onChange: PropTypes.func,
|
||||||
tagConfig: PropTypes.object
|
coloredTags: PropTypes.object
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CSSModules(TagSelect, styles)
|
export default CSSModules(TagSelect, styles)
|
||||||
|
|||||||
@@ -1047,7 +1047,7 @@ class NoteList extends React.Component {
|
|||||||
storageName={this.getNoteStorage(note).name}
|
storageName={this.getNoteStorage(note).name}
|
||||||
viewType={viewType}
|
viewType={viewType}
|
||||||
showTagsAlphabetically={config.ui.showTagsAlphabetically}
|
showTagsAlphabetically={config.ui.showTagsAlphabetically}
|
||||||
tagConfig={config.tag}
|
coloredTags={config.coloredTags}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ class SideNav extends React.Component {
|
|||||||
super(props)
|
super(props)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
colorPickerState: {
|
colorPicker: {
|
||||||
show: false,
|
show: false,
|
||||||
color: null,
|
color: null,
|
||||||
tagName: null,
|
tagName: null,
|
||||||
@@ -131,7 +131,7 @@ class SideNav extends React.Component {
|
|||||||
|
|
||||||
dismissColorPicker () {
|
dismissColorPicker () {
|
||||||
this.setState({
|
this.setState({
|
||||||
colorPickerState: {
|
colorPicker: {
|
||||||
show: false
|
show: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -140,9 +140,9 @@ class SideNav extends React.Component {
|
|||||||
displayColorPicker (tagName, rect) {
|
displayColorPicker (tagName, rect) {
|
||||||
const { config } = this.props
|
const { config } = this.props
|
||||||
this.setState({
|
this.setState({
|
||||||
colorPickerState: {
|
colorPicker: {
|
||||||
show: true,
|
show: true,
|
||||||
color: config.tag && config.tag[tagName],
|
color: config.coloredTags[tagName],
|
||||||
tagName,
|
tagName,
|
||||||
targetRect: rect
|
targetRect: rect
|
||||||
}
|
}
|
||||||
@@ -150,11 +150,11 @@ class SideNav extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleColorPickerConfirm (color) {
|
handleColorPickerConfirm (color) {
|
||||||
const { dispatch, config: {tag} } = this.props
|
const { dispatch, config: {coloredTags} } = this.props
|
||||||
const { colorPickerState: { tagName } } = this.state
|
const { colorPicker: { tagName } } = this.state
|
||||||
const tagConfig = Object.assign({}, tag, {[tagName]: color.hex})
|
const newColoredTags = Object.assign({}, coloredTags, {[tagName]: color.hex})
|
||||||
|
|
||||||
const config = {tag: tagConfig}
|
const config = { coloredTags: newColoredTags }
|
||||||
ConfigManager.set(config)
|
ConfigManager.set(config)
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'SET_CONFIG',
|
type: 'SET_CONFIG',
|
||||||
@@ -164,12 +164,13 @@ class SideNav extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleColorPickerReset () {
|
handleColorPickerReset () {
|
||||||
const { dispatch, config: {tag} } = this.props
|
const { dispatch, config: {coloredTags} } = this.props
|
||||||
const { colorPickerState: { tagName } } = this.state
|
const { colorPicker: { tagName } } = this.state
|
||||||
const tagConfig = Object.assign({}, tag)
|
const newColoredTags = Object.assign({}, coloredTags)
|
||||||
delete tagConfig[tagName]
|
|
||||||
|
|
||||||
const config = {tag: tagConfig}
|
delete newColoredTags[tagName]
|
||||||
|
|
||||||
|
const config = { coloredTags: newColoredTags }
|
||||||
ConfigManager.set(config)
|
ConfigManager.set(config)
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'SET_CONFIG',
|
type: 'SET_CONFIG',
|
||||||
@@ -278,6 +279,7 @@ class SideNav extends React.Component {
|
|||||||
|
|
||||||
tagListComponent () {
|
tagListComponent () {
|
||||||
const { data, location, config } = this.props
|
const { data, location, config } = this.props
|
||||||
|
const { colorPicker } = this.state
|
||||||
const activeTags = this.getActiveTags(location.pathname)
|
const activeTags = this.getActiveTags(location.pathname)
|
||||||
const relatedTags = this.getRelatedTags(activeTags, data.noteMap)
|
const relatedTags = this.getRelatedTags(activeTags, data.noteMap)
|
||||||
let tagList = _.sortBy(data.tagNoteMap.map(
|
let tagList = _.sortBy(data.tagNoteMap.map(
|
||||||
@@ -308,11 +310,11 @@ class SideNav extends React.Component {
|
|||||||
handleClickTagListItem={this.handleClickTagListItem.bind(this)}
|
handleClickTagListItem={this.handleClickTagListItem.bind(this)}
|
||||||
handleClickNarrowToTag={this.handleClickNarrowToTag.bind(this)}
|
handleClickNarrowToTag={this.handleClickNarrowToTag.bind(this)}
|
||||||
handleContextMenu={this.handleTagContextMenu.bind(this)}
|
handleContextMenu={this.handleTagContextMenu.bind(this)}
|
||||||
isActive={this.getTagActive(location.pathname, tag.name)}
|
isActive={this.getTagActive(location.pathname, tag.name) || (colorPicker.tagName === tag.name)}
|
||||||
isRelated={tag.related}
|
isRelated={tag.related}
|
||||||
key={tag.name}
|
key={tag.name}
|
||||||
count={tag.size}
|
count={tag.size}
|
||||||
color={config.tag[tag.name]}
|
color={config.coloredTags[tag.name]}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
@@ -405,7 +407,7 @@ class SideNav extends React.Component {
|
|||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { data, location, config, dispatch } = this.props
|
const { data, location, config, dispatch } = this.props
|
||||||
const { colorPickerState } = this.state
|
const { colorPicker: colorPickerState } = this.state
|
||||||
|
|
||||||
const isFolded = config.isSideNavFolded
|
const isFolded = config.isSideNavFolded
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export const DEFAULT_CONFIG = {
|
|||||||
username: '',
|
username: '',
|
||||||
password: ''
|
password: ''
|
||||||
},
|
},
|
||||||
tag: {}
|
coloredTags: {}
|
||||||
}
|
}
|
||||||
|
|
||||||
function validate (config) {
|
function validate (config) {
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
"react": "^15.5.4",
|
"react": "^15.5.4",
|
||||||
"react-autosuggest": "^9.4.0",
|
"react-autosuggest": "^9.4.0",
|
||||||
"react-codemirror": "^0.3.0",
|
"react-codemirror": "^0.3.0",
|
||||||
"react-color": "^2.17.0",
|
"react-color": "^2.2.2",
|
||||||
"react-debounce-render": "^4.0.1",
|
"react-debounce-render": "^4.0.1",
|
||||||
"react-dom": "^15.0.2",
|
"react-dom": "^15.0.2",
|
||||||
"react-image-carousel": "^2.0.18",
|
"react-image-carousel": "^2.0.18",
|
||||||
@@ -154,7 +154,6 @@
|
|||||||
"merge-stream": "^1.0.0",
|
"merge-stream": "^1.0.0",
|
||||||
"mock-require": "^3.0.1",
|
"mock-require": "^3.0.1",
|
||||||
"nib": "^1.1.0",
|
"nib": "^1.1.0",
|
||||||
"react-color": "^2.2.2",
|
|
||||||
"react-css-modules": "^3.7.6",
|
"react-css-modules": "^3.7.6",
|
||||||
"react-input-autosize": "^1.1.0",
|
"react-input-autosize": "^1.1.0",
|
||||||
"react-router": "^2.4.0",
|
"react-router": "^2.4.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user