1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-18 12:11:43 +00:00

implement tagItem active styleName

This commit is contained in:
Sosuke Suzuki
2017-10-10 00:31:26 +09:00
parent 9b60814292
commit ff4b96b622
3 changed files with 17 additions and 4 deletions

View File

@@ -8,10 +8,11 @@ import CSSModules from 'browser/lib/CSSModules'
/** /**
* @param {string} name * @param {string} name
* @param {Function} handleClickTagListItem * @param {Function} handleClickTagListItem
* @param {bool} isActive
*/ */
const TagListItem = ({name, handleClickTagListItem}) => ( const TagListItem = ({name, handleClickTagListItem, isActive}) => (
<button styleName='tagList-item' onClick={() => handleClickTagListItem(name)}> <button styleName={isActive? 'tagList-item-active' : 'tagList-item'} onClick={() => handleClickTagListItem(name)}>
<span styleName='tagList-item-name'> <span styleName='tagList-item-name'>
{`# ${name}`} {`# ${name}`}
</span> </span>

View File

@@ -20,6 +20,18 @@
color $ui-text-color color $ui-text-color
background-color $ui-button--active-backgroundColor background-color $ui-button--active-backgroundColor
.tagList-item-active
background-color $ui-button--active-backgroundColor
display flex
width 100%
height 26px
padding 0
margin-bottom 5px
text-align left
border none
overflow ellipsis
font-size 12px
.tagList-item-name .tagList-item-name
display block display block
flex 1 flex 1
@@ -31,4 +43,3 @@
border-color transparent border-color transparent
overflow hidden overflow hidden
text-overflow ellipsis text-overflow ellipsis

View File

@@ -95,7 +95,7 @@ class SideNav extends React.Component {
} }
tagListComponent () { tagListComponent () {
const { data } = this.props const { data, location } = this.props
let tagList = data.tagNoteMap.map((tag, key) => { let tagList = data.tagNoteMap.map((tag, key) => {
return key return key
}) })
@@ -104,6 +104,7 @@ class SideNav extends React.Component {
<TagListItem <TagListItem
name={tag} name={tag}
handleClickTagListItem={this.handleClickTagListItem.bind(this)} handleClickTagListItem={this.handleClickTagListItem.bind(this)}
isActive={!!location.pathname.match(tag)}
key={tag} key={tag}
/> />
)) ))